babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860
  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. _areAttributesDirty: boolean;
  7692. /** @hidden */
  7693. _areTexturesDirty: boolean;
  7694. /** @hidden */
  7695. _areFresnelDirty: boolean;
  7696. /** @hidden */
  7697. _areMiscDirty: boolean;
  7698. /** @hidden */
  7699. _areImageProcessingDirty: boolean;
  7700. /** @hidden */
  7701. _normals: boolean;
  7702. /** @hidden */
  7703. _uvs: boolean;
  7704. /** @hidden */
  7705. _needNormals: boolean;
  7706. /** @hidden */
  7707. _needUVs: boolean;
  7708. [id: string]: any;
  7709. /**
  7710. * Specifies if the material needs to be re-calculated
  7711. */
  7712. readonly isDirty: boolean;
  7713. /**
  7714. * Marks the material to indicate that it has been re-calculated
  7715. */
  7716. markAsProcessed(): void;
  7717. /**
  7718. * Marks the material to indicate that it needs to be re-calculated
  7719. */
  7720. markAsUnprocessed(): void;
  7721. /**
  7722. * Marks the material to indicate all of its defines need to be re-calculated
  7723. */
  7724. markAllAsDirty(): void;
  7725. /**
  7726. * Marks the material to indicate that image processing needs to be re-calculated
  7727. */
  7728. markAsImageProcessingDirty(): void;
  7729. /**
  7730. * Marks the material to indicate the lights need to be re-calculated
  7731. */
  7732. markAsLightDirty(): void;
  7733. /**
  7734. * Marks the attribute state as changed
  7735. */
  7736. markAsAttributesDirty(): void;
  7737. /**
  7738. * Marks the texture state as changed
  7739. */
  7740. markAsTexturesDirty(): void;
  7741. /**
  7742. * Marks the fresnel state as changed
  7743. */
  7744. markAsFresnelDirty(): void;
  7745. /**
  7746. * Marks the misc state as changed
  7747. */
  7748. markAsMiscDirty(): void;
  7749. /**
  7750. * Rebuilds the material defines
  7751. */
  7752. rebuild(): void;
  7753. /**
  7754. * Specifies if two material defines are equal
  7755. * @param other - A material define instance to compare to
  7756. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7757. */
  7758. isEqual(other: MaterialDefines): boolean;
  7759. /**
  7760. * Clones this instance's defines to another instance
  7761. * @param other - material defines to clone values to
  7762. */
  7763. cloneTo(other: MaterialDefines): void;
  7764. /**
  7765. * Resets the material define values
  7766. */
  7767. reset(): void;
  7768. /**
  7769. * Converts the material define values to a string
  7770. * @returns - String of material define information
  7771. */
  7772. toString(): string;
  7773. }
  7774. }
  7775. declare module "babylonjs/Materials/colorCurves" {
  7776. import { Effect } from "babylonjs/Materials/effect";
  7777. /**
  7778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7780. * 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;
  7781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7782. */
  7783. export class ColorCurves {
  7784. private _dirty;
  7785. private _tempColor;
  7786. private _globalCurve;
  7787. private _highlightsCurve;
  7788. private _midtonesCurve;
  7789. private _shadowsCurve;
  7790. private _positiveCurve;
  7791. private _negativeCurve;
  7792. private _globalHue;
  7793. private _globalDensity;
  7794. private _globalSaturation;
  7795. private _globalExposure;
  7796. /**
  7797. * Gets the global Hue value.
  7798. * 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).
  7799. */
  7800. /**
  7801. * Sets the global Hue value.
  7802. * 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).
  7803. */
  7804. globalHue: number;
  7805. /**
  7806. * Gets the global Density value.
  7807. * 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.
  7808. * Values less than zero provide a filter of opposite hue.
  7809. */
  7810. /**
  7811. * Sets the global Density value.
  7812. * 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.
  7813. * Values less than zero provide a filter of opposite hue.
  7814. */
  7815. globalDensity: number;
  7816. /**
  7817. * Gets the global Saturation value.
  7818. * 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.
  7819. */
  7820. /**
  7821. * Sets the global Saturation value.
  7822. * 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.
  7823. */
  7824. globalSaturation: number;
  7825. /**
  7826. * Gets the global Exposure value.
  7827. * 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.
  7828. */
  7829. /**
  7830. * Sets the global Exposure value.
  7831. * 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.
  7832. */
  7833. globalExposure: number;
  7834. private _highlightsHue;
  7835. private _highlightsDensity;
  7836. private _highlightsSaturation;
  7837. private _highlightsExposure;
  7838. /**
  7839. * Gets the highlights Hue value.
  7840. * 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).
  7841. */
  7842. /**
  7843. * Sets the highlights Hue value.
  7844. * 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).
  7845. */
  7846. highlightsHue: number;
  7847. /**
  7848. * Gets the highlights Density value.
  7849. * 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.
  7850. * Values less than zero provide a filter of opposite hue.
  7851. */
  7852. /**
  7853. * Sets the highlights Density value.
  7854. * 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.
  7855. * Values less than zero provide a filter of opposite hue.
  7856. */
  7857. highlightsDensity: number;
  7858. /**
  7859. * Gets the highlights Saturation value.
  7860. * 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.
  7861. */
  7862. /**
  7863. * Sets the highlights Saturation value.
  7864. * 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.
  7865. */
  7866. highlightsSaturation: number;
  7867. /**
  7868. * Gets the highlights Exposure value.
  7869. * 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.
  7870. */
  7871. /**
  7872. * Sets the highlights Exposure value.
  7873. * 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.
  7874. */
  7875. highlightsExposure: number;
  7876. private _midtonesHue;
  7877. private _midtonesDensity;
  7878. private _midtonesSaturation;
  7879. private _midtonesExposure;
  7880. /**
  7881. * Gets the midtones Hue value.
  7882. * 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).
  7883. */
  7884. /**
  7885. * Sets the midtones Hue value.
  7886. * 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).
  7887. */
  7888. midtonesHue: number;
  7889. /**
  7890. * Gets the midtones Density value.
  7891. * 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.
  7892. * Values less than zero provide a filter of opposite hue.
  7893. */
  7894. /**
  7895. * Sets the midtones Density value.
  7896. * 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.
  7897. * Values less than zero provide a filter of opposite hue.
  7898. */
  7899. midtonesDensity: number;
  7900. /**
  7901. * Gets the midtones Saturation value.
  7902. * 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.
  7903. */
  7904. /**
  7905. * Sets the midtones Saturation value.
  7906. * 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.
  7907. */
  7908. midtonesSaturation: number;
  7909. /**
  7910. * Gets the midtones Exposure value.
  7911. * 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.
  7912. */
  7913. /**
  7914. * Sets the midtones Exposure value.
  7915. * 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.
  7916. */
  7917. midtonesExposure: number;
  7918. private _shadowsHue;
  7919. private _shadowsDensity;
  7920. private _shadowsSaturation;
  7921. private _shadowsExposure;
  7922. /**
  7923. * Gets the shadows Hue value.
  7924. * 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).
  7925. */
  7926. /**
  7927. * Sets the shadows Hue value.
  7928. * 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).
  7929. */
  7930. shadowsHue: number;
  7931. /**
  7932. * Gets the shadows Density value.
  7933. * 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.
  7934. * Values less than zero provide a filter of opposite hue.
  7935. */
  7936. /**
  7937. * Sets the shadows Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. shadowsDensity: number;
  7942. /**
  7943. * Gets the shadows Saturation value.
  7944. * 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.
  7945. */
  7946. /**
  7947. * Sets the shadows Saturation value.
  7948. * 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.
  7949. */
  7950. shadowsSaturation: number;
  7951. /**
  7952. * Gets the shadows Exposure value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the shadows Exposure value.
  7957. * 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.
  7958. */
  7959. shadowsExposure: number;
  7960. /**
  7961. * Returns the class name
  7962. * @returns The class name
  7963. */
  7964. getClassName(): string;
  7965. /**
  7966. * Binds the color curves to the shader.
  7967. * @param colorCurves The color curve to bind
  7968. * @param effect The effect to bind to
  7969. * @param positiveUniform The positive uniform shader parameter
  7970. * @param neutralUniform The neutral uniform shader parameter
  7971. * @param negativeUniform The negative uniform shader parameter
  7972. */
  7973. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7974. /**
  7975. * Prepare the list of uniforms associated with the ColorCurves effects.
  7976. * @param uniformsList The list of uniforms used in the effect
  7977. */
  7978. static PrepareUniforms(uniformsList: string[]): void;
  7979. /**
  7980. * Returns color grading data based on a hue, density, saturation and exposure value.
  7981. * @param filterHue The hue of the color filter.
  7982. * @param filterDensity The density of the color filter.
  7983. * @param saturation The saturation.
  7984. * @param exposure The exposure.
  7985. * @param result The result data container.
  7986. */
  7987. private getColorGradingDataToRef;
  7988. /**
  7989. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7990. * @param value The input slider value in range [-100,100].
  7991. * @returns Adjusted value.
  7992. */
  7993. private static applyColorGradingSliderNonlinear;
  7994. /**
  7995. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7996. * @param hue The hue (H) input.
  7997. * @param saturation The saturation (S) input.
  7998. * @param brightness The brightness (B) input.
  7999. * @result An RGBA color represented as Vector4.
  8000. */
  8001. private static fromHSBToRef;
  8002. /**
  8003. * Returns a value clamped between min and max
  8004. * @param value The value to clamp
  8005. * @param min The minimum of value
  8006. * @param max The maximum of value
  8007. * @returns The clamped value.
  8008. */
  8009. private static clamp;
  8010. /**
  8011. * Clones the current color curve instance.
  8012. * @return The cloned curves
  8013. */
  8014. clone(): ColorCurves;
  8015. /**
  8016. * Serializes the current color curve instance to a json representation.
  8017. * @return a JSON representation
  8018. */
  8019. serialize(): any;
  8020. /**
  8021. * Parses the color curve from a json representation.
  8022. * @param source the JSON source to parse
  8023. * @return The parsed curves
  8024. */
  8025. static Parse(source: any): ColorCurves;
  8026. }
  8027. }
  8028. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8029. import { Observable } from "babylonjs/Misc/observable";
  8030. import { Nullable } from "babylonjs/types";
  8031. import { Color4 } from "babylonjs/Maths/math.color";
  8032. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8033. import { Effect } from "babylonjs/Materials/effect";
  8034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8035. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8036. /**
  8037. * Interface to follow in your material defines to integrate easily the
  8038. * Image proccessing functions.
  8039. * @hidden
  8040. */
  8041. export interface IImageProcessingConfigurationDefines {
  8042. IMAGEPROCESSING: boolean;
  8043. VIGNETTE: boolean;
  8044. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8045. VIGNETTEBLENDMODEOPAQUE: boolean;
  8046. TONEMAPPING: boolean;
  8047. TONEMAPPING_ACES: boolean;
  8048. CONTRAST: boolean;
  8049. EXPOSURE: boolean;
  8050. COLORCURVES: boolean;
  8051. COLORGRADING: boolean;
  8052. COLORGRADING3D: boolean;
  8053. SAMPLER3DGREENDEPTH: boolean;
  8054. SAMPLER3DBGRMAP: boolean;
  8055. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8056. }
  8057. /**
  8058. * @hidden
  8059. */
  8060. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8061. IMAGEPROCESSING: boolean;
  8062. VIGNETTE: boolean;
  8063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8064. VIGNETTEBLENDMODEOPAQUE: boolean;
  8065. TONEMAPPING: boolean;
  8066. TONEMAPPING_ACES: boolean;
  8067. CONTRAST: boolean;
  8068. COLORCURVES: boolean;
  8069. COLORGRADING: boolean;
  8070. COLORGRADING3D: boolean;
  8071. SAMPLER3DGREENDEPTH: boolean;
  8072. SAMPLER3DBGRMAP: boolean;
  8073. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8074. EXPOSURE: boolean;
  8075. constructor();
  8076. }
  8077. /**
  8078. * This groups together the common properties used for image processing either in direct forward pass
  8079. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8080. * or not.
  8081. */
  8082. export class ImageProcessingConfiguration {
  8083. /**
  8084. * Default tone mapping applied in BabylonJS.
  8085. */
  8086. static readonly TONEMAPPING_STANDARD: number;
  8087. /**
  8088. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8089. * to other engines rendering to increase portability.
  8090. */
  8091. static readonly TONEMAPPING_ACES: number;
  8092. /**
  8093. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8094. */
  8095. colorCurves: Nullable<ColorCurves>;
  8096. private _colorCurvesEnabled;
  8097. /**
  8098. * Gets wether the color curves effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color curves effect is enabled.
  8102. */
  8103. colorCurvesEnabled: boolean;
  8104. private _colorGradingTexture;
  8105. /**
  8106. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8107. */
  8108. /**
  8109. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8110. */
  8111. colorGradingTexture: Nullable<BaseTexture>;
  8112. private _colorGradingEnabled;
  8113. /**
  8114. * Gets wether the color grading effect is enabled.
  8115. */
  8116. /**
  8117. * Sets wether the color grading effect is enabled.
  8118. */
  8119. colorGradingEnabled: boolean;
  8120. private _colorGradingWithGreenDepth;
  8121. /**
  8122. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8123. */
  8124. /**
  8125. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8126. */
  8127. colorGradingWithGreenDepth: boolean;
  8128. private _colorGradingBGR;
  8129. /**
  8130. * Gets wether the color grading texture contains BGR values.
  8131. */
  8132. /**
  8133. * Sets wether the color grading texture contains BGR values.
  8134. */
  8135. colorGradingBGR: boolean;
  8136. /** @hidden */
  8137. _exposure: number;
  8138. /**
  8139. * Gets the Exposure used in the effect.
  8140. */
  8141. /**
  8142. * Sets the Exposure used in the effect.
  8143. */
  8144. exposure: number;
  8145. private _toneMappingEnabled;
  8146. /**
  8147. * Gets wether the tone mapping effect is enabled.
  8148. */
  8149. /**
  8150. * Sets wether the tone mapping effect is enabled.
  8151. */
  8152. toneMappingEnabled: boolean;
  8153. private _toneMappingType;
  8154. /**
  8155. * Gets the type of tone mapping effect.
  8156. */
  8157. /**
  8158. * Sets the type of tone mapping effect used in BabylonJS.
  8159. */
  8160. toneMappingType: number;
  8161. protected _contrast: number;
  8162. /**
  8163. * Gets the contrast used in the effect.
  8164. */
  8165. /**
  8166. * Sets the contrast used in the effect.
  8167. */
  8168. contrast: number;
  8169. /**
  8170. * Vignette stretch size.
  8171. */
  8172. vignetteStretch: number;
  8173. /**
  8174. * Vignette centre X Offset.
  8175. */
  8176. vignetteCentreX: number;
  8177. /**
  8178. * Vignette centre Y Offset.
  8179. */
  8180. vignetteCentreY: number;
  8181. /**
  8182. * Vignette weight or intensity of the vignette effect.
  8183. */
  8184. vignetteWeight: number;
  8185. /**
  8186. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8187. * if vignetteEnabled is set to true.
  8188. */
  8189. vignetteColor: Color4;
  8190. /**
  8191. * Camera field of view used by the Vignette effect.
  8192. */
  8193. vignetteCameraFov: number;
  8194. private _vignetteBlendMode;
  8195. /**
  8196. * Gets the vignette blend mode allowing different kind of effect.
  8197. */
  8198. /**
  8199. * Sets the vignette blend mode allowing different kind of effect.
  8200. */
  8201. vignetteBlendMode: number;
  8202. private _vignetteEnabled;
  8203. /**
  8204. * Gets wether the vignette effect is enabled.
  8205. */
  8206. /**
  8207. * Sets wether the vignette effect is enabled.
  8208. */
  8209. vignetteEnabled: boolean;
  8210. private _applyByPostProcess;
  8211. /**
  8212. * Gets wether the image processing is applied through a post process or not.
  8213. */
  8214. /**
  8215. * Sets wether the image processing is applied through a post process or not.
  8216. */
  8217. applyByPostProcess: boolean;
  8218. private _isEnabled;
  8219. /**
  8220. * Gets wether the image processing is enabled or not.
  8221. */
  8222. /**
  8223. * Sets wether the image processing is enabled or not.
  8224. */
  8225. isEnabled: boolean;
  8226. /**
  8227. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8228. */
  8229. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8230. /**
  8231. * Method called each time the image processing information changes requires to recompile the effect.
  8232. */
  8233. protected _updateParameters(): void;
  8234. /**
  8235. * Gets the current class name.
  8236. * @return "ImageProcessingConfiguration"
  8237. */
  8238. getClassName(): string;
  8239. /**
  8240. * Prepare the list of uniforms associated with the Image Processing effects.
  8241. * @param uniforms The list of uniforms used in the effect
  8242. * @param defines the list of defines currently in use
  8243. */
  8244. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8245. /**
  8246. * Prepare the list of samplers associated with the Image Processing effects.
  8247. * @param samplersList The list of uniforms used in the effect
  8248. * @param defines the list of defines currently in use
  8249. */
  8250. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8251. /**
  8252. * Prepare the list of defines associated to the shader.
  8253. * @param defines the list of defines to complete
  8254. * @param forPostProcess Define if we are currently in post process mode or not
  8255. */
  8256. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8257. /**
  8258. * Returns true if all the image processing information are ready.
  8259. * @returns True if ready, otherwise, false
  8260. */
  8261. isReady(): boolean;
  8262. /**
  8263. * Binds the image processing to the shader.
  8264. * @param effect The effect to bind to
  8265. * @param aspectRatio Define the current aspect ratio of the effect
  8266. */
  8267. bind(effect: Effect, aspectRatio?: number): void;
  8268. /**
  8269. * Clones the current image processing instance.
  8270. * @return The cloned image processing
  8271. */
  8272. clone(): ImageProcessingConfiguration;
  8273. /**
  8274. * Serializes the current image processing instance to a json representation.
  8275. * @return a JSON representation
  8276. */
  8277. serialize(): any;
  8278. /**
  8279. * Parses the image processing from a json representation.
  8280. * @param source the JSON source to parse
  8281. * @return The parsed image processing
  8282. */
  8283. static Parse(source: any): ImageProcessingConfiguration;
  8284. private static _VIGNETTEMODE_MULTIPLY;
  8285. private static _VIGNETTEMODE_OPAQUE;
  8286. /**
  8287. * Used to apply the vignette as a mix with the pixel color.
  8288. */
  8289. static readonly VIGNETTEMODE_MULTIPLY: number;
  8290. /**
  8291. * Used to apply the vignette as a replacement of the pixel color.
  8292. */
  8293. static readonly VIGNETTEMODE_OPAQUE: number;
  8294. }
  8295. }
  8296. declare module "babylonjs/Shaders/postprocess.vertex" {
  8297. /** @hidden */
  8298. export var postprocessVertexShader: {
  8299. name: string;
  8300. shader: string;
  8301. };
  8302. }
  8303. declare module "babylonjs/Maths/math.axis" {
  8304. import { Vector3 } from "babylonjs/Maths/math.vector";
  8305. /** Defines supported spaces */
  8306. export enum Space {
  8307. /** Local (object) space */
  8308. LOCAL = 0,
  8309. /** World space */
  8310. WORLD = 1,
  8311. /** Bone space */
  8312. BONE = 2
  8313. }
  8314. /** Defines the 3 main axes */
  8315. export class Axis {
  8316. /** X axis */
  8317. static X: Vector3;
  8318. /** Y axis */
  8319. static Y: Vector3;
  8320. /** Z axis */
  8321. static Z: Vector3;
  8322. }
  8323. }
  8324. declare module "babylonjs/Cameras/targetCamera" {
  8325. import { Nullable } from "babylonjs/types";
  8326. import { Camera } from "babylonjs/Cameras/camera";
  8327. import { Scene } from "babylonjs/scene";
  8328. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8329. /**
  8330. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8331. * This is the base of the follow, arc rotate cameras and Free camera
  8332. * @see http://doc.babylonjs.com/features/cameras
  8333. */
  8334. export class TargetCamera extends Camera {
  8335. private static _RigCamTransformMatrix;
  8336. private static _TargetTransformMatrix;
  8337. private static _TargetFocalPoint;
  8338. /**
  8339. * Define the current direction the camera is moving to
  8340. */
  8341. cameraDirection: Vector3;
  8342. /**
  8343. * Define the current rotation the camera is rotating to
  8344. */
  8345. cameraRotation: Vector2;
  8346. /**
  8347. * When set, the up vector of the camera will be updated by the rotation of the camera
  8348. */
  8349. updateUpVectorFromRotation: boolean;
  8350. private _tmpQuaternion;
  8351. /**
  8352. * Define the current rotation of the camera
  8353. */
  8354. rotation: Vector3;
  8355. /**
  8356. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8357. */
  8358. rotationQuaternion: Quaternion;
  8359. /**
  8360. * Define the current speed of the camera
  8361. */
  8362. speed: number;
  8363. /**
  8364. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8365. * around all axis.
  8366. */
  8367. noRotationConstraint: boolean;
  8368. /**
  8369. * Define the current target of the camera as an object or a position.
  8370. */
  8371. lockedTarget: any;
  8372. /** @hidden */
  8373. _currentTarget: Vector3;
  8374. /** @hidden */
  8375. _initialFocalDistance: number;
  8376. /** @hidden */
  8377. _viewMatrix: Matrix;
  8378. /** @hidden */
  8379. _camMatrix: Matrix;
  8380. /** @hidden */
  8381. _cameraTransformMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraRotationMatrix: Matrix;
  8384. /** @hidden */
  8385. _referencePoint: Vector3;
  8386. /** @hidden */
  8387. _transformedReferencePoint: Vector3;
  8388. protected _globalCurrentTarget: Vector3;
  8389. protected _globalCurrentUpVector: Vector3;
  8390. /** @hidden */
  8391. _reset: () => void;
  8392. private _defaultUp;
  8393. /**
  8394. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8395. * This is the base of the follow, arc rotate cameras and Free camera
  8396. * @see http://doc.babylonjs.com/features/cameras
  8397. * @param name Defines the name of the camera in the scene
  8398. * @param position Defines the start position of the camera in the scene
  8399. * @param scene Defines the scene the camera belongs to
  8400. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8401. */
  8402. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8403. /**
  8404. * Gets the position in front of the camera at a given distance.
  8405. * @param distance The distance from the camera we want the position to be
  8406. * @returns the position
  8407. */
  8408. getFrontPosition(distance: number): Vector3;
  8409. /** @hidden */
  8410. _getLockedTargetPosition(): Nullable<Vector3>;
  8411. private _storedPosition;
  8412. private _storedRotation;
  8413. private _storedRotationQuaternion;
  8414. /**
  8415. * Store current camera state of the camera (fov, position, rotation, etc..)
  8416. * @returns the camera
  8417. */
  8418. storeState(): Camera;
  8419. /**
  8420. * Restored camera state. You must call storeState() first
  8421. * @returns whether it was successful or not
  8422. * @hidden
  8423. */
  8424. _restoreStateValues(): boolean;
  8425. /** @hidden */
  8426. _initCache(): void;
  8427. /** @hidden */
  8428. _updateCache(ignoreParentClass?: boolean): void;
  8429. /** @hidden */
  8430. _isSynchronizedViewMatrix(): boolean;
  8431. /** @hidden */
  8432. _computeLocalCameraSpeed(): number;
  8433. /**
  8434. * Defines the target the camera should look at.
  8435. * @param target Defines the new target as a Vector or a mesh
  8436. */
  8437. setTarget(target: Vector3): void;
  8438. /**
  8439. * Return the current target position of the camera. This value is expressed in local space.
  8440. * @returns the target position
  8441. */
  8442. getTarget(): Vector3;
  8443. /** @hidden */
  8444. _decideIfNeedsToMove(): boolean;
  8445. /** @hidden */
  8446. _updatePosition(): void;
  8447. /** @hidden */
  8448. _checkInputs(): void;
  8449. protected _updateCameraRotationMatrix(): void;
  8450. /**
  8451. * 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)
  8452. * @returns the current camera
  8453. */
  8454. private _rotateUpVectorWithCameraRotationMatrix;
  8455. private _cachedRotationZ;
  8456. private _cachedQuaternionRotationZ;
  8457. /** @hidden */
  8458. _getViewMatrix(): Matrix;
  8459. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8460. /**
  8461. * @hidden
  8462. */
  8463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8464. /**
  8465. * @hidden
  8466. */
  8467. _updateRigCameras(): void;
  8468. private _getRigCamPositionAndTarget;
  8469. /**
  8470. * Gets the current object class name.
  8471. * @return the class name
  8472. */
  8473. getClassName(): string;
  8474. }
  8475. }
  8476. declare module "babylonjs/Events/keyboardEvents" {
  8477. /**
  8478. * Gather the list of keyboard event types as constants.
  8479. */
  8480. export class KeyboardEventTypes {
  8481. /**
  8482. * The keydown event is fired when a key becomes active (pressed).
  8483. */
  8484. static readonly KEYDOWN: number;
  8485. /**
  8486. * The keyup event is fired when a key has been released.
  8487. */
  8488. static readonly KEYUP: number;
  8489. }
  8490. /**
  8491. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8492. */
  8493. export class KeyboardInfo {
  8494. /**
  8495. * Defines the type of event (KeyboardEventTypes)
  8496. */
  8497. type: number;
  8498. /**
  8499. * Defines the related dom event
  8500. */
  8501. event: KeyboardEvent;
  8502. /**
  8503. * Instantiates a new keyboard info.
  8504. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8505. * @param type Defines the type of event (KeyboardEventTypes)
  8506. * @param event Defines the related dom event
  8507. */
  8508. constructor(
  8509. /**
  8510. * Defines the type of event (KeyboardEventTypes)
  8511. */
  8512. type: number,
  8513. /**
  8514. * Defines the related dom event
  8515. */
  8516. event: KeyboardEvent);
  8517. }
  8518. /**
  8519. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8520. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8521. */
  8522. export class KeyboardInfoPre extends KeyboardInfo {
  8523. /**
  8524. * Defines the type of event (KeyboardEventTypes)
  8525. */
  8526. type: number;
  8527. /**
  8528. * Defines the related dom event
  8529. */
  8530. event: KeyboardEvent;
  8531. /**
  8532. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8533. */
  8534. skipOnPointerObservable: boolean;
  8535. /**
  8536. * Instantiates a new keyboard pre info.
  8537. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8538. * @param type Defines the type of event (KeyboardEventTypes)
  8539. * @param event Defines the related dom event
  8540. */
  8541. constructor(
  8542. /**
  8543. * Defines the type of event (KeyboardEventTypes)
  8544. */
  8545. type: number,
  8546. /**
  8547. * Defines the related dom event
  8548. */
  8549. event: KeyboardEvent);
  8550. }
  8551. }
  8552. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8553. import { Nullable } from "babylonjs/types";
  8554. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8555. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8556. /**
  8557. * Manage the keyboard inputs to control the movement of a free camera.
  8558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8559. */
  8560. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8561. /**
  8562. * Defines the camera the input is attached to.
  8563. */
  8564. camera: FreeCamera;
  8565. /**
  8566. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8567. */
  8568. keysUp: number[];
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8571. */
  8572. keysDown: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8575. */
  8576. keysLeft: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8579. */
  8580. keysRight: number[];
  8581. private _keys;
  8582. private _onCanvasBlurObserver;
  8583. private _onKeyboardObserver;
  8584. private _engine;
  8585. private _scene;
  8586. /**
  8587. * Attach the input controls to a specific dom element to get the input from.
  8588. * @param element Defines the element the controls should be listened from
  8589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8590. */
  8591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8592. /**
  8593. * Detach the current controls from the specified dom element.
  8594. * @param element Defines the element to stop listening the inputs from
  8595. */
  8596. detachControl(element: Nullable<HTMLElement>): void;
  8597. /**
  8598. * Update the current camera state depending on the inputs that have been used this frame.
  8599. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8600. */
  8601. checkInputs(): void;
  8602. /**
  8603. * Gets the class name of the current intput.
  8604. * @returns the class name
  8605. */
  8606. getClassName(): string;
  8607. /** @hidden */
  8608. _onLostFocus(): void;
  8609. /**
  8610. * Get the friendly name associated with the input class.
  8611. * @returns the input friendly name
  8612. */
  8613. getSimpleName(): string;
  8614. }
  8615. }
  8616. declare module "babylonjs/Lights/shadowLight" {
  8617. import { Camera } from "babylonjs/Cameras/camera";
  8618. import { Scene } from "babylonjs/scene";
  8619. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8621. import { Light } from "babylonjs/Lights/light";
  8622. /**
  8623. * Interface describing all the common properties and methods a shadow light needs to implement.
  8624. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8625. * as well as binding the different shadow properties to the effects.
  8626. */
  8627. export interface IShadowLight extends Light {
  8628. /**
  8629. * The light id in the scene (used in scene.findLighById for instance)
  8630. */
  8631. id: string;
  8632. /**
  8633. * The position the shdow will be casted from.
  8634. */
  8635. position: Vector3;
  8636. /**
  8637. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8638. */
  8639. direction: Vector3;
  8640. /**
  8641. * The transformed position. Position of the light in world space taking parenting in account.
  8642. */
  8643. transformedPosition: Vector3;
  8644. /**
  8645. * The transformed direction. Direction of the light in world space taking parenting in account.
  8646. */
  8647. transformedDirection: Vector3;
  8648. /**
  8649. * The friendly name of the light in the scene.
  8650. */
  8651. name: string;
  8652. /**
  8653. * Defines the shadow projection clipping minimum z value.
  8654. */
  8655. shadowMinZ: number;
  8656. /**
  8657. * Defines the shadow projection clipping maximum z value.
  8658. */
  8659. shadowMaxZ: number;
  8660. /**
  8661. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8662. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8663. */
  8664. computeTransformedInformation(): boolean;
  8665. /**
  8666. * Gets the scene the light belongs to.
  8667. * @returns The scene
  8668. */
  8669. getScene(): Scene;
  8670. /**
  8671. * Callback defining a custom Projection Matrix Builder.
  8672. * This can be used to override the default projection matrix computation.
  8673. */
  8674. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8675. /**
  8676. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8677. * @param matrix The materix to updated with the projection information
  8678. * @param viewMatrix The transform matrix of the light
  8679. * @param renderList The list of mesh to render in the map
  8680. * @returns The current light
  8681. */
  8682. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8683. /**
  8684. * Gets the current depth scale used in ESM.
  8685. * @returns The scale
  8686. */
  8687. getDepthScale(): number;
  8688. /**
  8689. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8690. * @returns true if a cube texture needs to be use
  8691. */
  8692. needCube(): boolean;
  8693. /**
  8694. * Detects if the projection matrix requires to be recomputed this frame.
  8695. * @returns true if it requires to be recomputed otherwise, false.
  8696. */
  8697. needProjectionMatrixCompute(): boolean;
  8698. /**
  8699. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8700. */
  8701. forceProjectionMatrixCompute(): void;
  8702. /**
  8703. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8704. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8705. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8706. */
  8707. getShadowDirection(faceIndex?: number): Vector3;
  8708. /**
  8709. * Gets the minZ used for shadow according to both the scene and the light.
  8710. * @param activeCamera The camera we are returning the min for
  8711. * @returns the depth min z
  8712. */
  8713. getDepthMinZ(activeCamera: Camera): number;
  8714. /**
  8715. * Gets the maxZ used for shadow according to both the scene and the light.
  8716. * @param activeCamera The camera we are returning the max for
  8717. * @returns the depth max z
  8718. */
  8719. getDepthMaxZ(activeCamera: Camera): number;
  8720. }
  8721. /**
  8722. * Base implementation IShadowLight
  8723. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8724. */
  8725. export abstract class ShadowLight extends Light implements IShadowLight {
  8726. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8727. protected _position: Vector3;
  8728. protected _setPosition(value: Vector3): void;
  8729. /**
  8730. * Sets the position the shadow will be casted from. Also use as the light position for both
  8731. * point and spot lights.
  8732. */
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  8737. position: Vector3;
  8738. protected _direction: Vector3;
  8739. protected _setDirection(value: Vector3): void;
  8740. /**
  8741. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8742. * Also use as the light direction on spot and directional lights.
  8743. */
  8744. /**
  8745. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. direction: Vector3;
  8749. private _shadowMinZ;
  8750. /**
  8751. * Gets the shadow projection clipping minimum z value.
  8752. */
  8753. /**
  8754. * Sets the shadow projection clipping minimum z value.
  8755. */
  8756. shadowMinZ: number;
  8757. private _shadowMaxZ;
  8758. /**
  8759. * Sets the shadow projection clipping maximum z value.
  8760. */
  8761. /**
  8762. * Gets the shadow projection clipping maximum z value.
  8763. */
  8764. shadowMaxZ: number;
  8765. /**
  8766. * Callback defining a custom Projection Matrix Builder.
  8767. * This can be used to override the default projection matrix computation.
  8768. */
  8769. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8770. /**
  8771. * The transformed position. Position of the light in world space taking parenting in account.
  8772. */
  8773. transformedPosition: Vector3;
  8774. /**
  8775. * The transformed direction. Direction of the light in world space taking parenting in account.
  8776. */
  8777. transformedDirection: Vector3;
  8778. private _needProjectionMatrixCompute;
  8779. /**
  8780. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8781. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8782. */
  8783. computeTransformedInformation(): boolean;
  8784. /**
  8785. * Return the depth scale used for the shadow map.
  8786. * @returns the depth scale.
  8787. */
  8788. getDepthScale(): number;
  8789. /**
  8790. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8791. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8792. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8793. */
  8794. getShadowDirection(faceIndex?: number): Vector3;
  8795. /**
  8796. * Returns the ShadowLight absolute position in the World.
  8797. * @returns the position vector in world space
  8798. */
  8799. getAbsolutePosition(): Vector3;
  8800. /**
  8801. * Sets the ShadowLight direction toward the passed target.
  8802. * @param target The point to target in local space
  8803. * @returns the updated ShadowLight direction
  8804. */
  8805. setDirectionToTarget(target: Vector3): Vector3;
  8806. /**
  8807. * Returns the light rotation in euler definition.
  8808. * @returns the x y z rotation in local space.
  8809. */
  8810. getRotation(): Vector3;
  8811. /**
  8812. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8813. * @returns true if a cube texture needs to be use
  8814. */
  8815. needCube(): boolean;
  8816. /**
  8817. * Detects if the projection matrix requires to be recomputed this frame.
  8818. * @returns true if it requires to be recomputed otherwise, false.
  8819. */
  8820. needProjectionMatrixCompute(): boolean;
  8821. /**
  8822. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8823. */
  8824. forceProjectionMatrixCompute(): void;
  8825. /** @hidden */
  8826. _initCache(): void;
  8827. /** @hidden */
  8828. _isSynchronized(): boolean;
  8829. /**
  8830. * Computes the world matrix of the node
  8831. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8832. * @returns the world matrix
  8833. */
  8834. computeWorldMatrix(force?: boolean): Matrix;
  8835. /**
  8836. * Gets the minZ used for shadow according to both the scene and the light.
  8837. * @param activeCamera The camera we are returning the min for
  8838. * @returns the depth min z
  8839. */
  8840. getDepthMinZ(activeCamera: Camera): number;
  8841. /**
  8842. * Gets the maxZ used for shadow according to both the scene and the light.
  8843. * @param activeCamera The camera we are returning the max for
  8844. * @returns the depth max z
  8845. */
  8846. getDepthMaxZ(activeCamera: Camera): number;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/materialHelper" {
  8858. import { Nullable } from "babylonjs/types";
  8859. import { Scene } from "babylonjs/scene";
  8860. import { Engine } from "babylonjs/Engines/engine";
  8861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8862. import { Light } from "babylonjs/Lights/light";
  8863. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8864. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8865. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8866. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8867. /**
  8868. * "Static Class" containing the most commonly used helper while dealing with material for
  8869. * rendering purpose.
  8870. *
  8871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8872. *
  8873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8874. */
  8875. export class MaterialHelper {
  8876. /**
  8877. * Bind the current view position to an effect.
  8878. * @param effect The effect to be bound
  8879. * @param scene The scene the eyes position is used from
  8880. */
  8881. static BindEyePosition(effect: Effect, scene: Scene): void;
  8882. /**
  8883. * Helps preparing the defines values about the UVs in used in the effect.
  8884. * UVs are shared as much as we can accross channels in the shaders.
  8885. * @param texture The texture we are preparing the UVs for
  8886. * @param defines The defines to update
  8887. * @param key The channel key "diffuse", "specular"... used in the shader
  8888. */
  8889. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8890. /**
  8891. * Binds a texture matrix value to its corrsponding uniform
  8892. * @param texture The texture to bind the matrix for
  8893. * @param uniformBuffer The uniform buffer receivin the data
  8894. * @param key The channel key "diffuse", "specular"... used in the shader
  8895. */
  8896. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8897. /**
  8898. * Gets the current status of the fog (should it be enabled?)
  8899. * @param mesh defines the mesh to evaluate for fog support
  8900. * @param scene defines the hosting scene
  8901. * @returns true if fog must be enabled
  8902. */
  8903. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8904. /**
  8905. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8906. * @param mesh defines the current mesh
  8907. * @param scene defines the current scene
  8908. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8909. * @param pointsCloud defines if point cloud rendering has to be turned on
  8910. * @param fogEnabled defines if fog has to be turned on
  8911. * @param alphaTest defines if alpha testing has to be turned on
  8912. * @param defines defines the current list of defines
  8913. */
  8914. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8915. /**
  8916. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8917. * @param scene defines the current scene
  8918. * @param engine defines the current engine
  8919. * @param defines specifies the list of active defines
  8920. * @param useInstances defines if instances have to be turned on
  8921. * @param useClipPlane defines if clip plane have to be turned on
  8922. */
  8923. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8924. /**
  8925. * Prepares the defines for bones
  8926. * @param mesh The mesh containing the geometry data we will draw
  8927. * @param defines The defines to update
  8928. */
  8929. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8930. /**
  8931. * Prepares the defines for morph targets
  8932. * @param mesh The mesh containing the geometry data we will draw
  8933. * @param defines The defines to update
  8934. */
  8935. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8936. /**
  8937. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8938. * @param mesh The mesh containing the geometry data we will draw
  8939. * @param defines The defines to update
  8940. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8941. * @param useBones Precise whether bones should be used or not (override mesh info)
  8942. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8943. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8944. * @returns false if defines are considered not dirty and have not been checked
  8945. */
  8946. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8947. /**
  8948. * Prepares the defines related to multiview
  8949. * @param scene The scene we are intending to draw
  8950. * @param defines The defines to update
  8951. */
  8952. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8953. /**
  8954. * Prepares the defines related to the light information passed in parameter
  8955. * @param scene The scene we are intending to draw
  8956. * @param mesh The mesh the effect is compiling for
  8957. * @param light The light the effect is compiling for
  8958. * @param lightIndex The index of the light
  8959. * @param defines The defines to update
  8960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8961. * @param state Defines the current state regarding what is needed (normals, etc...)
  8962. */
  8963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8964. needNormals: boolean;
  8965. needRebuild: boolean;
  8966. shadowEnabled: boolean;
  8967. specularEnabled: boolean;
  8968. lightmapMode: boolean;
  8969. }): void;
  8970. /**
  8971. * Prepares the defines related to the light information passed in parameter
  8972. * @param scene The scene we are intending to draw
  8973. * @param mesh The mesh the effect is compiling for
  8974. * @param defines The defines to update
  8975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8978. * @returns true if normals will be required for the rest of the effect
  8979. */
  8980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8981. /**
  8982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8983. * @param lightIndex defines the light index
  8984. * @param uniformsList The uniform list
  8985. * @param samplersList The sampler list
  8986. * @param projectedLightTexture defines if projected texture must be used
  8987. * @param uniformBuffersList defines an optional list of uniform buffers
  8988. */
  8989. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8990. /**
  8991. * Prepares the uniforms and samplers list to be used in the effect
  8992. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8993. * @param samplersList The sampler list
  8994. * @param defines The defines helping in the list generation
  8995. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8996. */
  8997. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8998. /**
  8999. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9000. * @param defines The defines to update while falling back
  9001. * @param fallbacks The authorized effect fallbacks
  9002. * @param maxSimultaneousLights The maximum number of lights allowed
  9003. * @param rank the current rank of the Effect
  9004. * @returns The newly affected rank
  9005. */
  9006. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9007. private static _TmpMorphInfluencers;
  9008. /**
  9009. * Prepares the list of attributes required for morph targets according to the effect defines.
  9010. * @param attribs The current list of supported attribs
  9011. * @param mesh The mesh to prepare the morph targets attributes for
  9012. * @param influencers The number of influencers
  9013. */
  9014. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9015. /**
  9016. * Prepares the list of attributes required for morph targets according to the effect defines.
  9017. * @param attribs The current list of supported attribs
  9018. * @param mesh The mesh to prepare the morph targets attributes for
  9019. * @param defines The current Defines of the effect
  9020. */
  9021. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9022. /**
  9023. * Prepares the list of attributes required for bones according to the effect defines.
  9024. * @param attribs The current list of supported attribs
  9025. * @param mesh The mesh to prepare the bones attributes for
  9026. * @param defines The current Defines of the effect
  9027. * @param fallbacks The current efffect fallback strategy
  9028. */
  9029. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9030. /**
  9031. * Check and prepare the list of attributes required for instances according to the effect defines.
  9032. * @param attribs The current list of supported attribs
  9033. * @param defines The current MaterialDefines of the effect
  9034. */
  9035. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9036. /**
  9037. * Add the list of attributes required for instances to the attribs array.
  9038. * @param attribs The current list of supported attribs
  9039. */
  9040. static PushAttributesForInstances(attribs: string[]): void;
  9041. /**
  9042. * Binds the light shadow information to the effect for the given mesh.
  9043. * @param light The light containing the generator
  9044. * @param scene The scene the lights belongs to
  9045. * @param mesh The mesh we are binding the information to render
  9046. * @param lightIndex The light index in the effect used to render the mesh
  9047. * @param effect The effect we are binding the data to
  9048. */
  9049. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9050. /**
  9051. * Binds the light information to the effect.
  9052. * @param light The light containing the generator
  9053. * @param effect The effect we are binding the data to
  9054. * @param lightIndex The light index in the effect used to render
  9055. */
  9056. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9057. /**
  9058. * Binds the lights information from the scene to the effect for the given mesh.
  9059. * @param light Light to bind
  9060. * @param lightIndex Light index
  9061. * @param scene The scene where the light belongs to
  9062. * @param mesh The mesh we are binding the information to render
  9063. * @param effect The effect we are binding the data to
  9064. * @param useSpecular Defines if specular is supported
  9065. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9066. */
  9067. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  9068. /**
  9069. * Binds the lights information from the scene to the effect for the given mesh.
  9070. * @param scene The scene the lights belongs to
  9071. * @param mesh The mesh we are binding the information to render
  9072. * @param effect The effect we are binding the data to
  9073. * @param defines The generated defines for the effect
  9074. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9075. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9076. */
  9077. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9078. private static _tempFogColor;
  9079. /**
  9080. * Binds the fog information from the scene to the effect for the given mesh.
  9081. * @param scene The scene the lights belongs to
  9082. * @param mesh The mesh we are binding the information to render
  9083. * @param effect The effect we are binding the data to
  9084. * @param linearSpace Defines if the fog effect is applied in linear space
  9085. */
  9086. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9087. /**
  9088. * Binds the bones information from the mesh to the effect.
  9089. * @param mesh The mesh we are binding the information to render
  9090. * @param effect The effect we are binding the data to
  9091. */
  9092. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9093. /**
  9094. * Binds the morph targets information from the mesh to the effect.
  9095. * @param abstractMesh The mesh we are binding the information to render
  9096. * @param effect The effect we are binding the data to
  9097. */
  9098. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9099. /**
  9100. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9101. * @param defines The generated defines used in the effect
  9102. * @param effect The effect we are binding the data to
  9103. * @param scene The scene we are willing to render with logarithmic scale for
  9104. */
  9105. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9106. /**
  9107. * Binds the clip plane information from the scene to the effect.
  9108. * @param scene The scene the clip plane information are extracted from
  9109. * @param effect The effect we are binding the data to
  9110. */
  9111. static BindClipPlane(effect: Effect, scene: Scene): void;
  9112. }
  9113. }
  9114. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9115. /** @hidden */
  9116. export var packingFunctions: {
  9117. name: string;
  9118. shader: string;
  9119. };
  9120. }
  9121. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9122. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9123. /** @hidden */
  9124. export var shadowMapPixelShader: {
  9125. name: string;
  9126. shader: string;
  9127. };
  9128. }
  9129. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9130. /** @hidden */
  9131. export var bonesDeclaration: {
  9132. name: string;
  9133. shader: string;
  9134. };
  9135. }
  9136. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9137. /** @hidden */
  9138. export var morphTargetsVertexGlobalDeclaration: {
  9139. name: string;
  9140. shader: string;
  9141. };
  9142. }
  9143. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9144. /** @hidden */
  9145. export var morphTargetsVertexDeclaration: {
  9146. name: string;
  9147. shader: string;
  9148. };
  9149. }
  9150. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9151. /** @hidden */
  9152. export var instancesDeclaration: {
  9153. name: string;
  9154. shader: string;
  9155. };
  9156. }
  9157. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9158. /** @hidden */
  9159. export var helperFunctions: {
  9160. name: string;
  9161. shader: string;
  9162. };
  9163. }
  9164. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9165. /** @hidden */
  9166. export var morphTargetsVertex: {
  9167. name: string;
  9168. shader: string;
  9169. };
  9170. }
  9171. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9172. /** @hidden */
  9173. export var instancesVertex: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9179. /** @hidden */
  9180. export var bonesVertex: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9186. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9187. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9188. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9189. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9190. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9191. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9192. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9193. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9194. /** @hidden */
  9195. export var shadowMapVertexShader: {
  9196. name: string;
  9197. shader: string;
  9198. };
  9199. }
  9200. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9201. /** @hidden */
  9202. export var depthBoxBlurPixelShader: {
  9203. name: string;
  9204. shader: string;
  9205. };
  9206. }
  9207. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Matrix } from "babylonjs/Maths/math.vector";
  9211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9213. import { Mesh } from "babylonjs/Meshes/mesh";
  9214. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9215. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9216. import { Effect } from "babylonjs/Materials/effect";
  9217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9218. import "babylonjs/Shaders/shadowMap.fragment";
  9219. import "babylonjs/Shaders/shadowMap.vertex";
  9220. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9221. import { Observable } from "babylonjs/Misc/observable";
  9222. /**
  9223. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9224. */
  9225. export interface ICustomShaderOptions {
  9226. /**
  9227. * Gets or sets the custom shader name to use
  9228. */
  9229. shaderName: string;
  9230. /**
  9231. * The list of attribute names used in the shader
  9232. */
  9233. attributes?: string[];
  9234. /**
  9235. * The list of unifrom names used in the shader
  9236. */
  9237. uniforms?: string[];
  9238. /**
  9239. * The list of sampler names used in the shader
  9240. */
  9241. samplers?: string[];
  9242. /**
  9243. * The list of defines used in the shader
  9244. */
  9245. defines?: string[];
  9246. }
  9247. /**
  9248. * Interface to implement to create a shadow generator compatible with BJS.
  9249. */
  9250. export interface IShadowGenerator {
  9251. /**
  9252. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9253. * @returns The render target texture if present otherwise, null
  9254. */
  9255. getShadowMap(): Nullable<RenderTargetTexture>;
  9256. /**
  9257. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9258. * @returns The render target texture if the shadow map is present otherwise, null
  9259. */
  9260. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9261. /**
  9262. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9263. * @param subMesh The submesh we want to render in the shadow map
  9264. * @param useInstances Defines wether will draw in the map using instances
  9265. * @returns true if ready otherwise, false
  9266. */
  9267. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9268. /**
  9269. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9270. * @param defines Defines of the material we want to update
  9271. * @param lightIndex Index of the light in the enabled light list of the material
  9272. */
  9273. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9274. /**
  9275. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9276. * defined in the generator but impacting the effect).
  9277. * It implies the unifroms available on the materials are the standard BJS ones.
  9278. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9279. * @param effect The effect we are binfing the information for
  9280. */
  9281. bindShadowLight(lightIndex: string, effect: Effect): void;
  9282. /**
  9283. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9284. * (eq to shadow prjection matrix * light transform matrix)
  9285. * @returns The transform matrix used to create the shadow map
  9286. */
  9287. getTransformMatrix(): Matrix;
  9288. /**
  9289. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9290. * Cube and 2D textures for instance.
  9291. */
  9292. recreateShadowMap(): void;
  9293. /**
  9294. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9295. * @param onCompiled Callback triggered at the and of the effects compilation
  9296. * @param options Sets of optional options forcing the compilation with different modes
  9297. */
  9298. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9299. useInstances: boolean;
  9300. }>): void;
  9301. /**
  9302. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9303. * @param options Sets of optional options forcing the compilation with different modes
  9304. * @returns A promise that resolves when the compilation completes
  9305. */
  9306. forceCompilationAsync(options?: Partial<{
  9307. useInstances: boolean;
  9308. }>): Promise<void>;
  9309. /**
  9310. * Serializes the shadow generator setup to a json object.
  9311. * @returns The serialized JSON object
  9312. */
  9313. serialize(): any;
  9314. /**
  9315. * Disposes the Shadow map and related Textures and effects.
  9316. */
  9317. dispose(): void;
  9318. }
  9319. /**
  9320. * Default implementation IShadowGenerator.
  9321. * This is the main object responsible of generating shadows in the framework.
  9322. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9323. */
  9324. export class ShadowGenerator implements IShadowGenerator {
  9325. /**
  9326. * Shadow generator mode None: no filtering applied.
  9327. */
  9328. static readonly FILTER_NONE: number;
  9329. /**
  9330. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9336. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9337. */
  9338. static readonly FILTER_POISSONSAMPLING: number;
  9339. /**
  9340. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9341. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9342. */
  9343. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9344. /**
  9345. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9346. * edge artifacts on steep falloff.
  9347. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9348. */
  9349. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9350. /**
  9351. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9352. * edge artifacts on steep falloff.
  9353. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9354. */
  9355. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9356. /**
  9357. * Shadow generator mode PCF: Percentage Closer Filtering
  9358. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9359. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9360. */
  9361. static readonly FILTER_PCF: number;
  9362. /**
  9363. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9364. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9365. * Contact Hardening
  9366. */
  9367. static readonly FILTER_PCSS: number;
  9368. /**
  9369. * Reserved for PCF and PCSS
  9370. * Highest Quality.
  9371. *
  9372. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9373. *
  9374. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9375. */
  9376. static readonly QUALITY_HIGH: number;
  9377. /**
  9378. * Reserved for PCF and PCSS
  9379. * Good tradeoff for quality/perf cross devices
  9380. *
  9381. * Execute PCF on a 3*3 kernel.
  9382. *
  9383. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9384. */
  9385. static readonly QUALITY_MEDIUM: number;
  9386. /**
  9387. * Reserved for PCF and PCSS
  9388. * The lowest quality but the fastest.
  9389. *
  9390. * Execute PCF on a 1*1 kernel.
  9391. *
  9392. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9393. */
  9394. static readonly QUALITY_LOW: number;
  9395. /** Gets or sets the custom shader name to use */
  9396. customShaderOptions: ICustomShaderOptions;
  9397. /**
  9398. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9399. */
  9400. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9401. /**
  9402. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9403. */
  9404. onAfterShadowMapRenderObservable: Observable<Effect>;
  9405. /**
  9406. * Observable triggered before a mesh is rendered in the shadow map.
  9407. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9408. */
  9409. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9410. /**
  9411. * Observable triggered after a mesh is rendered in the shadow map.
  9412. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9413. */
  9414. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9415. private _bias;
  9416. /**
  9417. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9418. */
  9419. /**
  9420. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9421. */
  9422. bias: number;
  9423. private _normalBias;
  9424. /**
  9425. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9426. */
  9427. /**
  9428. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9429. */
  9430. normalBias: number;
  9431. private _blurBoxOffset;
  9432. /**
  9433. * Gets the blur box offset: offset applied during the blur pass.
  9434. * Only useful if useKernelBlur = false
  9435. */
  9436. /**
  9437. * Sets the blur box offset: offset applied during the blur pass.
  9438. * Only useful if useKernelBlur = false
  9439. */
  9440. blurBoxOffset: number;
  9441. private _blurScale;
  9442. /**
  9443. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9444. * 2 means half of the size.
  9445. */
  9446. /**
  9447. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9448. * 2 means half of the size.
  9449. */
  9450. blurScale: number;
  9451. private _blurKernel;
  9452. /**
  9453. * Gets the blur kernel: kernel size of the blur pass.
  9454. * Only useful if useKernelBlur = true
  9455. */
  9456. /**
  9457. * Sets the blur kernel: kernel size of the blur pass.
  9458. * Only useful if useKernelBlur = true
  9459. */
  9460. blurKernel: number;
  9461. private _useKernelBlur;
  9462. /**
  9463. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9464. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9465. */
  9466. /**
  9467. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9468. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9469. */
  9470. useKernelBlur: boolean;
  9471. private _depthScale;
  9472. /**
  9473. * Gets the depth scale used in ESM mode.
  9474. */
  9475. /**
  9476. * Sets the depth scale used in ESM mode.
  9477. * This can override the scale stored on the light.
  9478. */
  9479. depthScale: number;
  9480. private _filter;
  9481. /**
  9482. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9483. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9484. */
  9485. /**
  9486. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9487. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9488. */
  9489. filter: number;
  9490. /**
  9491. * Gets if the current filter is set to Poisson Sampling.
  9492. */
  9493. /**
  9494. * Sets the current filter to Poisson Sampling.
  9495. */
  9496. usePoissonSampling: boolean;
  9497. /**
  9498. * Gets if the current filter is set to ESM.
  9499. */
  9500. /**
  9501. * Sets the current filter is to ESM.
  9502. */
  9503. useExponentialShadowMap: boolean;
  9504. /**
  9505. * Gets if the current filter is set to filtered ESM.
  9506. */
  9507. /**
  9508. * Gets if the current filter is set to filtered ESM.
  9509. */
  9510. useBlurExponentialShadowMap: boolean;
  9511. /**
  9512. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9513. * exponential to prevent steep falloff artifacts).
  9514. */
  9515. /**
  9516. * Sets the current filter to "close ESM" (using the inverse of the
  9517. * exponential to prevent steep falloff artifacts).
  9518. */
  9519. useCloseExponentialShadowMap: boolean;
  9520. /**
  9521. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9522. * exponential to prevent steep falloff artifacts).
  9523. */
  9524. /**
  9525. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9526. * exponential to prevent steep falloff artifacts).
  9527. */
  9528. useBlurCloseExponentialShadowMap: boolean;
  9529. /**
  9530. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9531. */
  9532. /**
  9533. * Sets the current filter to "PCF" (percentage closer filtering).
  9534. */
  9535. usePercentageCloserFiltering: boolean;
  9536. private _filteringQuality;
  9537. /**
  9538. * Gets the PCF or PCSS Quality.
  9539. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9540. */
  9541. /**
  9542. * Sets the PCF or PCSS Quality.
  9543. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9544. */
  9545. filteringQuality: number;
  9546. /**
  9547. * Gets if the current filter is set to "PCSS" (contact hardening).
  9548. */
  9549. /**
  9550. * Sets the current filter to "PCSS" (contact hardening).
  9551. */
  9552. useContactHardeningShadow: boolean;
  9553. private _contactHardeningLightSizeUVRatio;
  9554. /**
  9555. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9556. * Using a ratio helps keeping shape stability independently of the map size.
  9557. *
  9558. * It does not account for the light projection as it was having too much
  9559. * instability during the light setup or during light position changes.
  9560. *
  9561. * Only valid if useContactHardeningShadow is true.
  9562. */
  9563. /**
  9564. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9565. * Using a ratio helps keeping shape stability independently of the map size.
  9566. *
  9567. * It does not account for the light projection as it was having too much
  9568. * instability during the light setup or during light position changes.
  9569. *
  9570. * Only valid if useContactHardeningShadow is true.
  9571. */
  9572. contactHardeningLightSizeUVRatio: number;
  9573. private _darkness;
  9574. /** Gets or sets the actual darkness of a shadow */
  9575. darkness: number;
  9576. /**
  9577. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9578. * 0 means strongest and 1 would means no shadow.
  9579. * @returns the darkness.
  9580. */
  9581. getDarkness(): number;
  9582. /**
  9583. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9584. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9585. * @returns the shadow generator allowing fluent coding.
  9586. */
  9587. setDarkness(darkness: number): ShadowGenerator;
  9588. private _transparencyShadow;
  9589. /** Gets or sets the ability to have transparent shadow */
  9590. transparencyShadow: boolean;
  9591. /**
  9592. * Sets the ability to have transparent shadow (boolean).
  9593. * @param transparent True if transparent else False
  9594. * @returns the shadow generator allowing fluent coding
  9595. */
  9596. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9597. private _shadowMap;
  9598. private _shadowMap2;
  9599. /**
  9600. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9601. * @returns The render target texture if present otherwise, null
  9602. */
  9603. getShadowMap(): Nullable<RenderTargetTexture>;
  9604. /**
  9605. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9606. * @returns The render target texture if the shadow map is present otherwise, null
  9607. */
  9608. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9609. /**
  9610. * Gets the class name of that object
  9611. * @returns "ShadowGenerator"
  9612. */
  9613. getClassName(): string;
  9614. /**
  9615. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9616. * @param mesh Mesh to add
  9617. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9618. * @returns the Shadow Generator itself
  9619. */
  9620. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9621. /**
  9622. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9623. * @param mesh Mesh to remove
  9624. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9625. * @returns the Shadow Generator itself
  9626. */
  9627. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9628. /**
  9629. * Controls the extent to which the shadows fade out at the edge of the frustum
  9630. * Used only by directionals and spots
  9631. */
  9632. frustumEdgeFalloff: number;
  9633. private _light;
  9634. /**
  9635. * Returns the associated light object.
  9636. * @returns the light generating the shadow
  9637. */
  9638. getLight(): IShadowLight;
  9639. /**
  9640. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9641. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9642. * It might on the other hand introduce peter panning.
  9643. */
  9644. forceBackFacesOnly: boolean;
  9645. private _scene;
  9646. private _lightDirection;
  9647. private _effect;
  9648. private _viewMatrix;
  9649. private _projectionMatrix;
  9650. private _transformMatrix;
  9651. private _cachedPosition;
  9652. private _cachedDirection;
  9653. private _cachedDefines;
  9654. private _currentRenderID;
  9655. private _boxBlurPostprocess;
  9656. private _kernelBlurXPostprocess;
  9657. private _kernelBlurYPostprocess;
  9658. private _blurPostProcesses;
  9659. private _mapSize;
  9660. private _currentFaceIndex;
  9661. private _currentFaceIndexCache;
  9662. private _textureType;
  9663. private _defaultTextureMatrix;
  9664. /** @hidden */
  9665. static _SceneComponentInitialization: (scene: Scene) => void;
  9666. /**
  9667. * Creates a ShadowGenerator object.
  9668. * A ShadowGenerator is the required tool to use the shadows.
  9669. * Each light casting shadows needs to use its own ShadowGenerator.
  9670. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9671. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9672. * @param light The light object generating the shadows.
  9673. * @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.
  9674. */
  9675. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9676. private _initializeGenerator;
  9677. private _initializeShadowMap;
  9678. private _initializeBlurRTTAndPostProcesses;
  9679. private _renderForShadowMap;
  9680. private _renderSubMeshForShadowMap;
  9681. private _applyFilterValues;
  9682. /**
  9683. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9684. * @param onCompiled Callback triggered at the and of the effects compilation
  9685. * @param options Sets of optional options forcing the compilation with different modes
  9686. */
  9687. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9688. useInstances: boolean;
  9689. }>): void;
  9690. /**
  9691. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9692. * @param options Sets of optional options forcing the compilation with different modes
  9693. * @returns A promise that resolves when the compilation completes
  9694. */
  9695. forceCompilationAsync(options?: Partial<{
  9696. useInstances: boolean;
  9697. }>): Promise<void>;
  9698. /**
  9699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9700. * @param subMesh The submesh we want to render in the shadow map
  9701. * @param useInstances Defines wether will draw in the map using instances
  9702. * @returns true if ready otherwise, false
  9703. */
  9704. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9705. /**
  9706. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9707. * @param defines Defines of the material we want to update
  9708. * @param lightIndex Index of the light in the enabled light list of the material
  9709. */
  9710. prepareDefines(defines: any, lightIndex: number): void;
  9711. /**
  9712. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9713. * defined in the generator but impacting the effect).
  9714. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9715. * @param effect The effect we are binfing the information for
  9716. */
  9717. bindShadowLight(lightIndex: string, effect: Effect): void;
  9718. /**
  9719. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9720. * (eq to shadow prjection matrix * light transform matrix)
  9721. * @returns The transform matrix used to create the shadow map
  9722. */
  9723. getTransformMatrix(): Matrix;
  9724. /**
  9725. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9726. * Cube and 2D textures for instance.
  9727. */
  9728. recreateShadowMap(): void;
  9729. private _disposeBlurPostProcesses;
  9730. private _disposeRTTandPostProcesses;
  9731. /**
  9732. * Disposes the ShadowGenerator.
  9733. * Returns nothing.
  9734. */
  9735. dispose(): void;
  9736. /**
  9737. * Serializes the shadow generator setup to a json object.
  9738. * @returns The serialized JSON object
  9739. */
  9740. serialize(): any;
  9741. /**
  9742. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9743. * @param parsedShadowGenerator The JSON object to parse
  9744. * @param scene The scene to create the shadow map for
  9745. * @returns The parsed shadow generator
  9746. */
  9747. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9748. }
  9749. }
  9750. declare module "babylonjs/Lights/light" {
  9751. import { Nullable } from "babylonjs/types";
  9752. import { Scene } from "babylonjs/scene";
  9753. import { Vector3 } from "babylonjs/Maths/math.vector";
  9754. import { Color3 } from "babylonjs/Maths/math.color";
  9755. import { Node } from "babylonjs/node";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { Effect } from "babylonjs/Materials/effect";
  9758. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9759. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9760. /**
  9761. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9762. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9763. * 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.
  9764. */
  9765. export abstract class Light extends Node {
  9766. /**
  9767. * Falloff Default: light is falling off following the material specification:
  9768. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9769. */
  9770. static readonly FALLOFF_DEFAULT: number;
  9771. /**
  9772. * Falloff Physical: light is falling off following the inverse squared distance law.
  9773. */
  9774. static readonly FALLOFF_PHYSICAL: number;
  9775. /**
  9776. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9777. * to enhance interoperability with other engines.
  9778. */
  9779. static readonly FALLOFF_GLTF: number;
  9780. /**
  9781. * Falloff Standard: light is falling off like in the standard material
  9782. * to enhance interoperability with other materials.
  9783. */
  9784. static readonly FALLOFF_STANDARD: number;
  9785. /**
  9786. * If every light affecting the material is in this lightmapMode,
  9787. * material.lightmapTexture adds or multiplies
  9788. * (depends on material.useLightmapAsShadowmap)
  9789. * after every other light calculations.
  9790. */
  9791. static readonly LIGHTMAP_DEFAULT: number;
  9792. /**
  9793. * material.lightmapTexture as only diffuse lighting from this light
  9794. * adds only specular lighting from this light
  9795. * adds dynamic shadows
  9796. */
  9797. static readonly LIGHTMAP_SPECULAR: number;
  9798. /**
  9799. * material.lightmapTexture as only lighting
  9800. * no light calculation from this light
  9801. * only adds dynamic shadows from this light
  9802. */
  9803. static readonly LIGHTMAP_SHADOWSONLY: number;
  9804. /**
  9805. * Each light type uses the default quantity according to its type:
  9806. * point/spot lights use luminous intensity
  9807. * directional lights use illuminance
  9808. */
  9809. static readonly INTENSITYMODE_AUTOMATIC: number;
  9810. /**
  9811. * lumen (lm)
  9812. */
  9813. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9814. /**
  9815. * candela (lm/sr)
  9816. */
  9817. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9818. /**
  9819. * lux (lm/m^2)
  9820. */
  9821. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9822. /**
  9823. * nit (cd/m^2)
  9824. */
  9825. static readonly INTENSITYMODE_LUMINANCE: number;
  9826. /**
  9827. * Light type const id of the point light.
  9828. */
  9829. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9830. /**
  9831. * Light type const id of the directional light.
  9832. */
  9833. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9834. /**
  9835. * Light type const id of the spot light.
  9836. */
  9837. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9838. /**
  9839. * Light type const id of the hemispheric light.
  9840. */
  9841. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9842. /**
  9843. * Diffuse gives the basic color to an object.
  9844. */
  9845. diffuse: Color3;
  9846. /**
  9847. * Specular produces a highlight color on an object.
  9848. * Note: This is note affecting PBR materials.
  9849. */
  9850. specular: Color3;
  9851. /**
  9852. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9853. * falling off base on range or angle.
  9854. * This can be set to any values in Light.FALLOFF_x.
  9855. *
  9856. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9857. * other types of materials.
  9858. */
  9859. falloffType: number;
  9860. /**
  9861. * Strength of the light.
  9862. * Note: By default it is define in the framework own unit.
  9863. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9864. */
  9865. intensity: number;
  9866. private _range;
  9867. protected _inverseSquaredRange: number;
  9868. /**
  9869. * Defines how far from the source the light is impacting in scene units.
  9870. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9871. */
  9872. /**
  9873. * Defines how far from the source the light is impacting in scene units.
  9874. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9875. */
  9876. range: number;
  9877. /**
  9878. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9879. * of light.
  9880. */
  9881. private _photometricScale;
  9882. private _intensityMode;
  9883. /**
  9884. * Gets the photometric scale used to interpret the intensity.
  9885. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9886. */
  9887. /**
  9888. * Sets the photometric scale used to interpret the intensity.
  9889. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9890. */
  9891. intensityMode: number;
  9892. private _radius;
  9893. /**
  9894. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9895. */
  9896. /**
  9897. * sets the light radius used by PBR Materials to simulate soft area lights.
  9898. */
  9899. radius: number;
  9900. private _renderPriority;
  9901. /**
  9902. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9903. * exceeding the number allowed of the materials.
  9904. */
  9905. renderPriority: number;
  9906. private _shadowEnabled;
  9907. /**
  9908. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9909. * the current shadow generator.
  9910. */
  9911. /**
  9912. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9913. * the current shadow generator.
  9914. */
  9915. shadowEnabled: boolean;
  9916. private _includedOnlyMeshes;
  9917. /**
  9918. * Gets the only meshes impacted by this light.
  9919. */
  9920. /**
  9921. * Sets the only meshes impacted by this light.
  9922. */
  9923. includedOnlyMeshes: AbstractMesh[];
  9924. private _excludedMeshes;
  9925. /**
  9926. * Gets the meshes not impacted by this light.
  9927. */
  9928. /**
  9929. * Sets the meshes not impacted by this light.
  9930. */
  9931. excludedMeshes: AbstractMesh[];
  9932. private _excludeWithLayerMask;
  9933. /**
  9934. * Gets the layer id use to find what meshes are not impacted by the light.
  9935. * Inactive if 0
  9936. */
  9937. /**
  9938. * Sets the layer id use to find what meshes are not impacted by the light.
  9939. * Inactive if 0
  9940. */
  9941. excludeWithLayerMask: number;
  9942. private _includeOnlyWithLayerMask;
  9943. /**
  9944. * Gets the layer id use to find what meshes are impacted by the light.
  9945. * Inactive if 0
  9946. */
  9947. /**
  9948. * Sets the layer id use to find what meshes are impacted by the light.
  9949. * Inactive if 0
  9950. */
  9951. includeOnlyWithLayerMask: number;
  9952. private _lightmapMode;
  9953. /**
  9954. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9955. */
  9956. /**
  9957. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9958. */
  9959. lightmapMode: number;
  9960. /**
  9961. * Shadow generator associted to the light.
  9962. * @hidden Internal use only.
  9963. */
  9964. _shadowGenerator: Nullable<IShadowGenerator>;
  9965. /**
  9966. * @hidden Internal use only.
  9967. */
  9968. _excludedMeshesIds: string[];
  9969. /**
  9970. * @hidden Internal use only.
  9971. */
  9972. _includedOnlyMeshesIds: string[];
  9973. /**
  9974. * The current light unifom buffer.
  9975. * @hidden Internal use only.
  9976. */
  9977. _uniformBuffer: UniformBuffer;
  9978. /**
  9979. * Creates a Light object in the scene.
  9980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9981. * @param name The firendly name of the light
  9982. * @param scene The scene the light belongs too
  9983. */
  9984. constructor(name: string, scene: Scene);
  9985. protected abstract _buildUniformLayout(): void;
  9986. /**
  9987. * Sets the passed Effect "effect" with the Light information.
  9988. * @param effect The effect to update
  9989. * @param lightIndex The index of the light in the effect to update
  9990. * @returns The light
  9991. */
  9992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9993. /**
  9994. * Returns the string "Light".
  9995. * @returns the class name
  9996. */
  9997. getClassName(): string;
  9998. /** @hidden */
  9999. readonly _isLight: boolean;
  10000. /**
  10001. * Converts the light information to a readable string for debug purpose.
  10002. * @param fullDetails Supports for multiple levels of logging within scene loading
  10003. * @returns the human readable light info
  10004. */
  10005. toString(fullDetails?: boolean): string;
  10006. /** @hidden */
  10007. protected _syncParentEnabledState(): void;
  10008. /**
  10009. * Set the enabled state of this node.
  10010. * @param value - the new enabled state
  10011. */
  10012. setEnabled(value: boolean): void;
  10013. /**
  10014. * Returns the Light associated shadow generator if any.
  10015. * @return the associated shadow generator.
  10016. */
  10017. getShadowGenerator(): Nullable<IShadowGenerator>;
  10018. /**
  10019. * Returns a Vector3, the absolute light position in the World.
  10020. * @returns the world space position of the light
  10021. */
  10022. getAbsolutePosition(): Vector3;
  10023. /**
  10024. * Specifies if the light will affect the passed mesh.
  10025. * @param mesh The mesh to test against the light
  10026. * @return true the mesh is affected otherwise, false.
  10027. */
  10028. canAffectMesh(mesh: AbstractMesh): boolean;
  10029. /**
  10030. * Sort function to order lights for rendering.
  10031. * @param a First Light object to compare to second.
  10032. * @param b Second Light object to compare first.
  10033. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10034. */
  10035. static CompareLightsPriority(a: Light, b: Light): number;
  10036. /**
  10037. * Releases resources associated with this node.
  10038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10040. */
  10041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10042. /**
  10043. * Returns the light type ID (integer).
  10044. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10045. */
  10046. getTypeID(): number;
  10047. /**
  10048. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10049. * @returns the scaled intensity in intensity mode unit
  10050. */
  10051. getScaledIntensity(): number;
  10052. /**
  10053. * Returns a new Light object, named "name", from the current one.
  10054. * @param name The name of the cloned light
  10055. * @returns the new created light
  10056. */
  10057. clone(name: string): Nullable<Light>;
  10058. /**
  10059. * Serializes the current light into a Serialization object.
  10060. * @returns the serialized object.
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10065. * This new light is named "name" and added to the passed scene.
  10066. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10067. * @param name The friendly name of the light
  10068. * @param scene The scene the new light will belong to
  10069. * @returns the constructor function
  10070. */
  10071. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10072. /**
  10073. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10074. * @param parsedLight The JSON representation of the light
  10075. * @param scene The scene to create the parsed light in
  10076. * @returns the created light after parsing
  10077. */
  10078. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10079. private _hookArrayForExcluded;
  10080. private _hookArrayForIncludedOnly;
  10081. private _resyncMeshes;
  10082. /**
  10083. * Forces the meshes to update their light related information in their rendering used effects
  10084. * @hidden Internal Use Only
  10085. */
  10086. _markMeshesAsLightDirty(): void;
  10087. /**
  10088. * Recomputes the cached photometric scale if needed.
  10089. */
  10090. private _computePhotometricScale;
  10091. /**
  10092. * Returns the Photometric Scale according to the light type and intensity mode.
  10093. */
  10094. private _getPhotometricScale;
  10095. /**
  10096. * Reorder the light in the scene according to their defined priority.
  10097. * @hidden Internal Use Only
  10098. */
  10099. _reorderLightsInScene(): void;
  10100. /**
  10101. * Prepares the list of defines specific to the light type.
  10102. * @param defines the list of defines
  10103. * @param lightIndex defines the index of the light for the effect
  10104. */
  10105. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10106. }
  10107. }
  10108. declare module "babylonjs/Actions/action" {
  10109. import { Observable } from "babylonjs/Misc/observable";
  10110. import { Condition } from "babylonjs/Actions/condition";
  10111. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10112. import { ActionManager } from "babylonjs/Actions/actionManager";
  10113. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10114. /**
  10115. * Interface used to define Action
  10116. */
  10117. export interface IAction {
  10118. /**
  10119. * Trigger for the action
  10120. */
  10121. trigger: number;
  10122. /** Options of the trigger */
  10123. triggerOptions: any;
  10124. /**
  10125. * Gets the trigger parameters
  10126. * @returns the trigger parameters
  10127. */
  10128. getTriggerParameter(): any;
  10129. /**
  10130. * Internal only - executes current action event
  10131. * @hidden
  10132. */
  10133. _executeCurrent(evt?: ActionEvent): void;
  10134. /**
  10135. * Serialize placeholder for child classes
  10136. * @param parent of child
  10137. * @returns the serialized object
  10138. */
  10139. serialize(parent: any): any;
  10140. /**
  10141. * Internal only
  10142. * @hidden
  10143. */
  10144. _prepare(): void;
  10145. /**
  10146. * Internal only - manager for action
  10147. * @hidden
  10148. */
  10149. _actionManager: AbstractActionManager;
  10150. /**
  10151. * Adds action to chain of actions, may be a DoNothingAction
  10152. * @param action defines the next action to execute
  10153. * @returns The action passed in
  10154. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10155. */
  10156. then(action: IAction): IAction;
  10157. }
  10158. /**
  10159. * The action to be carried out following a trigger
  10160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10161. */
  10162. export class Action implements IAction {
  10163. /** the trigger, with or without parameters, for the action */
  10164. triggerOptions: any;
  10165. /**
  10166. * Trigger for the action
  10167. */
  10168. trigger: number;
  10169. /**
  10170. * Internal only - manager for action
  10171. * @hidden
  10172. */
  10173. _actionManager: ActionManager;
  10174. private _nextActiveAction;
  10175. private _child;
  10176. private _condition?;
  10177. private _triggerParameter;
  10178. /**
  10179. * An event triggered prior to action being executed.
  10180. */
  10181. onBeforeExecuteObservable: Observable<Action>;
  10182. /**
  10183. * Creates a new Action
  10184. * @param triggerOptions the trigger, with or without parameters, for the action
  10185. * @param condition an optional determinant of action
  10186. */
  10187. constructor(
  10188. /** the trigger, with or without parameters, for the action */
  10189. triggerOptions: any, condition?: Condition);
  10190. /**
  10191. * Internal only
  10192. * @hidden
  10193. */
  10194. _prepare(): void;
  10195. /**
  10196. * Gets the trigger parameters
  10197. * @returns the trigger parameters
  10198. */
  10199. getTriggerParameter(): any;
  10200. /**
  10201. * Internal only - executes current action event
  10202. * @hidden
  10203. */
  10204. _executeCurrent(evt?: ActionEvent): void;
  10205. /**
  10206. * Execute placeholder for child classes
  10207. * @param evt optional action event
  10208. */
  10209. execute(evt?: ActionEvent): void;
  10210. /**
  10211. * Skips to next active action
  10212. */
  10213. skipToNextActiveAction(): void;
  10214. /**
  10215. * Adds action to chain of actions, may be a DoNothingAction
  10216. * @param action defines the next action to execute
  10217. * @returns The action passed in
  10218. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10219. */
  10220. then(action: Action): Action;
  10221. /**
  10222. * Internal only
  10223. * @hidden
  10224. */
  10225. _getProperty(propertyPath: string): string;
  10226. /**
  10227. * Internal only
  10228. * @hidden
  10229. */
  10230. _getEffectiveTarget(target: any, propertyPath: string): any;
  10231. /**
  10232. * Serialize placeholder for child classes
  10233. * @param parent of child
  10234. * @returns the serialized object
  10235. */
  10236. serialize(parent: any): any;
  10237. /**
  10238. * Internal only called by serialize
  10239. * @hidden
  10240. */
  10241. protected _serialize(serializedAction: any, parent?: any): any;
  10242. /**
  10243. * Internal only
  10244. * @hidden
  10245. */
  10246. static _SerializeValueAsString: (value: any) => string;
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10252. name: string;
  10253. targetType: string;
  10254. value: string;
  10255. };
  10256. }
  10257. }
  10258. declare module "babylonjs/Actions/condition" {
  10259. import { ActionManager } from "babylonjs/Actions/actionManager";
  10260. /**
  10261. * A Condition applied to an Action
  10262. */
  10263. export class Condition {
  10264. /**
  10265. * Internal only - manager for action
  10266. * @hidden
  10267. */
  10268. _actionManager: ActionManager;
  10269. /**
  10270. * Internal only
  10271. * @hidden
  10272. */
  10273. _evaluationId: number;
  10274. /**
  10275. * Internal only
  10276. * @hidden
  10277. */
  10278. _currentResult: boolean;
  10279. /**
  10280. * Creates a new Condition
  10281. * @param actionManager the manager of the action the condition is applied to
  10282. */
  10283. constructor(actionManager: ActionManager);
  10284. /**
  10285. * Check if the current condition is valid
  10286. * @returns a boolean
  10287. */
  10288. isValid(): boolean;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getProperty(propertyPath: string): string;
  10294. /**
  10295. * Internal only
  10296. * @hidden
  10297. */
  10298. _getEffectiveTarget(target: any, propertyPath: string): any;
  10299. /**
  10300. * Serialize placeholder for child classes
  10301. * @returns the serialized object
  10302. */
  10303. serialize(): any;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. protected _serialize(serializedCondition: any): any;
  10309. }
  10310. /**
  10311. * Defines specific conditional operators as extensions of Condition
  10312. */
  10313. export class ValueCondition extends Condition {
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string;
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any;
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator: number;
  10320. /**
  10321. * Internal only
  10322. * @hidden
  10323. */
  10324. private static _IsEqual;
  10325. /**
  10326. * Internal only
  10327. * @hidden
  10328. */
  10329. private static _IsDifferent;
  10330. /**
  10331. * Internal only
  10332. * @hidden
  10333. */
  10334. private static _IsGreater;
  10335. /**
  10336. * Internal only
  10337. * @hidden
  10338. */
  10339. private static _IsLesser;
  10340. /**
  10341. * returns the number for IsEqual
  10342. */
  10343. static readonly IsEqual: number;
  10344. /**
  10345. * Returns the number for IsDifferent
  10346. */
  10347. static readonly IsDifferent: number;
  10348. /**
  10349. * Returns the number for IsGreater
  10350. */
  10351. static readonly IsGreater: number;
  10352. /**
  10353. * Returns the number for IsLesser
  10354. */
  10355. static readonly IsLesser: number;
  10356. /**
  10357. * Internal only The action manager for the condition
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. private _target;
  10366. /**
  10367. * Internal only
  10368. * @hidden
  10369. */
  10370. private _effectiveTarget;
  10371. /**
  10372. * Internal only
  10373. * @hidden
  10374. */
  10375. private _property;
  10376. /**
  10377. * Creates a new ValueCondition
  10378. * @param actionManager manager for the action the condition applies to
  10379. * @param target for the action
  10380. * @param propertyPath path to specify the property of the target the conditional operator uses
  10381. * @param value the value compared by the conditional operator against the current value of the property
  10382. * @param operator the conditional operator, default ValueCondition.IsEqual
  10383. */
  10384. constructor(actionManager: ActionManager, target: any,
  10385. /** path to specify the property of the target the conditional operator uses */
  10386. propertyPath: string,
  10387. /** the value compared by the conditional operator against the current value of the property */
  10388. value: any,
  10389. /** the conditional operator, default ValueCondition.IsEqual */
  10390. operator?: number);
  10391. /**
  10392. * Compares the given value with the property value for the specified conditional operator
  10393. * @returns the result of the comparison
  10394. */
  10395. isValid(): boolean;
  10396. /**
  10397. * Serialize the ValueCondition into a JSON compatible object
  10398. * @returns serialization object
  10399. */
  10400. serialize(): any;
  10401. /**
  10402. * Gets the name of the conditional operator for the ValueCondition
  10403. * @param operator the conditional operator
  10404. * @returns the name
  10405. */
  10406. static GetOperatorName(operator: number): string;
  10407. }
  10408. /**
  10409. * Defines a predicate condition as an extension of Condition
  10410. */
  10411. export class PredicateCondition extends Condition {
  10412. /** defines the predicate function used to validate the condition */
  10413. predicate: () => boolean;
  10414. /**
  10415. * Internal only - manager for action
  10416. * @hidden
  10417. */
  10418. _actionManager: ActionManager;
  10419. /**
  10420. * Creates a new PredicateCondition
  10421. * @param actionManager manager for the action the condition applies to
  10422. * @param predicate defines the predicate function used to validate the condition
  10423. */
  10424. constructor(actionManager: ActionManager,
  10425. /** defines the predicate function used to validate the condition */
  10426. predicate: () => boolean);
  10427. /**
  10428. * @returns the validity of the predicate condition
  10429. */
  10430. isValid(): boolean;
  10431. }
  10432. /**
  10433. * Defines a state condition as an extension of Condition
  10434. */
  10435. export class StateCondition extends Condition {
  10436. /** Value to compare with target state */
  10437. value: string;
  10438. /**
  10439. * Internal only - manager for action
  10440. * @hidden
  10441. */
  10442. _actionManager: ActionManager;
  10443. /**
  10444. * Internal only
  10445. * @hidden
  10446. */
  10447. private _target;
  10448. /**
  10449. * Creates a new StateCondition
  10450. * @param actionManager manager for the action the condition applies to
  10451. * @param target of the condition
  10452. * @param value to compare with target state
  10453. */
  10454. constructor(actionManager: ActionManager, target: any,
  10455. /** Value to compare with target state */
  10456. value: string);
  10457. /**
  10458. * Gets a boolean indicating if the current condition is met
  10459. * @returns the validity of the state
  10460. */
  10461. isValid(): boolean;
  10462. /**
  10463. * Serialize the StateCondition into a JSON compatible object
  10464. * @returns serialization object
  10465. */
  10466. serialize(): any;
  10467. }
  10468. }
  10469. declare module "babylonjs/Actions/directActions" {
  10470. import { Action } from "babylonjs/Actions/action";
  10471. import { Condition } from "babylonjs/Actions/condition";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * This defines an action responsible to toggle a boolean once triggered.
  10475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10476. */
  10477. export class SwitchBooleanAction extends Action {
  10478. /**
  10479. * The path to the boolean property in the target object
  10480. */
  10481. propertyPath: string;
  10482. private _target;
  10483. private _effectiveTarget;
  10484. private _property;
  10485. /**
  10486. * Instantiate the action
  10487. * @param triggerOptions defines the trigger options
  10488. * @param target defines the object containing the boolean
  10489. * @param propertyPath defines the path to the boolean property in the target object
  10490. * @param condition defines the trigger related conditions
  10491. */
  10492. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10493. /** @hidden */
  10494. _prepare(): void;
  10495. /**
  10496. * Execute the action toggle the boolean value.
  10497. */
  10498. execute(): void;
  10499. /**
  10500. * Serializes the actions and its related information.
  10501. * @param parent defines the object to serialize in
  10502. * @returns the serialized object
  10503. */
  10504. serialize(parent: any): any;
  10505. }
  10506. /**
  10507. * This defines an action responsible to set a the state field of the target
  10508. * to a desired value once triggered.
  10509. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10510. */
  10511. export class SetStateAction extends Action {
  10512. /**
  10513. * The value to store in the state field.
  10514. */
  10515. value: string;
  10516. private _target;
  10517. /**
  10518. * Instantiate the action
  10519. * @param triggerOptions defines the trigger options
  10520. * @param target defines the object containing the state property
  10521. * @param value defines the value to store in the state field
  10522. * @param condition defines the trigger related conditions
  10523. */
  10524. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10525. /**
  10526. * Execute the action and store the value on the target state property.
  10527. */
  10528. execute(): void;
  10529. /**
  10530. * Serializes the actions and its related information.
  10531. * @param parent defines the object to serialize in
  10532. * @returns the serialized object
  10533. */
  10534. serialize(parent: any): any;
  10535. }
  10536. /**
  10537. * This defines an action responsible to set a property of the target
  10538. * to a desired value once triggered.
  10539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10540. */
  10541. export class SetValueAction extends Action {
  10542. /**
  10543. * The path of the property to set in the target.
  10544. */
  10545. propertyPath: string;
  10546. /**
  10547. * The value to set in the property
  10548. */
  10549. value: any;
  10550. private _target;
  10551. private _effectiveTarget;
  10552. private _property;
  10553. /**
  10554. * Instantiate the action
  10555. * @param triggerOptions defines the trigger options
  10556. * @param target defines the object containing the property
  10557. * @param propertyPath defines the path of the property to set in the target
  10558. * @param value defines the value to set in the property
  10559. * @param condition defines the trigger related conditions
  10560. */
  10561. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10562. /** @hidden */
  10563. _prepare(): void;
  10564. /**
  10565. * Execute the action and set the targetted property to the desired value.
  10566. */
  10567. execute(): void;
  10568. /**
  10569. * Serializes the actions and its related information.
  10570. * @param parent defines the object to serialize in
  10571. * @returns the serialized object
  10572. */
  10573. serialize(parent: any): any;
  10574. }
  10575. /**
  10576. * This defines an action responsible to increment the target value
  10577. * to a desired value once triggered.
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10579. */
  10580. export class IncrementValueAction extends Action {
  10581. /**
  10582. * The path of the property to increment in the target.
  10583. */
  10584. propertyPath: string;
  10585. /**
  10586. * The value we should increment the property by.
  10587. */
  10588. value: any;
  10589. private _target;
  10590. private _effectiveTarget;
  10591. private _property;
  10592. /**
  10593. * Instantiate the action
  10594. * @param triggerOptions defines the trigger options
  10595. * @param target defines the object containing the property
  10596. * @param propertyPath defines the path of the property to increment in the target
  10597. * @param value defines the value value we should increment the property by
  10598. * @param condition defines the trigger related conditions
  10599. */
  10600. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10601. /** @hidden */
  10602. _prepare(): void;
  10603. /**
  10604. * Execute the action and increment the target of the value amount.
  10605. */
  10606. execute(): void;
  10607. /**
  10608. * Serializes the actions and its related information.
  10609. * @param parent defines the object to serialize in
  10610. * @returns the serialized object
  10611. */
  10612. serialize(parent: any): any;
  10613. }
  10614. /**
  10615. * This defines an action responsible to start an animation once triggered.
  10616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class PlayAnimationAction extends Action {
  10619. /**
  10620. * Where the animation should start (animation frame)
  10621. */
  10622. from: number;
  10623. /**
  10624. * Where the animation should stop (animation frame)
  10625. */
  10626. to: number;
  10627. /**
  10628. * Define if the animation should loop or stop after the first play.
  10629. */
  10630. loop?: boolean;
  10631. private _target;
  10632. /**
  10633. * Instantiate the action
  10634. * @param triggerOptions defines the trigger options
  10635. * @param target defines the target animation or animation name
  10636. * @param from defines from where the animation should start (animation frame)
  10637. * @param end defines where the animation should stop (animation frame)
  10638. * @param loop defines if the animation should loop or stop after the first play
  10639. * @param condition defines the trigger related conditions
  10640. */
  10641. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10642. /** @hidden */
  10643. _prepare(): void;
  10644. /**
  10645. * Execute the action and play the animation.
  10646. */
  10647. execute(): void;
  10648. /**
  10649. * Serializes the actions and its related information.
  10650. * @param parent defines the object to serialize in
  10651. * @returns the serialized object
  10652. */
  10653. serialize(parent: any): any;
  10654. }
  10655. /**
  10656. * This defines an action responsible to stop an animation once triggered.
  10657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10658. */
  10659. export class StopAnimationAction extends Action {
  10660. private _target;
  10661. /**
  10662. * Instantiate the action
  10663. * @param triggerOptions defines the trigger options
  10664. * @param target defines the target animation or animation name
  10665. * @param condition defines the trigger related conditions
  10666. */
  10667. constructor(triggerOptions: any, target: any, condition?: Condition);
  10668. /** @hidden */
  10669. _prepare(): void;
  10670. /**
  10671. * Execute the action and stop the animation.
  10672. */
  10673. execute(): void;
  10674. /**
  10675. * Serializes the actions and its related information.
  10676. * @param parent defines the object to serialize in
  10677. * @returns the serialized object
  10678. */
  10679. serialize(parent: any): any;
  10680. }
  10681. /**
  10682. * This defines an action responsible that does nothing once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class DoNothingAction extends Action {
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param condition defines the trigger related conditions
  10690. */
  10691. constructor(triggerOptions?: any, condition?: Condition);
  10692. /**
  10693. * Execute the action and do nothing.
  10694. */
  10695. execute(): void;
  10696. /**
  10697. * Serializes the actions and its related information.
  10698. * @param parent defines the object to serialize in
  10699. * @returns the serialized object
  10700. */
  10701. serialize(parent: any): any;
  10702. }
  10703. /**
  10704. * This defines an action responsible to trigger several actions once triggered.
  10705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10706. */
  10707. export class CombineAction extends Action {
  10708. /**
  10709. * The list of aggregated animations to run.
  10710. */
  10711. children: Action[];
  10712. /**
  10713. * Instantiate the action
  10714. * @param triggerOptions defines the trigger options
  10715. * @param children defines the list of aggregated animations to run
  10716. * @param condition defines the trigger related conditions
  10717. */
  10718. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10719. /** @hidden */
  10720. _prepare(): void;
  10721. /**
  10722. * Execute the action and executes all the aggregated actions.
  10723. */
  10724. execute(evt: ActionEvent): void;
  10725. /**
  10726. * Serializes the actions and its related information.
  10727. * @param parent defines the object to serialize in
  10728. * @returns the serialized object
  10729. */
  10730. serialize(parent: any): any;
  10731. }
  10732. /**
  10733. * This defines an action responsible to run code (external event) once triggered.
  10734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10735. */
  10736. export class ExecuteCodeAction extends Action {
  10737. /**
  10738. * The callback function to run.
  10739. */
  10740. func: (evt: ActionEvent) => void;
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param func defines the callback function to run
  10745. * @param condition defines the trigger related conditions
  10746. */
  10747. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10748. /**
  10749. * Execute the action and run the attached code.
  10750. */
  10751. execute(evt: ActionEvent): void;
  10752. }
  10753. /**
  10754. * This defines an action responsible to set the parent property of the target once triggered.
  10755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10756. */
  10757. export class SetParentAction extends Action {
  10758. private _parent;
  10759. private _target;
  10760. /**
  10761. * Instantiate the action
  10762. * @param triggerOptions defines the trigger options
  10763. * @param target defines the target containing the parent property
  10764. * @param parent defines from where the animation should start (animation frame)
  10765. * @param condition defines the trigger related conditions
  10766. */
  10767. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10768. /** @hidden */
  10769. _prepare(): void;
  10770. /**
  10771. * Execute the action and set the parent property.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. }
  10782. declare module "babylonjs/Actions/actionManager" {
  10783. import { Nullable } from "babylonjs/types";
  10784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10785. import { Scene } from "babylonjs/scene";
  10786. import { IAction } from "babylonjs/Actions/action";
  10787. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10789. /**
  10790. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10791. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10793. */
  10794. export class ActionManager extends AbstractActionManager {
  10795. /**
  10796. * Nothing
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10798. */
  10799. static readonly NothingTrigger: number;
  10800. /**
  10801. * On pick
  10802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10803. */
  10804. static readonly OnPickTrigger: number;
  10805. /**
  10806. * On left pick
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10808. */
  10809. static readonly OnLeftPickTrigger: number;
  10810. /**
  10811. * On right pick
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10813. */
  10814. static readonly OnRightPickTrigger: number;
  10815. /**
  10816. * On center pick
  10817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10818. */
  10819. static readonly OnCenterPickTrigger: number;
  10820. /**
  10821. * On pick down
  10822. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10823. */
  10824. static readonly OnPickDownTrigger: number;
  10825. /**
  10826. * On double pick
  10827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10828. */
  10829. static readonly OnDoublePickTrigger: number;
  10830. /**
  10831. * On pick up
  10832. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10833. */
  10834. static readonly OnPickUpTrigger: number;
  10835. /**
  10836. * On pick out.
  10837. * This trigger will only be raised if you also declared a OnPickDown
  10838. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10839. */
  10840. static readonly OnPickOutTrigger: number;
  10841. /**
  10842. * On long press
  10843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10844. */
  10845. static readonly OnLongPressTrigger: number;
  10846. /**
  10847. * On pointer over
  10848. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10849. */
  10850. static readonly OnPointerOverTrigger: number;
  10851. /**
  10852. * On pointer out
  10853. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10854. */
  10855. static readonly OnPointerOutTrigger: number;
  10856. /**
  10857. * On every frame
  10858. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10859. */
  10860. static readonly OnEveryFrameTrigger: number;
  10861. /**
  10862. * On intersection enter
  10863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10864. */
  10865. static readonly OnIntersectionEnterTrigger: number;
  10866. /**
  10867. * On intersection exit
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10869. */
  10870. static readonly OnIntersectionExitTrigger: number;
  10871. /**
  10872. * On key down
  10873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10874. */
  10875. static readonly OnKeyDownTrigger: number;
  10876. /**
  10877. * On key up
  10878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10879. */
  10880. static readonly OnKeyUpTrigger: number;
  10881. private _scene;
  10882. /**
  10883. * Creates a new action manager
  10884. * @param scene defines the hosting scene
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Releases all associated resources
  10889. */
  10890. dispose(): void;
  10891. /**
  10892. * Gets hosting scene
  10893. * @returns the hosting scene
  10894. */
  10895. getScene(): Scene;
  10896. /**
  10897. * Does this action manager handles actions of any of the given triggers
  10898. * @param triggers defines the triggers to be tested
  10899. * @return a boolean indicating whether one (or more) of the triggers is handled
  10900. */
  10901. hasSpecificTriggers(triggers: number[]): boolean;
  10902. /**
  10903. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10904. * speed.
  10905. * @param triggerA defines the trigger to be tested
  10906. * @param triggerB defines the trigger to be tested
  10907. * @return a boolean indicating whether one (or more) of the triggers is handled
  10908. */
  10909. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10910. /**
  10911. * Does this action manager handles actions of a given trigger
  10912. * @param trigger defines the trigger to be tested
  10913. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10914. * @return whether the trigger is handled
  10915. */
  10916. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10917. /**
  10918. * Does this action manager has pointer triggers
  10919. */
  10920. readonly hasPointerTriggers: boolean;
  10921. /**
  10922. * Does this action manager has pick triggers
  10923. */
  10924. readonly hasPickTriggers: boolean;
  10925. /**
  10926. * Registers an action to this action manager
  10927. * @param action defines the action to be registered
  10928. * @return the action amended (prepared) after registration
  10929. */
  10930. registerAction(action: IAction): Nullable<IAction>;
  10931. /**
  10932. * Unregisters an action to this action manager
  10933. * @param action defines the action to be unregistered
  10934. * @return a boolean indicating whether the action has been unregistered
  10935. */
  10936. unregisterAction(action: IAction): Boolean;
  10937. /**
  10938. * Process a specific trigger
  10939. * @param trigger defines the trigger to process
  10940. * @param evt defines the event details to be processed
  10941. */
  10942. processTrigger(trigger: number, evt?: IActionEvent): void;
  10943. /** @hidden */
  10944. _getEffectiveTarget(target: any, propertyPath: string): any;
  10945. /** @hidden */
  10946. _getProperty(propertyPath: string): string;
  10947. /**
  10948. * Serialize this manager to a JSON object
  10949. * @param name defines the property name to store this manager
  10950. * @returns a JSON representation of this manager
  10951. */
  10952. serialize(name: string): any;
  10953. /**
  10954. * Creates a new ActionManager from a JSON data
  10955. * @param parsedActions defines the JSON data to read from
  10956. * @param object defines the hosting mesh
  10957. * @param scene defines the hosting scene
  10958. */
  10959. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10960. /**
  10961. * Get a trigger name by index
  10962. * @param trigger defines the trigger index
  10963. * @returns a trigger name
  10964. */
  10965. static GetTriggerName(trigger: number): string;
  10966. }
  10967. }
  10968. declare module "babylonjs/Culling/ray" {
  10969. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10970. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10973. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10974. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10975. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10976. import { Plane } from "babylonjs/Maths/math.plane";
  10977. /**
  10978. * Class representing a ray with position and direction
  10979. */
  10980. export class Ray {
  10981. /** origin point */
  10982. origin: Vector3;
  10983. /** direction */
  10984. direction: Vector3;
  10985. /** length of the ray */
  10986. length: number;
  10987. private static readonly TmpVector3;
  10988. private _tmpRay;
  10989. /**
  10990. * Creates a new ray
  10991. * @param origin origin point
  10992. * @param direction direction
  10993. * @param length length of the ray
  10994. */
  10995. constructor(
  10996. /** origin point */
  10997. origin: Vector3,
  10998. /** direction */
  10999. direction: Vector3,
  11000. /** length of the ray */
  11001. length?: number);
  11002. /**
  11003. * Checks if the ray intersects a box
  11004. * @param minimum bound of the box
  11005. * @param maximum bound of the box
  11006. * @param intersectionTreshold extra extend to be added to the box in all direction
  11007. * @returns if the box was hit
  11008. */
  11009. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11010. /**
  11011. * Checks if the ray intersects a box
  11012. * @param box the bounding box to check
  11013. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11014. * @returns if the box was hit
  11015. */
  11016. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11017. /**
  11018. * If the ray hits a sphere
  11019. * @param sphere the bounding sphere to check
  11020. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11021. * @returns true if it hits the sphere
  11022. */
  11023. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11024. /**
  11025. * If the ray hits a triange
  11026. * @param vertex0 triangle vertex
  11027. * @param vertex1 triangle vertex
  11028. * @param vertex2 triangle vertex
  11029. * @returns intersection information if hit
  11030. */
  11031. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11032. /**
  11033. * Checks if ray intersects a plane
  11034. * @param plane the plane to check
  11035. * @returns the distance away it was hit
  11036. */
  11037. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11038. /**
  11039. * Calculate the intercept of a ray on a given axis
  11040. * @param axis to check 'x' | 'y' | 'z'
  11041. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11042. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11043. */
  11044. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11045. /**
  11046. * Checks if ray intersects a mesh
  11047. * @param mesh the mesh to check
  11048. * @param fastCheck if only the bounding box should checked
  11049. * @returns picking info of the intersecton
  11050. */
  11051. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11052. /**
  11053. * Checks if ray intersects a mesh
  11054. * @param meshes the meshes to check
  11055. * @param fastCheck if only the bounding box should checked
  11056. * @param results array to store result in
  11057. * @returns Array of picking infos
  11058. */
  11059. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11060. private _comparePickingInfo;
  11061. private static smallnum;
  11062. private static rayl;
  11063. /**
  11064. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11065. * @param sega the first point of the segment to test the intersection against
  11066. * @param segb the second point of the segment to test the intersection against
  11067. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11068. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11069. */
  11070. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11071. /**
  11072. * Update the ray from viewport position
  11073. * @param x position
  11074. * @param y y position
  11075. * @param viewportWidth viewport width
  11076. * @param viewportHeight viewport height
  11077. * @param world world matrix
  11078. * @param view view matrix
  11079. * @param projection projection matrix
  11080. * @returns this ray updated
  11081. */
  11082. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11083. /**
  11084. * Creates a ray with origin and direction of 0,0,0
  11085. * @returns the new ray
  11086. */
  11087. static Zero(): Ray;
  11088. /**
  11089. * Creates a new ray from screen space and viewport
  11090. * @param x position
  11091. * @param y y position
  11092. * @param viewportWidth viewport width
  11093. * @param viewportHeight viewport height
  11094. * @param world world matrix
  11095. * @param view view matrix
  11096. * @param projection projection matrix
  11097. * @returns new ray
  11098. */
  11099. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11100. /**
  11101. * 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
  11102. * transformed to the given world matrix.
  11103. * @param origin The origin point
  11104. * @param end The end point
  11105. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11106. * @returns the new ray
  11107. */
  11108. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11109. /**
  11110. * Transforms a ray by a matrix
  11111. * @param ray ray to transform
  11112. * @param matrix matrix to apply
  11113. * @returns the resulting new ray
  11114. */
  11115. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11116. /**
  11117. * Transforms a ray by a matrix
  11118. * @param ray ray to transform
  11119. * @param matrix matrix to apply
  11120. * @param result ray to store result in
  11121. */
  11122. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11123. /**
  11124. * Unproject a ray from screen space to object space
  11125. * @param sourceX defines the screen space x coordinate to use
  11126. * @param sourceY defines the screen space y coordinate to use
  11127. * @param viewportWidth defines the current width of the viewport
  11128. * @param viewportHeight defines the current height of the viewport
  11129. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11130. * @param view defines the view matrix to use
  11131. * @param projection defines the projection matrix to use
  11132. */
  11133. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11134. }
  11135. /**
  11136. * Type used to define predicate used to select faces when a mesh intersection is detected
  11137. */
  11138. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11139. module "babylonjs/scene" {
  11140. interface Scene {
  11141. /** @hidden */
  11142. _tempPickingRay: Nullable<Ray>;
  11143. /** @hidden */
  11144. _cachedRayForTransform: Ray;
  11145. /** @hidden */
  11146. _pickWithRayInverseMatrix: Matrix;
  11147. /** @hidden */
  11148. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11149. /** @hidden */
  11150. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11151. }
  11152. }
  11153. }
  11154. declare module "babylonjs/sceneComponent" {
  11155. import { Scene } from "babylonjs/scene";
  11156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11157. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11158. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11159. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11160. import { Nullable } from "babylonjs/types";
  11161. import { Camera } from "babylonjs/Cameras/camera";
  11162. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11163. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11164. import { AbstractScene } from "babylonjs/abstractScene";
  11165. /**
  11166. * Groups all the scene component constants in one place to ease maintenance.
  11167. * @hidden
  11168. */
  11169. export class SceneComponentConstants {
  11170. static readonly NAME_EFFECTLAYER: string;
  11171. static readonly NAME_LAYER: string;
  11172. static readonly NAME_LENSFLARESYSTEM: string;
  11173. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11174. static readonly NAME_PARTICLESYSTEM: string;
  11175. static readonly NAME_GAMEPAD: string;
  11176. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11177. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11178. static readonly NAME_DEPTHRENDERER: string;
  11179. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11180. static readonly NAME_SPRITE: string;
  11181. static readonly NAME_OUTLINERENDERER: string;
  11182. static readonly NAME_PROCEDURALTEXTURE: string;
  11183. static readonly NAME_SHADOWGENERATOR: string;
  11184. static readonly NAME_OCTREE: string;
  11185. static readonly NAME_PHYSICSENGINE: string;
  11186. static readonly NAME_AUDIO: string;
  11187. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11188. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11189. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11190. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11191. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11192. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11193. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11194. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11195. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11196. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11197. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11198. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11199. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11200. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11201. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11202. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11203. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11204. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11205. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11206. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11207. static readonly STEP_AFTERRENDER_AUDIO: number;
  11208. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11209. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11210. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11211. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11212. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11213. static readonly STEP_POINTERMOVE_SPRITE: number;
  11214. static readonly STEP_POINTERDOWN_SPRITE: number;
  11215. static readonly STEP_POINTERUP_SPRITE: number;
  11216. }
  11217. /**
  11218. * This represents a scene component.
  11219. *
  11220. * This is used to decouple the dependency the scene is having on the different workloads like
  11221. * layers, post processes...
  11222. */
  11223. export interface ISceneComponent {
  11224. /**
  11225. * The name of the component. Each component must have a unique name.
  11226. */
  11227. name: string;
  11228. /**
  11229. * The scene the component belongs to.
  11230. */
  11231. scene: Scene;
  11232. /**
  11233. * Register the component to one instance of a scene.
  11234. */
  11235. register(): void;
  11236. /**
  11237. * Rebuilds the elements related to this component in case of
  11238. * context lost for instance.
  11239. */
  11240. rebuild(): void;
  11241. /**
  11242. * Disposes the component and the associated ressources.
  11243. */
  11244. dispose(): void;
  11245. }
  11246. /**
  11247. * This represents a SERIALIZABLE scene component.
  11248. *
  11249. * This extends Scene Component to add Serialization methods on top.
  11250. */
  11251. export interface ISceneSerializableComponent extends ISceneComponent {
  11252. /**
  11253. * Adds all the elements from the container to the scene
  11254. * @param container the container holding the elements
  11255. */
  11256. addFromContainer(container: AbstractScene): void;
  11257. /**
  11258. * Removes all the elements in the container from the scene
  11259. * @param container contains the elements to remove
  11260. * @param dispose if the removed element should be disposed (default: false)
  11261. */
  11262. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11263. /**
  11264. * Serializes the component data to the specified json object
  11265. * @param serializationObject The object to serialize to
  11266. */
  11267. serialize(serializationObject: any): void;
  11268. }
  11269. /**
  11270. * Strong typing of a Mesh related stage step action
  11271. */
  11272. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11273. /**
  11274. * Strong typing of a Evaluate Sub Mesh related stage step action
  11275. */
  11276. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11277. /**
  11278. * Strong typing of a Active Mesh related stage step action
  11279. */
  11280. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11281. /**
  11282. * Strong typing of a Camera related stage step action
  11283. */
  11284. export type CameraStageAction = (camera: Camera) => void;
  11285. /**
  11286. * Strong typing of a Camera Frame buffer related stage step action
  11287. */
  11288. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11289. /**
  11290. * Strong typing of a Render Target related stage step action
  11291. */
  11292. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11293. /**
  11294. * Strong typing of a RenderingGroup related stage step action
  11295. */
  11296. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11297. /**
  11298. * Strong typing of a Mesh Render related stage step action
  11299. */
  11300. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11301. /**
  11302. * Strong typing of a simple stage step action
  11303. */
  11304. export type SimpleStageAction = () => void;
  11305. /**
  11306. * Strong typing of a render target action.
  11307. */
  11308. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11309. /**
  11310. * Strong typing of a pointer move action.
  11311. */
  11312. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11313. /**
  11314. * Strong typing of a pointer up/down action.
  11315. */
  11316. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11317. /**
  11318. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11319. * @hidden
  11320. */
  11321. export class Stage<T extends Function> extends Array<{
  11322. index: number;
  11323. component: ISceneComponent;
  11324. action: T;
  11325. }> {
  11326. /**
  11327. * Hide ctor from the rest of the world.
  11328. * @param items The items to add.
  11329. */
  11330. private constructor();
  11331. /**
  11332. * Creates a new Stage.
  11333. * @returns A new instance of a Stage
  11334. */
  11335. static Create<T extends Function>(): Stage<T>;
  11336. /**
  11337. * Registers a step in an ordered way in the targeted stage.
  11338. * @param index Defines the position to register the step in
  11339. * @param component Defines the component attached to the step
  11340. * @param action Defines the action to launch during the step
  11341. */
  11342. registerStep(index: number, component: ISceneComponent, action: T): void;
  11343. /**
  11344. * Clears all the steps from the stage.
  11345. */
  11346. clear(): void;
  11347. }
  11348. }
  11349. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11350. import { Nullable } from "babylonjs/types";
  11351. import { Observable } from "babylonjs/Misc/observable";
  11352. import { Scene } from "babylonjs/scene";
  11353. import { Sprite } from "babylonjs/Sprites/sprite";
  11354. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11355. import { Ray } from "babylonjs/Culling/ray";
  11356. import { Camera } from "babylonjs/Cameras/camera";
  11357. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11358. import { ISceneComponent } from "babylonjs/sceneComponent";
  11359. module "babylonjs/scene" {
  11360. interface Scene {
  11361. /** @hidden */
  11362. _pointerOverSprite: Nullable<Sprite>;
  11363. /** @hidden */
  11364. _pickedDownSprite: Nullable<Sprite>;
  11365. /** @hidden */
  11366. _tempSpritePickingRay: Nullable<Ray>;
  11367. /**
  11368. * All of the sprite managers added to this scene
  11369. * @see http://doc.babylonjs.com/babylon101/sprites
  11370. */
  11371. spriteManagers: Array<ISpriteManager>;
  11372. /**
  11373. * An event triggered when sprites rendering is about to start
  11374. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11375. */
  11376. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11377. /**
  11378. * An event triggered when sprites rendering is done
  11379. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11380. */
  11381. onAfterSpritesRenderingObservable: Observable<Scene>;
  11382. /** @hidden */
  11383. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11384. /** Launch a ray to try to pick a sprite in the scene
  11385. * @param x position on screen
  11386. * @param y position on screen
  11387. * @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
  11388. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11389. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11390. * @returns a PickingInfo
  11391. */
  11392. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11393. /** Use the given ray to pick a sprite in the scene
  11394. * @param ray The ray (in world space) to use to pick meshes
  11395. * @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
  11396. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11397. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11398. * @returns a PickingInfo
  11399. */
  11400. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11401. /**
  11402. * Force the sprite under the pointer
  11403. * @param sprite defines the sprite to use
  11404. */
  11405. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11406. /**
  11407. * Gets the sprite under the pointer
  11408. * @returns a Sprite or null if no sprite is under the pointer
  11409. */
  11410. getPointerOverSprite(): Nullable<Sprite>;
  11411. }
  11412. }
  11413. /**
  11414. * Defines the sprite scene component responsible to manage sprites
  11415. * in a given scene.
  11416. */
  11417. export class SpriteSceneComponent implements ISceneComponent {
  11418. /**
  11419. * The component name helpfull to identify the component in the list of scene components.
  11420. */
  11421. readonly name: string;
  11422. /**
  11423. * The scene the component belongs to.
  11424. */
  11425. scene: Scene;
  11426. /** @hidden */
  11427. private _spritePredicate;
  11428. /**
  11429. * Creates a new instance of the component for the given scene
  11430. * @param scene Defines the scene to register the component in
  11431. */
  11432. constructor(scene: Scene);
  11433. /**
  11434. * Registers the component in a given scene
  11435. */
  11436. register(): void;
  11437. /**
  11438. * Rebuilds the elements related to this component in case of
  11439. * context lost for instance.
  11440. */
  11441. rebuild(): void;
  11442. /**
  11443. * Disposes the component and the associated ressources.
  11444. */
  11445. dispose(): void;
  11446. private _pickSpriteButKeepRay;
  11447. private _pointerMove;
  11448. private _pointerDown;
  11449. private _pointerUp;
  11450. }
  11451. }
  11452. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11453. /** @hidden */
  11454. export var fogFragmentDeclaration: {
  11455. name: string;
  11456. shader: string;
  11457. };
  11458. }
  11459. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11460. /** @hidden */
  11461. export var fogFragment: {
  11462. name: string;
  11463. shader: string;
  11464. };
  11465. }
  11466. declare module "babylonjs/Shaders/sprites.fragment" {
  11467. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11468. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11469. /** @hidden */
  11470. export var spritesPixelShader: {
  11471. name: string;
  11472. shader: string;
  11473. };
  11474. }
  11475. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11476. /** @hidden */
  11477. export var fogVertexDeclaration: {
  11478. name: string;
  11479. shader: string;
  11480. };
  11481. }
  11482. declare module "babylonjs/Shaders/sprites.vertex" {
  11483. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11484. /** @hidden */
  11485. export var spritesVertexShader: {
  11486. name: string;
  11487. shader: string;
  11488. };
  11489. }
  11490. declare module "babylonjs/Sprites/spriteManager" {
  11491. import { IDisposable, Scene } from "babylonjs/scene";
  11492. import { Nullable } from "babylonjs/types";
  11493. import { Observable } from "babylonjs/Misc/observable";
  11494. import { Sprite } from "babylonjs/Sprites/sprite";
  11495. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11496. import { Camera } from "babylonjs/Cameras/camera";
  11497. import { Texture } from "babylonjs/Materials/Textures/texture";
  11498. import "babylonjs/Shaders/sprites.fragment";
  11499. import "babylonjs/Shaders/sprites.vertex";
  11500. import { Ray } from "babylonjs/Culling/ray";
  11501. /**
  11502. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11503. */
  11504. export interface ISpriteManager extends IDisposable {
  11505. /**
  11506. * Restricts the camera to viewing objects with the same layerMask.
  11507. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11508. */
  11509. layerMask: number;
  11510. /**
  11511. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11512. */
  11513. isPickable: boolean;
  11514. /**
  11515. * Specifies the rendering group id for this mesh (0 by default)
  11516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11517. */
  11518. renderingGroupId: number;
  11519. /**
  11520. * Defines the list of sprites managed by the manager.
  11521. */
  11522. sprites: Array<Sprite>;
  11523. /**
  11524. * Tests the intersection of a sprite with a specific ray.
  11525. * @param ray The ray we are sending to test the collision
  11526. * @param camera The camera space we are sending rays in
  11527. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11528. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11529. * @returns picking info or null.
  11530. */
  11531. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11532. /**
  11533. * Renders the list of sprites on screen.
  11534. */
  11535. render(): void;
  11536. }
  11537. /**
  11538. * Class used to manage multiple sprites on the same spritesheet
  11539. * @see http://doc.babylonjs.com/babylon101/sprites
  11540. */
  11541. export class SpriteManager implements ISpriteManager {
  11542. /** defines the manager's name */
  11543. name: string;
  11544. /** Gets the list of sprites */
  11545. sprites: Sprite[];
  11546. /** Gets or sets the rendering group id (0 by default) */
  11547. renderingGroupId: number;
  11548. /** Gets or sets camera layer mask */
  11549. layerMask: number;
  11550. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11551. fogEnabled: boolean;
  11552. /** Gets or sets a boolean indicating if the sprites are pickable */
  11553. isPickable: boolean;
  11554. /** Defines the default width of a cell in the spritesheet */
  11555. cellWidth: number;
  11556. /** Defines the default height of a cell in the spritesheet */
  11557. cellHeight: number;
  11558. /**
  11559. * An event triggered when the manager is disposed.
  11560. */
  11561. onDisposeObservable: Observable<SpriteManager>;
  11562. private _onDisposeObserver;
  11563. /**
  11564. * Callback called when the manager is disposed
  11565. */
  11566. onDispose: () => void;
  11567. private _capacity;
  11568. private _spriteTexture;
  11569. private _epsilon;
  11570. private _scene;
  11571. private _vertexData;
  11572. private _buffer;
  11573. private _vertexBuffers;
  11574. private _indexBuffer;
  11575. private _effectBase;
  11576. private _effectFog;
  11577. /**
  11578. * Gets or sets the spritesheet texture
  11579. */
  11580. texture: Texture;
  11581. /**
  11582. * Creates a new sprite manager
  11583. * @param name defines the manager's name
  11584. * @param imgUrl defines the sprite sheet url
  11585. * @param capacity defines the maximum allowed number of sprites
  11586. * @param cellSize defines the size of a sprite cell
  11587. * @param scene defines the hosting scene
  11588. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11589. * @param samplingMode defines the smapling mode to use with spritesheet
  11590. */
  11591. constructor(
  11592. /** defines the manager's name */
  11593. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11594. private _appendSpriteVertex;
  11595. /**
  11596. * Intersects the sprites with a ray
  11597. * @param ray defines the ray to intersect with
  11598. * @param camera defines the current active camera
  11599. * @param predicate defines a predicate used to select candidate sprites
  11600. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11601. * @returns null if no hit or a PickingInfo
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Render all child sprites
  11606. */
  11607. render(): void;
  11608. /**
  11609. * Release associated resources
  11610. */
  11611. dispose(): void;
  11612. }
  11613. }
  11614. declare module "babylonjs/Sprites/sprite" {
  11615. import { Vector3 } from "babylonjs/Maths/math.vector";
  11616. import { Nullable } from "babylonjs/types";
  11617. import { ActionManager } from "babylonjs/Actions/actionManager";
  11618. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11619. import { Color4 } from "babylonjs/Maths/math.color";
  11620. /**
  11621. * Class used to represent a sprite
  11622. * @see http://doc.babylonjs.com/babylon101/sprites
  11623. */
  11624. export class Sprite {
  11625. /** defines the name */
  11626. name: string;
  11627. /** Gets or sets the current world position */
  11628. position: Vector3;
  11629. /** Gets or sets the main color */
  11630. color: Color4;
  11631. /** Gets or sets the width */
  11632. width: number;
  11633. /** Gets or sets the height */
  11634. height: number;
  11635. /** Gets or sets rotation angle */
  11636. angle: number;
  11637. /** Gets or sets the cell index in the sprite sheet */
  11638. cellIndex: number;
  11639. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11640. invertU: number;
  11641. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11642. invertV: number;
  11643. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11644. disposeWhenFinishedAnimating: boolean;
  11645. /** Gets the list of attached animations */
  11646. animations: Animation[];
  11647. /** Gets or sets a boolean indicating if the sprite can be picked */
  11648. isPickable: boolean;
  11649. /**
  11650. * Gets or sets the associated action manager
  11651. */
  11652. actionManager: Nullable<ActionManager>;
  11653. private _animationStarted;
  11654. private _loopAnimation;
  11655. private _fromIndex;
  11656. private _toIndex;
  11657. private _delay;
  11658. private _direction;
  11659. private _manager;
  11660. private _time;
  11661. private _onAnimationEnd;
  11662. /**
  11663. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11664. */
  11665. isVisible: boolean;
  11666. /**
  11667. * Gets or sets the sprite size
  11668. */
  11669. size: number;
  11670. /**
  11671. * Creates a new Sprite
  11672. * @param name defines the name
  11673. * @param manager defines the manager
  11674. */
  11675. constructor(
  11676. /** defines the name */
  11677. name: string, manager: ISpriteManager);
  11678. /**
  11679. * Starts an animation
  11680. * @param from defines the initial key
  11681. * @param to defines the end key
  11682. * @param loop defines if the animation must loop
  11683. * @param delay defines the start delay (in ms)
  11684. * @param onAnimationEnd defines a callback to call when animation ends
  11685. */
  11686. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11687. /** Stops current animation (if any) */
  11688. stopAnimation(): void;
  11689. /** @hidden */
  11690. _animate(deltaTime: number): void;
  11691. /** Release associated resources */
  11692. dispose(): void;
  11693. }
  11694. }
  11695. declare module "babylonjs/Collisions/pickingInfo" {
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11699. import { Sprite } from "babylonjs/Sprites/sprite";
  11700. import { Ray } from "babylonjs/Culling/ray";
  11701. /**
  11702. * Information about the result of picking within a scene
  11703. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11704. */
  11705. export class PickingInfo {
  11706. /** @hidden */
  11707. _pickingUnavailable: boolean;
  11708. /**
  11709. * If the pick collided with an object
  11710. */
  11711. hit: boolean;
  11712. /**
  11713. * Distance away where the pick collided
  11714. */
  11715. distance: number;
  11716. /**
  11717. * The location of pick collision
  11718. */
  11719. pickedPoint: Nullable<Vector3>;
  11720. /**
  11721. * The mesh corresponding the the pick collision
  11722. */
  11723. pickedMesh: Nullable<AbstractMesh>;
  11724. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11725. bu: number;
  11726. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11727. bv: number;
  11728. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11729. faceId: number;
  11730. /** Id of the the submesh that was picked */
  11731. subMeshId: number;
  11732. /** If a sprite was picked, this will be the sprite the pick collided with */
  11733. pickedSprite: Nullable<Sprite>;
  11734. /**
  11735. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11736. */
  11737. originMesh: Nullable<AbstractMesh>;
  11738. /**
  11739. * The ray that was used to perform the picking.
  11740. */
  11741. ray: Nullable<Ray>;
  11742. /**
  11743. * Gets the normal correspodning to the face the pick collided with
  11744. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11745. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11746. * @returns The normal correspodning to the face the pick collided with
  11747. */
  11748. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11749. /**
  11750. * Gets the texture coordinates of where the pick occured
  11751. * @returns the vector containing the coordnates of the texture
  11752. */
  11753. getTextureCoordinates(): Nullable<Vector2>;
  11754. }
  11755. }
  11756. declare module "babylonjs/Events/pointerEvents" {
  11757. import { Nullable } from "babylonjs/types";
  11758. import { Vector2 } from "babylonjs/Maths/math.vector";
  11759. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11760. import { Ray } from "babylonjs/Culling/ray";
  11761. /**
  11762. * Gather the list of pointer event types as constants.
  11763. */
  11764. export class PointerEventTypes {
  11765. /**
  11766. * 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.
  11767. */
  11768. static readonly POINTERDOWN: number;
  11769. /**
  11770. * The pointerup event is fired when a pointer is no longer active.
  11771. */
  11772. static readonly POINTERUP: number;
  11773. /**
  11774. * The pointermove event is fired when a pointer changes coordinates.
  11775. */
  11776. static readonly POINTERMOVE: number;
  11777. /**
  11778. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11779. */
  11780. static readonly POINTERWHEEL: number;
  11781. /**
  11782. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11783. */
  11784. static readonly POINTERPICK: number;
  11785. /**
  11786. * The pointertap event is fired when a the object has been touched and released without drag.
  11787. */
  11788. static readonly POINTERTAP: number;
  11789. /**
  11790. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11791. */
  11792. static readonly POINTERDOUBLETAP: number;
  11793. }
  11794. /**
  11795. * Base class of pointer info types.
  11796. */
  11797. export class PointerInfoBase {
  11798. /**
  11799. * Defines the type of event (PointerEventTypes)
  11800. */
  11801. type: number;
  11802. /**
  11803. * Defines the related dom event
  11804. */
  11805. event: PointerEvent | MouseWheelEvent;
  11806. /**
  11807. * Instantiates the base class of pointers info.
  11808. * @param type Defines the type of event (PointerEventTypes)
  11809. * @param event Defines the related dom event
  11810. */
  11811. constructor(
  11812. /**
  11813. * Defines the type of event (PointerEventTypes)
  11814. */
  11815. type: number,
  11816. /**
  11817. * Defines the related dom event
  11818. */
  11819. event: PointerEvent | MouseWheelEvent);
  11820. }
  11821. /**
  11822. * This class is used to store pointer related info for the onPrePointerObservable event.
  11823. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11824. */
  11825. export class PointerInfoPre extends PointerInfoBase {
  11826. /**
  11827. * Ray from a pointer if availible (eg. 6dof controller)
  11828. */
  11829. ray: Nullable<Ray>;
  11830. /**
  11831. * Defines the local position of the pointer on the canvas.
  11832. */
  11833. localPosition: Vector2;
  11834. /**
  11835. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11836. */
  11837. skipOnPointerObservable: boolean;
  11838. /**
  11839. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11840. * @param type Defines the type of event (PointerEventTypes)
  11841. * @param event Defines the related dom event
  11842. * @param localX Defines the local x coordinates of the pointer when the event occured
  11843. * @param localY Defines the local y coordinates of the pointer when the event occured
  11844. */
  11845. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11846. }
  11847. /**
  11848. * This type contains all the data related to a pointer event in Babylon.js.
  11849. * 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.
  11850. */
  11851. export class PointerInfo extends PointerInfoBase {
  11852. /**
  11853. * Defines the picking info associated to the info (if any)\
  11854. */
  11855. pickInfo: Nullable<PickingInfo>;
  11856. /**
  11857. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11858. * @param type Defines the type of event (PointerEventTypes)
  11859. * @param event Defines the related dom event
  11860. * @param pickInfo Defines the picking info associated to the info (if any)\
  11861. */
  11862. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11863. /**
  11864. * Defines the picking info associated to the info (if any)\
  11865. */
  11866. pickInfo: Nullable<PickingInfo>);
  11867. }
  11868. /**
  11869. * Data relating to a touch event on the screen.
  11870. */
  11871. export interface PointerTouch {
  11872. /**
  11873. * X coordinate of touch.
  11874. */
  11875. x: number;
  11876. /**
  11877. * Y coordinate of touch.
  11878. */
  11879. y: number;
  11880. /**
  11881. * Id of touch. Unique for each finger.
  11882. */
  11883. pointerId: number;
  11884. /**
  11885. * Event type passed from DOM.
  11886. */
  11887. type: any;
  11888. }
  11889. }
  11890. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11891. import { Observable } from "babylonjs/Misc/observable";
  11892. import { Nullable } from "babylonjs/types";
  11893. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11894. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11895. /**
  11896. * Manage the mouse inputs to control the movement of a free camera.
  11897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11898. */
  11899. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11900. /**
  11901. * Define if touch is enabled in the mouse input
  11902. */
  11903. touchEnabled: boolean;
  11904. /**
  11905. * Defines the camera the input is attached to.
  11906. */
  11907. camera: FreeCamera;
  11908. /**
  11909. * Defines the buttons associated with the input to handle camera move.
  11910. */
  11911. buttons: number[];
  11912. /**
  11913. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11914. */
  11915. angularSensibility: number;
  11916. private _pointerInput;
  11917. private _onMouseMove;
  11918. private _observer;
  11919. private previousPosition;
  11920. /**
  11921. * Observable for when a pointer move event occurs containing the move offset
  11922. */
  11923. onPointerMovedObservable: Observable<{
  11924. offsetX: number;
  11925. offsetY: number;
  11926. }>;
  11927. /**
  11928. * @hidden
  11929. * If the camera should be rotated automatically based on pointer movement
  11930. */
  11931. _allowCameraRotation: boolean;
  11932. /**
  11933. * Manage the mouse inputs to control the movement of a free camera.
  11934. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11935. * @param touchEnabled Defines if touch is enabled or not
  11936. */
  11937. constructor(
  11938. /**
  11939. * Define if touch is enabled in the mouse input
  11940. */
  11941. touchEnabled?: boolean);
  11942. /**
  11943. * Attach the input controls to a specific dom element to get the input from.
  11944. * @param element Defines the element the controls should be listened from
  11945. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11946. */
  11947. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11948. /**
  11949. * Called on JS contextmenu event.
  11950. * Override this method to provide functionality.
  11951. */
  11952. protected onContextMenu(evt: PointerEvent): void;
  11953. /**
  11954. * Detach the current controls from the specified dom element.
  11955. * @param element Defines the element to stop listening the inputs from
  11956. */
  11957. detachControl(element: Nullable<HTMLElement>): void;
  11958. /**
  11959. * Gets the class name of the current intput.
  11960. * @returns the class name
  11961. */
  11962. getClassName(): string;
  11963. /**
  11964. * Get the friendly name associated with the input class.
  11965. * @returns the input friendly name
  11966. */
  11967. getSimpleName(): string;
  11968. }
  11969. }
  11970. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  11971. import { Nullable } from "babylonjs/types";
  11972. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11973. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11974. /**
  11975. * Manage the touch inputs to control the movement of a free camera.
  11976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11977. */
  11978. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11979. /**
  11980. * Defines the camera the input is attached to.
  11981. */
  11982. camera: FreeCamera;
  11983. /**
  11984. * Defines the touch sensibility for rotation.
  11985. * The higher the faster.
  11986. */
  11987. touchAngularSensibility: number;
  11988. /**
  11989. * Defines the touch sensibility for move.
  11990. * The higher the faster.
  11991. */
  11992. touchMoveSensibility: number;
  11993. private _offsetX;
  11994. private _offsetY;
  11995. private _pointerPressed;
  11996. private _pointerInput;
  11997. private _observer;
  11998. private _onLostFocus;
  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. * Detach the current controls from the specified dom element.
  12007. * @param element Defines the element to stop listening the inputs from
  12008. */
  12009. detachControl(element: Nullable<HTMLElement>): void;
  12010. /**
  12011. * Update the current camera state depending on the inputs that have been used this frame.
  12012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12013. */
  12014. checkInputs(): 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/freeCameraInputsManager" {
  12028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12029. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12030. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12031. import { Nullable } from "babylonjs/types";
  12032. /**
  12033. * Default Inputs manager for the FreeCamera.
  12034. * It groups all the default supported inputs for ease of use.
  12035. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12036. */
  12037. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12038. /**
  12039. * @hidden
  12040. */
  12041. _mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. /**
  12069. * Remove all attached input methods from a camera
  12070. */
  12071. clear(): void;
  12072. }
  12073. }
  12074. declare module "babylonjs/Cameras/freeCamera" {
  12075. import { Vector3 } from "babylonjs/Maths/math.vector";
  12076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12077. import { Scene } from "babylonjs/scene";
  12078. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12079. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12080. /**
  12081. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12082. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12083. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12084. */
  12085. export class FreeCamera extends TargetCamera {
  12086. /**
  12087. * Define the collision ellipsoid of the camera.
  12088. * This is helpful to simulate a camera body like the player body around the camera
  12089. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12090. */
  12091. ellipsoid: Vector3;
  12092. /**
  12093. * Define an offset for the position of the ellipsoid around the camera.
  12094. * This can be helpful to determine the center of the body near the gravity center of the body
  12095. * instead of its head.
  12096. */
  12097. ellipsoidOffset: Vector3;
  12098. /**
  12099. * Enable or disable collisions of the camera with the rest of the scene objects.
  12100. */
  12101. checkCollisions: boolean;
  12102. /**
  12103. * Enable or disable gravity on the camera.
  12104. */
  12105. applyGravity: boolean;
  12106. /**
  12107. * Define the input manager associated to the camera.
  12108. */
  12109. inputs: FreeCameraInputsManager;
  12110. /**
  12111. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12112. * Higher values reduce sensitivity.
  12113. */
  12114. /**
  12115. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12116. * Higher values reduce sensitivity.
  12117. */
  12118. angularSensibility: number;
  12119. /**
  12120. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12121. */
  12122. keysUp: number[];
  12123. /**
  12124. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12125. */
  12126. keysDown: number[];
  12127. /**
  12128. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12129. */
  12130. keysLeft: number[];
  12131. /**
  12132. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12133. */
  12134. keysRight: number[];
  12135. /**
  12136. * Event raised when the camera collide with a mesh in the scene.
  12137. */
  12138. onCollide: (collidedMesh: AbstractMesh) => void;
  12139. private _collider;
  12140. private _needMoveForGravity;
  12141. private _oldPosition;
  12142. private _diffPosition;
  12143. private _newPosition;
  12144. /** @hidden */
  12145. _localDirection: Vector3;
  12146. /** @hidden */
  12147. _transformedDirection: Vector3;
  12148. /**
  12149. * Instantiates a Free Camera.
  12150. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12151. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12152. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12153. * @param name Define the name of the camera in the scene
  12154. * @param position Define the start position of the camera in the scene
  12155. * @param scene Define the scene the camera belongs to
  12156. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12157. */
  12158. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12159. /**
  12160. * Attached controls to the current camera.
  12161. * @param element Defines the element the controls should be listened from
  12162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12163. */
  12164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12165. /**
  12166. * Detach the current controls from the camera.
  12167. * The camera will stop reacting to inputs.
  12168. * @param element Defines the element to stop listening the inputs from
  12169. */
  12170. detachControl(element: HTMLElement): void;
  12171. private _collisionMask;
  12172. /**
  12173. * Define a collision mask to limit the list of object the camera can collide with
  12174. */
  12175. collisionMask: number;
  12176. /** @hidden */
  12177. _collideWithWorld(displacement: Vector3): void;
  12178. private _onCollisionPositionChange;
  12179. /** @hidden */
  12180. _checkInputs(): void;
  12181. /** @hidden */
  12182. _decideIfNeedsToMove(): boolean;
  12183. /** @hidden */
  12184. _updatePosition(): void;
  12185. /**
  12186. * Destroy the camera and release the current resources hold by it.
  12187. */
  12188. dispose(): void;
  12189. /**
  12190. * Gets the current object class name.
  12191. * @return the class name
  12192. */
  12193. getClassName(): string;
  12194. }
  12195. }
  12196. declare module "babylonjs/Gamepads/gamepad" {
  12197. import { Observable } from "babylonjs/Misc/observable";
  12198. /**
  12199. * Represents a gamepad control stick position
  12200. */
  12201. export class StickValues {
  12202. /**
  12203. * The x component of the control stick
  12204. */
  12205. x: number;
  12206. /**
  12207. * The y component of the control stick
  12208. */
  12209. y: number;
  12210. /**
  12211. * Initializes the gamepad x and y control stick values
  12212. * @param x The x component of the gamepad control stick value
  12213. * @param y The y component of the gamepad control stick value
  12214. */
  12215. constructor(
  12216. /**
  12217. * The x component of the control stick
  12218. */
  12219. x: number,
  12220. /**
  12221. * The y component of the control stick
  12222. */
  12223. y: number);
  12224. }
  12225. /**
  12226. * An interface which manages callbacks for gamepad button changes
  12227. */
  12228. export interface GamepadButtonChanges {
  12229. /**
  12230. * Called when a gamepad has been changed
  12231. */
  12232. changed: boolean;
  12233. /**
  12234. * Called when a gamepad press event has been triggered
  12235. */
  12236. pressChanged: boolean;
  12237. /**
  12238. * Called when a touch event has been triggered
  12239. */
  12240. touchChanged: boolean;
  12241. /**
  12242. * Called when a value has changed
  12243. */
  12244. valueChanged: boolean;
  12245. }
  12246. /**
  12247. * Represents a gamepad
  12248. */
  12249. export class Gamepad {
  12250. /**
  12251. * The id of the gamepad
  12252. */
  12253. id: string;
  12254. /**
  12255. * The index of the gamepad
  12256. */
  12257. index: number;
  12258. /**
  12259. * The browser gamepad
  12260. */
  12261. browserGamepad: any;
  12262. /**
  12263. * Specifies what type of gamepad this represents
  12264. */
  12265. type: number;
  12266. private _leftStick;
  12267. private _rightStick;
  12268. /** @hidden */
  12269. _isConnected: boolean;
  12270. private _leftStickAxisX;
  12271. private _leftStickAxisY;
  12272. private _rightStickAxisX;
  12273. private _rightStickAxisY;
  12274. /**
  12275. * Triggered when the left control stick has been changed
  12276. */
  12277. private _onleftstickchanged;
  12278. /**
  12279. * Triggered when the right control stick has been changed
  12280. */
  12281. private _onrightstickchanged;
  12282. /**
  12283. * Represents a gamepad controller
  12284. */
  12285. static GAMEPAD: number;
  12286. /**
  12287. * Represents a generic controller
  12288. */
  12289. static GENERIC: number;
  12290. /**
  12291. * Represents an XBox controller
  12292. */
  12293. static XBOX: number;
  12294. /**
  12295. * Represents a pose-enabled controller
  12296. */
  12297. static POSE_ENABLED: number;
  12298. /**
  12299. * Specifies whether the left control stick should be Y-inverted
  12300. */
  12301. protected _invertLeftStickY: boolean;
  12302. /**
  12303. * Specifies if the gamepad has been connected
  12304. */
  12305. readonly isConnected: boolean;
  12306. /**
  12307. * Initializes the gamepad
  12308. * @param id The id of the gamepad
  12309. * @param index The index of the gamepad
  12310. * @param browserGamepad The browser gamepad
  12311. * @param leftStickX The x component of the left joystick
  12312. * @param leftStickY The y component of the left joystick
  12313. * @param rightStickX The x component of the right joystick
  12314. * @param rightStickY The y component of the right joystick
  12315. */
  12316. constructor(
  12317. /**
  12318. * The id of the gamepad
  12319. */
  12320. id: string,
  12321. /**
  12322. * The index of the gamepad
  12323. */
  12324. index: number,
  12325. /**
  12326. * The browser gamepad
  12327. */
  12328. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12329. /**
  12330. * Callback triggered when the left joystick has changed
  12331. * @param callback
  12332. */
  12333. onleftstickchanged(callback: (values: StickValues) => void): void;
  12334. /**
  12335. * Callback triggered when the right joystick has changed
  12336. * @param callback
  12337. */
  12338. onrightstickchanged(callback: (values: StickValues) => void): void;
  12339. /**
  12340. * Gets the left joystick
  12341. */
  12342. /**
  12343. * Sets the left joystick values
  12344. */
  12345. leftStick: StickValues;
  12346. /**
  12347. * Gets the right joystick
  12348. */
  12349. /**
  12350. * Sets the right joystick value
  12351. */
  12352. rightStick: StickValues;
  12353. /**
  12354. * Updates the gamepad joystick positions
  12355. */
  12356. update(): void;
  12357. /**
  12358. * Disposes the gamepad
  12359. */
  12360. dispose(): void;
  12361. }
  12362. /**
  12363. * Represents a generic gamepad
  12364. */
  12365. export class GenericPad extends Gamepad {
  12366. private _buttons;
  12367. private _onbuttondown;
  12368. private _onbuttonup;
  12369. /**
  12370. * Observable triggered when a button has been pressed
  12371. */
  12372. onButtonDownObservable: Observable<number>;
  12373. /**
  12374. * Observable triggered when a button has been released
  12375. */
  12376. onButtonUpObservable: Observable<number>;
  12377. /**
  12378. * Callback triggered when a button has been pressed
  12379. * @param callback Called when a button has been pressed
  12380. */
  12381. onbuttondown(callback: (buttonPressed: number) => void): void;
  12382. /**
  12383. * Callback triggered when a button has been released
  12384. * @param callback Called when a button has been released
  12385. */
  12386. onbuttonup(callback: (buttonReleased: number) => void): void;
  12387. /**
  12388. * Initializes the generic gamepad
  12389. * @param id The id of the generic gamepad
  12390. * @param index The index of the generic gamepad
  12391. * @param browserGamepad The browser gamepad
  12392. */
  12393. constructor(id: string, index: number, browserGamepad: any);
  12394. private _setButtonValue;
  12395. /**
  12396. * Updates the generic gamepad
  12397. */
  12398. update(): void;
  12399. /**
  12400. * Disposes the generic gamepad
  12401. */
  12402. dispose(): void;
  12403. }
  12404. }
  12405. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12406. import { Nullable } from "babylonjs/types";
  12407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12408. import { Scene } from "babylonjs/scene";
  12409. module "babylonjs/Engines/engine" {
  12410. interface Engine {
  12411. /**
  12412. * Creates a raw texture
  12413. * @param data defines the data to store in the texture
  12414. * @param width defines the width of the texture
  12415. * @param height defines the height of the texture
  12416. * @param format defines the format of the data
  12417. * @param generateMipMaps defines if the engine should generate the mip levels
  12418. * @param invertY defines if data must be stored with Y axis inverted
  12419. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12420. * @param compression defines the compression used (null by default)
  12421. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12422. * @returns the raw texture inside an InternalTexture
  12423. */
  12424. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12425. /**
  12426. * Update a raw texture
  12427. * @param texture defines the texture to update
  12428. * @param data defines the data to store in the texture
  12429. * @param format defines the format of the data
  12430. * @param invertY defines if data must be stored with Y axis inverted
  12431. */
  12432. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12433. /**
  12434. * Update a raw texture
  12435. * @param texture defines the texture to update
  12436. * @param data defines the data to store in the texture
  12437. * @param format defines the format of the data
  12438. * @param invertY defines if data must be stored with Y axis inverted
  12439. * @param compression defines the compression used (null by default)
  12440. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12441. */
  12442. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12443. /**
  12444. * Creates a new raw cube texture
  12445. * @param data defines the array of data to use to create each face
  12446. * @param size defines the size of the textures
  12447. * @param format defines the format of the data
  12448. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12449. * @param generateMipMaps defines if the engine should generate the mip levels
  12450. * @param invertY defines if data must be stored with Y axis inverted
  12451. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12452. * @param compression defines the compression used (null by default)
  12453. * @returns the cube texture as an InternalTexture
  12454. */
  12455. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12456. /**
  12457. * Update a raw cube texture
  12458. * @param texture defines the texture to udpdate
  12459. * @param data defines the data to store
  12460. * @param format defines the data format
  12461. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12462. * @param invertY defines if data must be stored with Y axis inverted
  12463. */
  12464. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12465. /**
  12466. * Update a raw cube texture
  12467. * @param texture defines the texture to udpdate
  12468. * @param data defines the data to store
  12469. * @param format defines the data format
  12470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12471. * @param invertY defines if data must be stored with Y axis inverted
  12472. * @param compression defines the compression used (null by default)
  12473. */
  12474. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12475. /**
  12476. * Update a raw cube texture
  12477. * @param texture defines the texture to udpdate
  12478. * @param data defines the data to store
  12479. * @param format defines the data format
  12480. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12481. * @param invertY defines if data must be stored with Y axis inverted
  12482. * @param compression defines the compression used (null by default)
  12483. * @param level defines which level of the texture to update
  12484. */
  12485. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12486. /**
  12487. * Creates a new raw cube texture from a specified url
  12488. * @param url defines the url where the data is located
  12489. * @param scene defines the current scene
  12490. * @param size defines the size of the textures
  12491. * @param format defines the format of the data
  12492. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12493. * @param noMipmap defines if the engine should avoid generating the mip levels
  12494. * @param callback defines a callback used to extract texture data from loaded data
  12495. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12496. * @param onLoad defines a callback called when texture is loaded
  12497. * @param onError defines a callback called if there is an error
  12498. * @returns the cube texture as an InternalTexture
  12499. */
  12500. 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;
  12501. /**
  12502. * Creates a new raw cube texture from a specified url
  12503. * @param url defines the url where the data is located
  12504. * @param scene defines the current scene
  12505. * @param size defines the size of the textures
  12506. * @param format defines the format of the data
  12507. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12508. * @param noMipmap defines if the engine should avoid generating the mip levels
  12509. * @param callback defines a callback used to extract texture data from loaded data
  12510. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12511. * @param onLoad defines a callback called when texture is loaded
  12512. * @param onError defines a callback called if there is an error
  12513. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12514. * @param invertY defines if data must be stored with Y axis inverted
  12515. * @returns the cube texture as an InternalTexture
  12516. */
  12517. 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;
  12518. /**
  12519. * Creates a new raw 3D texture
  12520. * @param data defines the data used to create the texture
  12521. * @param width defines the width of the texture
  12522. * @param height defines the height of the texture
  12523. * @param depth defines the depth of the texture
  12524. * @param format defines the format of the texture
  12525. * @param generateMipMaps defines if the engine must generate mip levels
  12526. * @param invertY defines if data must be stored with Y axis inverted
  12527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12528. * @param compression defines the compressed used (can be null)
  12529. * @param textureType defines the compressed used (can be null)
  12530. * @returns a new raw 3D texture (stored in an InternalTexture)
  12531. */
  12532. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12533. /**
  12534. * Update a raw 3D texture
  12535. * @param texture defines the texture to update
  12536. * @param data defines the data to store
  12537. * @param format defines the data format
  12538. * @param invertY defines if data must be stored with Y axis inverted
  12539. */
  12540. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12541. /**
  12542. * Update a raw 3D texture
  12543. * @param texture defines the texture to update
  12544. * @param data defines the data to store
  12545. * @param format defines the data format
  12546. * @param invertY defines if data must be stored with Y axis inverted
  12547. * @param compression defines the used compression (can be null)
  12548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12549. */
  12550. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12551. }
  12552. }
  12553. }
  12554. declare module "babylonjs/Materials/Textures/rawTexture" {
  12555. import { Scene } from "babylonjs/scene";
  12556. import { Texture } from "babylonjs/Materials/Textures/texture";
  12557. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12558. /**
  12559. * Raw texture can help creating a texture directly from an array of data.
  12560. * This can be super useful if you either get the data from an uncompressed source or
  12561. * if you wish to create your texture pixel by pixel.
  12562. */
  12563. export class RawTexture extends Texture {
  12564. /**
  12565. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12566. */
  12567. format: number;
  12568. private _engine;
  12569. /**
  12570. * Instantiates a new RawTexture.
  12571. * Raw texture can help creating a texture directly from an array of data.
  12572. * This can be super useful if you either get the data from an uncompressed source or
  12573. * if you wish to create your texture pixel by pixel.
  12574. * @param data define the array of data to use to create the texture
  12575. * @param width define the width of the texture
  12576. * @param height define the height of the texture
  12577. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. * @param scene define the scene the texture belongs to
  12579. * @param generateMipMaps define whether mip maps should be generated or not
  12580. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12581. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12582. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12583. */
  12584. constructor(data: ArrayBufferView, width: number, height: number,
  12585. /**
  12586. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12587. */
  12588. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12589. /**
  12590. * Updates the texture underlying data.
  12591. * @param data Define the new data of the texture
  12592. */
  12593. update(data: ArrayBufferView): void;
  12594. /**
  12595. * Creates a luminance texture from some data.
  12596. * @param data Define the texture data
  12597. * @param width Define the width of the texture
  12598. * @param height Define the height of the texture
  12599. * @param scene Define the scene the texture belongs to
  12600. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12601. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12602. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12603. * @returns the luminance texture
  12604. */
  12605. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12606. /**
  12607. * Creates a luminance alpha texture from some data.
  12608. * @param data Define the texture data
  12609. * @param width Define the width of the texture
  12610. * @param height Define the height of the texture
  12611. * @param scene Define the scene the texture belongs to
  12612. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12613. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12614. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12615. * @returns the luminance alpha texture
  12616. */
  12617. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12618. /**
  12619. * Creates an alpha texture from some data.
  12620. * @param data Define the texture data
  12621. * @param width Define the width of the texture
  12622. * @param height Define the height of the texture
  12623. * @param scene Define the scene the texture belongs to
  12624. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12625. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12626. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12627. * @returns the alpha texture
  12628. */
  12629. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12630. /**
  12631. * Creates a RGB texture from some data.
  12632. * @param data Define the texture data
  12633. * @param width Define the width of the texture
  12634. * @param height Define the height of the texture
  12635. * @param scene Define the scene the texture belongs to
  12636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12640. * @returns the RGB alpha texture
  12641. */
  12642. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12643. /**
  12644. * Creates a RGBA texture from some data.
  12645. * @param data Define the texture data
  12646. * @param width Define the width of the texture
  12647. * @param height Define the height of the texture
  12648. * @param scene Define the scene the texture belongs to
  12649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12653. * @returns the RGBA texture
  12654. */
  12655. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12656. /**
  12657. * Creates a R texture from some data.
  12658. * @param data Define the texture data
  12659. * @param width Define the width of the texture
  12660. * @param height Define the height of the texture
  12661. * @param scene Define the scene the texture belongs to
  12662. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12663. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12664. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12665. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12666. * @returns the R texture
  12667. */
  12668. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12669. }
  12670. }
  12671. declare module "babylonjs/Maths/math.size" {
  12672. /**
  12673. * Interface for the size containing width and height
  12674. */
  12675. export interface ISize {
  12676. /**
  12677. * Width
  12678. */
  12679. width: number;
  12680. /**
  12681. * Heighht
  12682. */
  12683. height: number;
  12684. }
  12685. /**
  12686. * Size containing widht and height
  12687. */
  12688. export class Size implements ISize {
  12689. /**
  12690. * Width
  12691. */
  12692. width: number;
  12693. /**
  12694. * Height
  12695. */
  12696. height: number;
  12697. /**
  12698. * Creates a Size object from the given width and height (floats).
  12699. * @param width width of the new size
  12700. * @param height height of the new size
  12701. */
  12702. constructor(width: number, height: number);
  12703. /**
  12704. * Returns a string with the Size width and height
  12705. * @returns a string with the Size width and height
  12706. */
  12707. toString(): string;
  12708. /**
  12709. * "Size"
  12710. * @returns the string "Size"
  12711. */
  12712. getClassName(): string;
  12713. /**
  12714. * Returns the Size hash code.
  12715. * @returns a hash code for a unique width and height
  12716. */
  12717. getHashCode(): number;
  12718. /**
  12719. * Updates the current size from the given one.
  12720. * @param src the given size
  12721. */
  12722. copyFrom(src: Size): void;
  12723. /**
  12724. * Updates in place the current Size from the given floats.
  12725. * @param width width of the new size
  12726. * @param height height of the new size
  12727. * @returns the updated Size.
  12728. */
  12729. copyFromFloats(width: number, height: number): Size;
  12730. /**
  12731. * Updates in place the current Size from the given floats.
  12732. * @param width width to set
  12733. * @param height height to set
  12734. * @returns the updated Size.
  12735. */
  12736. set(width: number, height: number): Size;
  12737. /**
  12738. * Multiplies the width and height by numbers
  12739. * @param w factor to multiple the width by
  12740. * @param h factor to multiple the height by
  12741. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12742. */
  12743. multiplyByFloats(w: number, h: number): Size;
  12744. /**
  12745. * Clones the size
  12746. * @returns a new Size copied from the given one.
  12747. */
  12748. clone(): Size;
  12749. /**
  12750. * True if the current Size and the given one width and height are strictly equal.
  12751. * @param other the other size to compare against
  12752. * @returns True if the current Size and the given one width and height are strictly equal.
  12753. */
  12754. equals(other: Size): boolean;
  12755. /**
  12756. * The surface of the Size : width * height (float).
  12757. */
  12758. readonly surface: number;
  12759. /**
  12760. * Create a new size of zero
  12761. * @returns a new Size set to (0.0, 0.0)
  12762. */
  12763. static Zero(): Size;
  12764. /**
  12765. * Sums the width and height of two sizes
  12766. * @param otherSize size to add to this size
  12767. * @returns a new Size set as the addition result of the current Size and the given one.
  12768. */
  12769. add(otherSize: Size): Size;
  12770. /**
  12771. * Subtracts the width and height of two
  12772. * @param otherSize size to subtract to this size
  12773. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12774. */
  12775. subtract(otherSize: Size): Size;
  12776. /**
  12777. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12778. * @param start starting size to lerp between
  12779. * @param end end size to lerp between
  12780. * @param amount amount to lerp between the start and end values
  12781. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12782. */
  12783. static Lerp(start: Size, end: Size, amount: number): Size;
  12784. }
  12785. }
  12786. declare module "babylonjs/Animations/runtimeAnimation" {
  12787. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12788. import { Animatable } from "babylonjs/Animations/animatable";
  12789. import { Scene } from "babylonjs/scene";
  12790. /**
  12791. * Defines a runtime animation
  12792. */
  12793. export class RuntimeAnimation {
  12794. private _events;
  12795. /**
  12796. * The current frame of the runtime animation
  12797. */
  12798. private _currentFrame;
  12799. /**
  12800. * The animation used by the runtime animation
  12801. */
  12802. private _animation;
  12803. /**
  12804. * The target of the runtime animation
  12805. */
  12806. private _target;
  12807. /**
  12808. * The initiating animatable
  12809. */
  12810. private _host;
  12811. /**
  12812. * The original value of the runtime animation
  12813. */
  12814. private _originalValue;
  12815. /**
  12816. * The original blend value of the runtime animation
  12817. */
  12818. private _originalBlendValue;
  12819. /**
  12820. * The offsets cache of the runtime animation
  12821. */
  12822. private _offsetsCache;
  12823. /**
  12824. * The high limits cache of the runtime animation
  12825. */
  12826. private _highLimitsCache;
  12827. /**
  12828. * Specifies if the runtime animation has been stopped
  12829. */
  12830. private _stopped;
  12831. /**
  12832. * The blending factor of the runtime animation
  12833. */
  12834. private _blendingFactor;
  12835. /**
  12836. * The BabylonJS scene
  12837. */
  12838. private _scene;
  12839. /**
  12840. * The current value of the runtime animation
  12841. */
  12842. private _currentValue;
  12843. /** @hidden */
  12844. _animationState: _IAnimationState;
  12845. /**
  12846. * The active target of the runtime animation
  12847. */
  12848. private _activeTargets;
  12849. private _currentActiveTarget;
  12850. private _directTarget;
  12851. /**
  12852. * The target path of the runtime animation
  12853. */
  12854. private _targetPath;
  12855. /**
  12856. * The weight of the runtime animation
  12857. */
  12858. private _weight;
  12859. /**
  12860. * The ratio offset of the runtime animation
  12861. */
  12862. private _ratioOffset;
  12863. /**
  12864. * The previous delay of the runtime animation
  12865. */
  12866. private _previousDelay;
  12867. /**
  12868. * The previous ratio of the runtime animation
  12869. */
  12870. private _previousRatio;
  12871. private _enableBlending;
  12872. private _keys;
  12873. private _minFrame;
  12874. private _maxFrame;
  12875. private _minValue;
  12876. private _maxValue;
  12877. private _targetIsArray;
  12878. /**
  12879. * Gets the current frame of the runtime animation
  12880. */
  12881. readonly currentFrame: number;
  12882. /**
  12883. * Gets the weight of the runtime animation
  12884. */
  12885. readonly weight: number;
  12886. /**
  12887. * Gets the current value of the runtime animation
  12888. */
  12889. readonly currentValue: any;
  12890. /**
  12891. * Gets the target path of the runtime animation
  12892. */
  12893. readonly targetPath: string;
  12894. /**
  12895. * Gets the actual target of the runtime animation
  12896. */
  12897. readonly target: any;
  12898. /** @hidden */
  12899. _onLoop: () => void;
  12900. /**
  12901. * Create a new RuntimeAnimation object
  12902. * @param target defines the target of the animation
  12903. * @param animation defines the source animation object
  12904. * @param scene defines the hosting scene
  12905. * @param host defines the initiating Animatable
  12906. */
  12907. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12908. private _preparePath;
  12909. /**
  12910. * Gets the animation from the runtime animation
  12911. */
  12912. readonly animation: Animation;
  12913. /**
  12914. * Resets the runtime animation to the beginning
  12915. * @param restoreOriginal defines whether to restore the target property to the original value
  12916. */
  12917. reset(restoreOriginal?: boolean): void;
  12918. /**
  12919. * Specifies if the runtime animation is stopped
  12920. * @returns Boolean specifying if the runtime animation is stopped
  12921. */
  12922. isStopped(): boolean;
  12923. /**
  12924. * Disposes of the runtime animation
  12925. */
  12926. dispose(): void;
  12927. /**
  12928. * Apply the interpolated value to the target
  12929. * @param currentValue defines the value computed by the animation
  12930. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12931. */
  12932. setValue(currentValue: any, weight: number): void;
  12933. private _getOriginalValues;
  12934. private _setValue;
  12935. /**
  12936. * Gets the loop pmode of the runtime animation
  12937. * @returns Loop Mode
  12938. */
  12939. private _getCorrectLoopMode;
  12940. /**
  12941. * Move the current animation to a given frame
  12942. * @param frame defines the frame to move to
  12943. */
  12944. goToFrame(frame: number): void;
  12945. /**
  12946. * @hidden Internal use only
  12947. */
  12948. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12949. /**
  12950. * Execute the current animation
  12951. * @param delay defines the delay to add to the current frame
  12952. * @param from defines the lower bound of the animation range
  12953. * @param to defines the upper bound of the animation range
  12954. * @param loop defines if the current animation must loop
  12955. * @param speedRatio defines the current speed ratio
  12956. * @param weight defines the weight of the animation (default is -1 so no weight)
  12957. * @param onLoop optional callback called when animation loops
  12958. * @returns a boolean indicating if the animation is running
  12959. */
  12960. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12961. }
  12962. }
  12963. declare module "babylonjs/Animations/animatable" {
  12964. import { Animation } from "babylonjs/Animations/animation";
  12965. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  12966. import { Nullable } from "babylonjs/types";
  12967. import { Observable } from "babylonjs/Misc/observable";
  12968. import { Scene } from "babylonjs/scene";
  12969. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  12970. import { Node } from "babylonjs/node";
  12971. /**
  12972. * Class used to store an actual running animation
  12973. */
  12974. export class Animatable {
  12975. /** defines the target object */
  12976. target: any;
  12977. /** defines the starting frame number (default is 0) */
  12978. fromFrame: number;
  12979. /** defines the ending frame number (default is 100) */
  12980. toFrame: number;
  12981. /** defines if the animation must loop (default is false) */
  12982. loopAnimation: boolean;
  12983. /** defines a callback to call when animation ends if it is not looping */
  12984. onAnimationEnd?: (() => void) | null | undefined;
  12985. /** defines a callback to call when animation loops */
  12986. onAnimationLoop?: (() => void) | null | undefined;
  12987. private _localDelayOffset;
  12988. private _pausedDelay;
  12989. private _runtimeAnimations;
  12990. private _paused;
  12991. private _scene;
  12992. private _speedRatio;
  12993. private _weight;
  12994. private _syncRoot;
  12995. /**
  12996. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12997. * This will only apply for non looping animation (default is true)
  12998. */
  12999. disposeOnEnd: boolean;
  13000. /**
  13001. * Gets a boolean indicating if the animation has started
  13002. */
  13003. animationStarted: boolean;
  13004. /**
  13005. * Observer raised when the animation ends
  13006. */
  13007. onAnimationEndObservable: Observable<Animatable>;
  13008. /**
  13009. * Observer raised when the animation loops
  13010. */
  13011. onAnimationLoopObservable: Observable<Animatable>;
  13012. /**
  13013. * Gets the root Animatable used to synchronize and normalize animations
  13014. */
  13015. readonly syncRoot: Nullable<Animatable>;
  13016. /**
  13017. * Gets the current frame of the first RuntimeAnimation
  13018. * Used to synchronize Animatables
  13019. */
  13020. readonly masterFrame: number;
  13021. /**
  13022. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13023. */
  13024. weight: number;
  13025. /**
  13026. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13027. */
  13028. speedRatio: number;
  13029. /**
  13030. * Creates a new Animatable
  13031. * @param scene defines the hosting scene
  13032. * @param target defines the target object
  13033. * @param fromFrame defines the starting frame number (default is 0)
  13034. * @param toFrame defines the ending frame number (default is 100)
  13035. * @param loopAnimation defines if the animation must loop (default is false)
  13036. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13037. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13038. * @param animations defines a group of animation to add to the new Animatable
  13039. * @param onAnimationLoop defines a callback to call when animation loops
  13040. */
  13041. constructor(scene: Scene,
  13042. /** defines the target object */
  13043. target: any,
  13044. /** defines the starting frame number (default is 0) */
  13045. fromFrame?: number,
  13046. /** defines the ending frame number (default is 100) */
  13047. toFrame?: number,
  13048. /** defines if the animation must loop (default is false) */
  13049. loopAnimation?: boolean, speedRatio?: number,
  13050. /** defines a callback to call when animation ends if it is not looping */
  13051. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13052. /** defines a callback to call when animation loops */
  13053. onAnimationLoop?: (() => void) | null | undefined);
  13054. /**
  13055. * Synchronize and normalize current Animatable with a source Animatable
  13056. * This is useful when using animation weights and when animations are not of the same length
  13057. * @param root defines the root Animatable to synchronize with
  13058. * @returns the current Animatable
  13059. */
  13060. syncWith(root: Animatable): Animatable;
  13061. /**
  13062. * Gets the list of runtime animations
  13063. * @returns an array of RuntimeAnimation
  13064. */
  13065. getAnimations(): RuntimeAnimation[];
  13066. /**
  13067. * Adds more animations to the current animatable
  13068. * @param target defines the target of the animations
  13069. * @param animations defines the new animations to add
  13070. */
  13071. appendAnimations(target: any, animations: Animation[]): void;
  13072. /**
  13073. * Gets the source animation for a specific property
  13074. * @param property defines the propertyu to look for
  13075. * @returns null or the source animation for the given property
  13076. */
  13077. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13078. /**
  13079. * Gets the runtime animation for a specific property
  13080. * @param property defines the propertyu to look for
  13081. * @returns null or the runtime animation for the given property
  13082. */
  13083. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13084. /**
  13085. * Resets the animatable to its original state
  13086. */
  13087. reset(): void;
  13088. /**
  13089. * Allows the animatable to blend with current running animations
  13090. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13091. * @param blendingSpeed defines the blending speed to use
  13092. */
  13093. enableBlending(blendingSpeed: number): void;
  13094. /**
  13095. * Disable animation blending
  13096. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13097. */
  13098. disableBlending(): void;
  13099. /**
  13100. * Jump directly to a given frame
  13101. * @param frame defines the frame to jump to
  13102. */
  13103. goToFrame(frame: number): void;
  13104. /**
  13105. * Pause the animation
  13106. */
  13107. pause(): void;
  13108. /**
  13109. * Restart the animation
  13110. */
  13111. restart(): void;
  13112. private _raiseOnAnimationEnd;
  13113. /**
  13114. * Stop and delete the current animation
  13115. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13116. * @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)
  13117. */
  13118. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13119. /**
  13120. * Wait asynchronously for the animation to end
  13121. * @returns a promise which will be fullfilled when the animation ends
  13122. */
  13123. waitAsync(): Promise<Animatable>;
  13124. /** @hidden */
  13125. _animate(delay: number): boolean;
  13126. }
  13127. module "babylonjs/scene" {
  13128. interface Scene {
  13129. /** @hidden */
  13130. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13131. /** @hidden */
  13132. _processLateAnimationBindingsForMatrices(holder: {
  13133. totalWeight: number;
  13134. animations: RuntimeAnimation[];
  13135. originalValue: Matrix;
  13136. }): any;
  13137. /** @hidden */
  13138. _processLateAnimationBindingsForQuaternions(holder: {
  13139. totalWeight: number;
  13140. animations: RuntimeAnimation[];
  13141. originalValue: Quaternion;
  13142. }, refQuaternion: Quaternion): Quaternion;
  13143. /** @hidden */
  13144. _processLateAnimationBindings(): void;
  13145. /**
  13146. * Will start the animation sequence of a given target
  13147. * @param target defines the target
  13148. * @param from defines from which frame should animation start
  13149. * @param to defines until which frame should animation run.
  13150. * @param weight defines the weight to apply to the animation (1.0 by default)
  13151. * @param loop defines if the animation loops
  13152. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13153. * @param onAnimationEnd defines the function to be executed when the animation ends
  13154. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13155. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13156. * @param onAnimationLoop defines the callback to call when an animation loops
  13157. * @returns the animatable object created for this animation
  13158. */
  13159. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13160. /**
  13161. * Will start the animation sequence of a given target
  13162. * @param target defines the target
  13163. * @param from defines from which frame should animation start
  13164. * @param to defines until which frame should animation run.
  13165. * @param loop defines if the animation loops
  13166. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13167. * @param onAnimationEnd defines the function to be executed when the animation ends
  13168. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13169. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13170. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13171. * @param onAnimationLoop defines the callback to call when an animation loops
  13172. * @returns the animatable object created for this animation
  13173. */
  13174. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13175. /**
  13176. * Will start the animation sequence of a given target and its hierarchy
  13177. * @param target defines the target
  13178. * @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.
  13179. * @param from defines from which frame should animation start
  13180. * @param to defines until which frame should animation run.
  13181. * @param loop defines if the animation loops
  13182. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13183. * @param onAnimationEnd defines the function to be executed when the animation ends
  13184. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13185. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13186. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13187. * @param onAnimationLoop defines the callback to call when an animation loops
  13188. * @returns the list of created animatables
  13189. */
  13190. 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[];
  13191. /**
  13192. * Begin a new animation on a given node
  13193. * @param target defines the target where the animation will take place
  13194. * @param animations defines the list of animations to start
  13195. * @param from defines the initial value
  13196. * @param to defines the final value
  13197. * @param loop defines if you want animation to loop (off by default)
  13198. * @param speedRatio defines the speed ratio to apply to all animations
  13199. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13200. * @param onAnimationLoop defines the callback to call when an animation loops
  13201. * @returns the list of created animatables
  13202. */
  13203. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13204. /**
  13205. * Begin a new animation on a given node and its hierarchy
  13206. * @param target defines the root node where the animation will take place
  13207. * @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.
  13208. * @param animations defines the list of animations to start
  13209. * @param from defines the initial value
  13210. * @param to defines the final value
  13211. * @param loop defines if you want animation to loop (off by default)
  13212. * @param speedRatio defines the speed ratio to apply to all animations
  13213. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13214. * @param onAnimationLoop defines the callback to call when an animation loops
  13215. * @returns the list of animatables created for all nodes
  13216. */
  13217. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13218. /**
  13219. * Gets the animatable associated with a specific target
  13220. * @param target defines the target of the animatable
  13221. * @returns the required animatable if found
  13222. */
  13223. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13224. /**
  13225. * Gets all animatables associated with a given target
  13226. * @param target defines the target to look animatables for
  13227. * @returns an array of Animatables
  13228. */
  13229. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13230. /**
  13231. * Stops and removes all animations that have been applied to the scene
  13232. */
  13233. stopAllAnimations(): void;
  13234. }
  13235. }
  13236. module "babylonjs/Bones/bone" {
  13237. interface Bone {
  13238. /**
  13239. * Copy an animation range from another bone
  13240. * @param source defines the source bone
  13241. * @param rangeName defines the range name to copy
  13242. * @param frameOffset defines the frame offset
  13243. * @param rescaleAsRequired defines if rescaling must be applied if required
  13244. * @param skelDimensionsRatio defines the scaling ratio
  13245. * @returns true if operation was successful
  13246. */
  13247. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13248. }
  13249. }
  13250. }
  13251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13252. /**
  13253. * Class used to override all child animations of a given target
  13254. */
  13255. export class AnimationPropertiesOverride {
  13256. /**
  13257. * Gets or sets a value indicating if animation blending must be used
  13258. */
  13259. enableBlending: boolean;
  13260. /**
  13261. * Gets or sets the blending speed to use when enableBlending is true
  13262. */
  13263. blendingSpeed: number;
  13264. /**
  13265. * Gets or sets the default loop mode to use
  13266. */
  13267. loopMode: number;
  13268. }
  13269. }
  13270. declare module "babylonjs/Bones/skeleton" {
  13271. import { Bone } from "babylonjs/Bones/bone";
  13272. import { Observable } from "babylonjs/Misc/observable";
  13273. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13274. import { Scene } from "babylonjs/scene";
  13275. import { Nullable } from "babylonjs/types";
  13276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13277. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13278. import { Animatable } from "babylonjs/Animations/animatable";
  13279. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13280. import { Animation } from "babylonjs/Animations/animation";
  13281. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13282. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13283. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13284. /**
  13285. * Class used to handle skinning animations
  13286. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13287. */
  13288. export class Skeleton implements IAnimatable {
  13289. /** defines the skeleton name */
  13290. name: string;
  13291. /** defines the skeleton Id */
  13292. id: string;
  13293. /**
  13294. * Defines the list of child bones
  13295. */
  13296. bones: Bone[];
  13297. /**
  13298. * Defines an estimate of the dimension of the skeleton at rest
  13299. */
  13300. dimensionsAtRest: Vector3;
  13301. /**
  13302. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13303. */
  13304. needInitialSkinMatrix: boolean;
  13305. /**
  13306. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13307. */
  13308. overrideMesh: Nullable<AbstractMesh>;
  13309. /**
  13310. * Gets the list of animations attached to this skeleton
  13311. */
  13312. animations: Array<Animation>;
  13313. private _scene;
  13314. private _isDirty;
  13315. private _transformMatrices;
  13316. private _transformMatrixTexture;
  13317. private _meshesWithPoseMatrix;
  13318. private _animatables;
  13319. private _identity;
  13320. private _synchronizedWithMesh;
  13321. private _ranges;
  13322. private _lastAbsoluteTransformsUpdateId;
  13323. private _canUseTextureForBones;
  13324. private _uniqueId;
  13325. /** @hidden */
  13326. _numBonesWithLinkedTransformNode: number;
  13327. /** @hidden */
  13328. _hasWaitingData: Nullable<boolean>;
  13329. /**
  13330. * Specifies if the skeleton should be serialized
  13331. */
  13332. doNotSerialize: boolean;
  13333. private _useTextureToStoreBoneMatrices;
  13334. /**
  13335. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13336. * Please note that this option is not available if the hardware does not support it
  13337. */
  13338. useTextureToStoreBoneMatrices: boolean;
  13339. private _animationPropertiesOverride;
  13340. /**
  13341. * Gets or sets the animation properties override
  13342. */
  13343. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13344. /**
  13345. * List of inspectable custom properties (used by the Inspector)
  13346. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13347. */
  13348. inspectableCustomProperties: IInspectable[];
  13349. /**
  13350. * An observable triggered before computing the skeleton's matrices
  13351. */
  13352. onBeforeComputeObservable: Observable<Skeleton>;
  13353. /**
  13354. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13355. */
  13356. readonly isUsingTextureForMatrices: boolean;
  13357. /**
  13358. * Gets the unique ID of this skeleton
  13359. */
  13360. readonly uniqueId: number;
  13361. /**
  13362. * Creates a new skeleton
  13363. * @param name defines the skeleton name
  13364. * @param id defines the skeleton Id
  13365. * @param scene defines the hosting scene
  13366. */
  13367. constructor(
  13368. /** defines the skeleton name */
  13369. name: string,
  13370. /** defines the skeleton Id */
  13371. id: string, scene: Scene);
  13372. /**
  13373. * Gets the current object class name.
  13374. * @return the class name
  13375. */
  13376. getClassName(): string;
  13377. /**
  13378. * Returns an array containing the root bones
  13379. * @returns an array containing the root bones
  13380. */
  13381. getChildren(): Array<Bone>;
  13382. /**
  13383. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13384. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13385. * @returns a Float32Array containing matrices data
  13386. */
  13387. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13388. /**
  13389. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13390. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13391. * @returns a raw texture containing the data
  13392. */
  13393. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13394. /**
  13395. * Gets the current hosting scene
  13396. * @returns a scene object
  13397. */
  13398. getScene(): Scene;
  13399. /**
  13400. * Gets a string representing the current skeleton data
  13401. * @param fullDetails defines a boolean indicating if we want a verbose version
  13402. * @returns a string representing the current skeleton data
  13403. */
  13404. toString(fullDetails?: boolean): string;
  13405. /**
  13406. * Get bone's index searching by name
  13407. * @param name defines bone's name to search for
  13408. * @return the indice of the bone. Returns -1 if not found
  13409. */
  13410. getBoneIndexByName(name: string): number;
  13411. /**
  13412. * Creater a new animation range
  13413. * @param name defines the name of the range
  13414. * @param from defines the start key
  13415. * @param to defines the end key
  13416. */
  13417. createAnimationRange(name: string, from: number, to: number): void;
  13418. /**
  13419. * Delete a specific animation range
  13420. * @param name defines the name of the range
  13421. * @param deleteFrames defines if frames must be removed as well
  13422. */
  13423. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13424. /**
  13425. * Gets a specific animation range
  13426. * @param name defines the name of the range to look for
  13427. * @returns the requested animation range or null if not found
  13428. */
  13429. getAnimationRange(name: string): Nullable<AnimationRange>;
  13430. /**
  13431. * Gets the list of all animation ranges defined on this skeleton
  13432. * @returns an array
  13433. */
  13434. getAnimationRanges(): Nullable<AnimationRange>[];
  13435. /**
  13436. * Copy animation range from a source skeleton.
  13437. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13438. * @param source defines the source skeleton
  13439. * @param name defines the name of the range to copy
  13440. * @param rescaleAsRequired defines if rescaling must be applied if required
  13441. * @returns true if operation was successful
  13442. */
  13443. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13444. /**
  13445. * Forces the skeleton to go to rest pose
  13446. */
  13447. returnToRest(): void;
  13448. private _getHighestAnimationFrame;
  13449. /**
  13450. * Begin a specific animation range
  13451. * @param name defines the name of the range to start
  13452. * @param loop defines if looping must be turned on (false by default)
  13453. * @param speedRatio defines the speed ratio to apply (1 by default)
  13454. * @param onAnimationEnd defines a callback which will be called when animation will end
  13455. * @returns a new animatable
  13456. */
  13457. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13458. /** @hidden */
  13459. _markAsDirty(): void;
  13460. /** @hidden */
  13461. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13462. /** @hidden */
  13463. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13464. private _computeTransformMatrices;
  13465. /**
  13466. * Build all resources required to render a skeleton
  13467. */
  13468. prepare(): void;
  13469. /**
  13470. * Gets the list of animatables currently running for this skeleton
  13471. * @returns an array of animatables
  13472. */
  13473. getAnimatables(): IAnimatable[];
  13474. /**
  13475. * Clone the current skeleton
  13476. * @param name defines the name of the new skeleton
  13477. * @param id defines the id of the new skeleton
  13478. * @returns the new skeleton
  13479. */
  13480. clone(name: string, id: string): Skeleton;
  13481. /**
  13482. * Enable animation blending for this skeleton
  13483. * @param blendingSpeed defines the blending speed to apply
  13484. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13485. */
  13486. enableBlending(blendingSpeed?: number): void;
  13487. /**
  13488. * Releases all resources associated with the current skeleton
  13489. */
  13490. dispose(): void;
  13491. /**
  13492. * Serialize the skeleton in a JSON object
  13493. * @returns a JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Creates a new skeleton from serialized data
  13498. * @param parsedSkeleton defines the serialized data
  13499. * @param scene defines the hosting scene
  13500. * @returns a new skeleton
  13501. */
  13502. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13503. /**
  13504. * Compute all node absolute transforms
  13505. * @param forceUpdate defines if computation must be done even if cache is up to date
  13506. */
  13507. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13508. /**
  13509. * Gets the root pose matrix
  13510. * @returns a matrix
  13511. */
  13512. getPoseMatrix(): Nullable<Matrix>;
  13513. /**
  13514. * Sorts bones per internal index
  13515. */
  13516. sortBones(): void;
  13517. private _sortBones;
  13518. }
  13519. }
  13520. declare module "babylonjs/Bones/bone" {
  13521. import { Skeleton } from "babylonjs/Bones/skeleton";
  13522. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13523. import { Nullable } from "babylonjs/types";
  13524. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13525. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13526. import { Node } from "babylonjs/node";
  13527. import { Space } from "babylonjs/Maths/math.axis";
  13528. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13529. /**
  13530. * Class used to store bone information
  13531. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13532. */
  13533. export class Bone extends Node {
  13534. /**
  13535. * defines the bone name
  13536. */
  13537. name: string;
  13538. private static _tmpVecs;
  13539. private static _tmpQuat;
  13540. private static _tmpMats;
  13541. /**
  13542. * Gets the list of child bones
  13543. */
  13544. children: Bone[];
  13545. /** Gets the animations associated with this bone */
  13546. animations: import("babylonjs/Animations/animation").Animation[];
  13547. /**
  13548. * Gets or sets bone length
  13549. */
  13550. length: number;
  13551. /**
  13552. * @hidden Internal only
  13553. * Set this value to map this bone to a different index in the transform matrices
  13554. * Set this value to -1 to exclude the bone from the transform matrices
  13555. */
  13556. _index: Nullable<number>;
  13557. private _skeleton;
  13558. private _localMatrix;
  13559. private _restPose;
  13560. private _baseMatrix;
  13561. private _absoluteTransform;
  13562. private _invertedAbsoluteTransform;
  13563. private _parent;
  13564. private _scalingDeterminant;
  13565. private _worldTransform;
  13566. private _localScaling;
  13567. private _localRotation;
  13568. private _localPosition;
  13569. private _needToDecompose;
  13570. private _needToCompose;
  13571. /** @hidden */
  13572. _linkedTransformNode: Nullable<TransformNode>;
  13573. /** @hidden */
  13574. _waitingTransformNodeId: Nullable<string>;
  13575. /** @hidden */
  13576. /** @hidden */
  13577. _matrix: Matrix;
  13578. /**
  13579. * Create a new bone
  13580. * @param name defines the bone name
  13581. * @param skeleton defines the parent skeleton
  13582. * @param parentBone defines the parent (can be null if the bone is the root)
  13583. * @param localMatrix defines the local matrix
  13584. * @param restPose defines the rest pose matrix
  13585. * @param baseMatrix defines the base matrix
  13586. * @param index defines index of the bone in the hiearchy
  13587. */
  13588. constructor(
  13589. /**
  13590. * defines the bone name
  13591. */
  13592. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13593. /**
  13594. * Gets the current object class name.
  13595. * @return the class name
  13596. */
  13597. getClassName(): string;
  13598. /**
  13599. * Gets the parent skeleton
  13600. * @returns a skeleton
  13601. */
  13602. getSkeleton(): Skeleton;
  13603. /**
  13604. * Gets parent bone
  13605. * @returns a bone or null if the bone is the root of the bone hierarchy
  13606. */
  13607. getParent(): Nullable<Bone>;
  13608. /**
  13609. * Returns an array containing the root bones
  13610. * @returns an array containing the root bones
  13611. */
  13612. getChildren(): Array<Bone>;
  13613. /**
  13614. * Sets the parent bone
  13615. * @param parent defines the parent (can be null if the bone is the root)
  13616. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13617. */
  13618. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13619. /**
  13620. * Gets the local matrix
  13621. * @returns a matrix
  13622. */
  13623. getLocalMatrix(): Matrix;
  13624. /**
  13625. * Gets the base matrix (initial matrix which remains unchanged)
  13626. * @returns a matrix
  13627. */
  13628. getBaseMatrix(): Matrix;
  13629. /**
  13630. * Gets the rest pose matrix
  13631. * @returns a matrix
  13632. */
  13633. getRestPose(): Matrix;
  13634. /**
  13635. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13636. */
  13637. getWorldMatrix(): Matrix;
  13638. /**
  13639. * Sets the local matrix to rest pose matrix
  13640. */
  13641. returnToRest(): void;
  13642. /**
  13643. * Gets the inverse of the absolute transform matrix.
  13644. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13645. * @returns a matrix
  13646. */
  13647. getInvertedAbsoluteTransform(): Matrix;
  13648. /**
  13649. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13650. * @returns a matrix
  13651. */
  13652. getAbsoluteTransform(): Matrix;
  13653. /**
  13654. * Links with the given transform node.
  13655. * The local matrix of this bone is copied from the transform node every frame.
  13656. * @param transformNode defines the transform node to link to
  13657. */
  13658. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13659. /**
  13660. * Gets the node used to drive the bone's transformation
  13661. * @returns a transform node or null
  13662. */
  13663. getTransformNode(): Nullable<TransformNode>;
  13664. /** Gets or sets current position (in local space) */
  13665. position: Vector3;
  13666. /** Gets or sets current rotation (in local space) */
  13667. rotation: Vector3;
  13668. /** Gets or sets current rotation quaternion (in local space) */
  13669. rotationQuaternion: Quaternion;
  13670. /** Gets or sets current scaling (in local space) */
  13671. scaling: Vector3;
  13672. /**
  13673. * Gets the animation properties override
  13674. */
  13675. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13676. private _decompose;
  13677. private _compose;
  13678. /**
  13679. * Update the base and local matrices
  13680. * @param matrix defines the new base or local matrix
  13681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13682. * @param updateLocalMatrix defines if the local matrix should be updated
  13683. */
  13684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13685. /** @hidden */
  13686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13687. /**
  13688. * Flag the bone as dirty (Forcing it to update everything)
  13689. */
  13690. markAsDirty(): void;
  13691. /** @hidden */
  13692. _markAsDirtyAndCompose(): void;
  13693. private _markAsDirtyAndDecompose;
  13694. /**
  13695. * Translate the bone in local or world space
  13696. * @param vec The amount to translate the bone
  13697. * @param space The space that the translation is in
  13698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13699. */
  13700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13701. /**
  13702. * Set the postion of the bone in local or world space
  13703. * @param position The position to set the bone
  13704. * @param space The space that the position is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the absolute position of the bone (world space)
  13710. * @param position The position to set the bone
  13711. * @param mesh The mesh that this bone is attached to
  13712. */
  13713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Scale the bone on the x, y and z axes (in local space)
  13716. * @param x The amount to scale the bone on the x axis
  13717. * @param y The amount to scale the bone on the y axis
  13718. * @param z The amount to scale the bone on the z axis
  13719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13720. */
  13721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13722. /**
  13723. * Set the bone scaling in local space
  13724. * @param scale defines the scaling vector
  13725. */
  13726. setScale(scale: Vector3): void;
  13727. /**
  13728. * Gets the current scaling in local space
  13729. * @returns the current scaling vector
  13730. */
  13731. getScale(): Vector3;
  13732. /**
  13733. * Gets the current scaling in local space and stores it in a target vector
  13734. * @param result defines the target vector
  13735. */
  13736. getScaleToRef(result: Vector3): void;
  13737. /**
  13738. * Set the yaw, pitch, and roll of the bone in local or world space
  13739. * @param yaw The rotation of the bone on the y axis
  13740. * @param pitch The rotation of the bone on the x axis
  13741. * @param roll The rotation of the bone on the z axis
  13742. * @param space The space that the axes of rotation are in
  13743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13744. */
  13745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13746. /**
  13747. * Add a rotation to the bone on an axis in local or world space
  13748. * @param axis The axis to rotate the bone on
  13749. * @param amount The amount to rotate the bone
  13750. * @param space The space that the axis is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the rotation of the bone to a particular axis angle in local or world space
  13756. * @param axis The axis to rotate the bone on
  13757. * @param angle The angle that the bone should be rotated to
  13758. * @param space The space that the axis is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the euler rotation of the bone in local of world space
  13764. * @param rotation The euler rotation that the bone should be set to
  13765. * @param space The space that the rotation is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the quaternion rotation of the bone in local of world space
  13771. * @param quat The quaternion rotation that the bone should be set to
  13772. * @param space The space that the rotation is in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. */
  13775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Set the rotation matrix of the bone in local of world space
  13778. * @param rotMat The rotation matrix that the bone should be set to
  13779. * @param space The space that the rotation is in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. */
  13782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13783. private _rotateWithMatrix;
  13784. private _getNegativeRotationToRef;
  13785. /**
  13786. * Get the position of the bone in local or world space
  13787. * @param space The space that the returned position is in
  13788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13789. * @returns The position of the bone
  13790. */
  13791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13792. /**
  13793. * Copy the position of the bone to a vector3 in local or world space
  13794. * @param space The space that the returned position is in
  13795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13796. * @param result The vector3 to copy the position to
  13797. */
  13798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13799. /**
  13800. * Get the absolute position of the bone (world space)
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The absolute position of the bone
  13803. */
  13804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Copy the absolute position of the bone (world space) to the result param
  13807. * @param mesh The mesh that this bone is attached to
  13808. * @param result The vector3 to copy the absolute position to
  13809. */
  13810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13811. /**
  13812. * Compute the absolute transforms of this bone and its children
  13813. */
  13814. computeAbsoluteTransforms(): void;
  13815. /**
  13816. * Get the world direction from an axis that is in the local space of the bone
  13817. * @param localAxis The local direction that is used to compute the world direction
  13818. * @param mesh The mesh that this bone is attached to
  13819. * @returns The world direction
  13820. */
  13821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13822. /**
  13823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13824. * @param localAxis The local direction that is used to compute the world direction
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @param result The vector3 that the world direction will be copied to
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13829. /**
  13830. * Get the euler rotation of the bone in local or world space
  13831. * @param space The space that the rotation should be in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. * @returns The euler rotation
  13834. */
  13835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13836. /**
  13837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13838. * @param space The space that the rotation should be in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. * @param result The vector3 that the rotation should be copied to
  13841. */
  13842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13843. /**
  13844. * Get the quaternion rotation of the bone in either local or world space
  13845. * @param space The space that the rotation should be in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The quaternion rotation
  13848. */
  13849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13850. /**
  13851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13852. * @param space The space that the rotation should be in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The quaternion that the rotation should be copied to
  13855. */
  13856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13857. /**
  13858. * Get the rotation matrix of the bone in local or world space
  13859. * @param space The space that the rotation should be in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. * @returns The rotation matrix
  13862. */
  13863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13864. /**
  13865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13866. * @param space The space that the rotation should be in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. * @param result The quaternion that the rotation should be copied to
  13869. */
  13870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13871. /**
  13872. * Get the world position of a point that is in the local space of the bone
  13873. * @param position The local position
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The world position
  13876. */
  13877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13880. * @param position The local position
  13881. * @param mesh The mesh that this bone is attached to
  13882. * @param result The vector3 that the world position should be copied to
  13883. */
  13884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13885. /**
  13886. * Get the local position of a point that is in world space
  13887. * @param position The world position
  13888. * @param mesh The mesh that this bone is attached to
  13889. * @returns The local position
  13890. */
  13891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13892. /**
  13893. * Get the local position of a point that is in world space and copy it to the result param
  13894. * @param position The world position
  13895. * @param mesh The mesh that this bone is attached to
  13896. * @param result The vector3 that the local position should be copied to
  13897. */
  13898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13899. }
  13900. }
  13901. declare module "babylonjs/Meshes/transformNode" {
  13902. import { DeepImmutable } from "babylonjs/types";
  13903. import { Observable } from "babylonjs/Misc/observable";
  13904. import { Nullable } from "babylonjs/types";
  13905. import { Camera } from "babylonjs/Cameras/camera";
  13906. import { Scene } from "babylonjs/scene";
  13907. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13908. import { Node } from "babylonjs/node";
  13909. import { Bone } from "babylonjs/Bones/bone";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. import { Space } from "babylonjs/Maths/math.axis";
  13912. /**
  13913. * 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.
  13914. * @see https://doc.babylonjs.com/how_to/transformnode
  13915. */
  13916. export class TransformNode extends Node {
  13917. /**
  13918. * Object will not rotate to face the camera
  13919. */
  13920. static BILLBOARDMODE_NONE: number;
  13921. /**
  13922. * Object will rotate to face the camera but only on the x axis
  13923. */
  13924. static BILLBOARDMODE_X: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the y axis
  13927. */
  13928. static BILLBOARDMODE_Y: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the z axis
  13931. */
  13932. static BILLBOARDMODE_Z: number;
  13933. /**
  13934. * Object will rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_ALL: number;
  13937. private _forward;
  13938. private _forwardInverted;
  13939. private _up;
  13940. private _right;
  13941. private _rightInverted;
  13942. private _position;
  13943. private _rotation;
  13944. private _rotationQuaternion;
  13945. protected _scaling: Vector3;
  13946. protected _isDirty: boolean;
  13947. private _transformToBoneReferal;
  13948. private _isAbsoluteSynced;
  13949. private _billboardMode;
  13950. /**
  13951. * Gets or sets the billboard mode. Default is 0.
  13952. *
  13953. * | Value | Type | Description |
  13954. * | --- | --- | --- |
  13955. * | 0 | BILLBOARDMODE_NONE | |
  13956. * | 1 | BILLBOARDMODE_X | |
  13957. * | 2 | BILLBOARDMODE_Y | |
  13958. * | 4 | BILLBOARDMODE_Z | |
  13959. * | 7 | BILLBOARDMODE_ALL | |
  13960. *
  13961. */
  13962. billboardMode: number;
  13963. private _preserveParentRotationForBillboard;
  13964. /**
  13965. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13966. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13967. */
  13968. preserveParentRotationForBillboard: boolean;
  13969. /**
  13970. * 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
  13971. */
  13972. scalingDeterminant: number;
  13973. private _infiniteDistance;
  13974. /**
  13975. * Gets or sets the distance of the object to max, often used by skybox
  13976. */
  13977. infiniteDistance: boolean;
  13978. /**
  13979. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13980. * By default the system will update normals to compensate
  13981. */
  13982. ignoreNonUniformScaling: boolean;
  13983. /**
  13984. * 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
  13985. */
  13986. reIntegrateRotationIntoRotationQuaternion: boolean;
  13987. /** @hidden */
  13988. _poseMatrix: Nullable<Matrix>;
  13989. /** @hidden */
  13990. _localMatrix: Matrix;
  13991. private _usePivotMatrix;
  13992. private _absolutePosition;
  13993. private _absoluteScaling;
  13994. private _absoluteRotationQuaternion;
  13995. private _pivotMatrix;
  13996. private _pivotMatrixInverse;
  13997. protected _postMultiplyPivotMatrix: boolean;
  13998. protected _isWorldMatrixFrozen: boolean;
  13999. /** @hidden */
  14000. _indexInSceneTransformNodesArray: number;
  14001. /**
  14002. * An event triggered after the world matrix is updated
  14003. */
  14004. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14005. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14006. /**
  14007. * Gets a string identifying the name of the class
  14008. * @returns "TransformNode" string
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14013. */
  14014. position: Vector3;
  14015. /**
  14016. * 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)).
  14017. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14018. */
  14019. rotation: Vector3;
  14020. /**
  14021. * 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)).
  14022. */
  14023. scaling: Vector3;
  14024. /**
  14025. * 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).
  14026. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14027. */
  14028. rotationQuaternion: Nullable<Quaternion>;
  14029. /**
  14030. * The forward direction of that transform in world space.
  14031. */
  14032. readonly forward: Vector3;
  14033. /**
  14034. * The up direction of that transform in world space.
  14035. */
  14036. readonly up: Vector3;
  14037. /**
  14038. * The right direction of that transform in world space.
  14039. */
  14040. readonly right: Vector3;
  14041. /**
  14042. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14043. * @param matrix the matrix to copy the pose from
  14044. * @returns this TransformNode.
  14045. */
  14046. updatePoseMatrix(matrix: Matrix): TransformNode;
  14047. /**
  14048. * Returns the mesh Pose matrix.
  14049. * @returns the pose matrix
  14050. */
  14051. getPoseMatrix(): Matrix;
  14052. /** @hidden */
  14053. _isSynchronized(): boolean;
  14054. /** @hidden */
  14055. _initCache(): void;
  14056. /**
  14057. * Flag the transform node as dirty (Forcing it to update everything)
  14058. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14059. * @returns this transform node
  14060. */
  14061. markAsDirty(property: string): TransformNode;
  14062. /**
  14063. * Returns the current mesh absolute position.
  14064. * Returns a Vector3.
  14065. */
  14066. readonly absolutePosition: Vector3;
  14067. /**
  14068. * Returns the current mesh absolute scaling.
  14069. * Returns a Vector3.
  14070. */
  14071. readonly absoluteScaling: Vector3;
  14072. /**
  14073. * Returns the current mesh absolute rotation.
  14074. * Returns a Quaternion.
  14075. */
  14076. readonly absoluteRotationQuaternion: Quaternion;
  14077. /**
  14078. * Sets a new matrix to apply before all other transformation
  14079. * @param matrix defines the transform matrix
  14080. * @returns the current TransformNode
  14081. */
  14082. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14083. /**
  14084. * Sets a new pivot matrix to the current node
  14085. * @param matrix defines the new pivot matrix to use
  14086. * @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
  14087. * @returns the current TransformNode
  14088. */
  14089. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14090. /**
  14091. * Returns the mesh pivot matrix.
  14092. * Default : Identity.
  14093. * @returns the matrix
  14094. */
  14095. getPivotMatrix(): Matrix;
  14096. /**
  14097. * Prevents the World matrix to be computed any longer.
  14098. * @returns the TransformNode.
  14099. */
  14100. freezeWorldMatrix(): TransformNode;
  14101. /**
  14102. * Allows back the World matrix computation.
  14103. * @returns the TransformNode.
  14104. */
  14105. unfreezeWorldMatrix(): this;
  14106. /**
  14107. * True if the World matrix has been frozen.
  14108. */
  14109. readonly isWorldMatrixFrozen: boolean;
  14110. /**
  14111. * Retuns the mesh absolute position in the World.
  14112. * @returns a Vector3.
  14113. */
  14114. getAbsolutePosition(): Vector3;
  14115. /**
  14116. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14117. * @param absolutePosition the absolute position to set
  14118. * @returns the TransformNode.
  14119. */
  14120. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14121. /**
  14122. * Sets the mesh position in its local space.
  14123. * @param vector3 the position to set in localspace
  14124. * @returns the TransformNode.
  14125. */
  14126. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14127. /**
  14128. * Returns the mesh position in the local space from the current World matrix values.
  14129. * @returns a new Vector3.
  14130. */
  14131. getPositionExpressedInLocalSpace(): Vector3;
  14132. /**
  14133. * Translates the mesh along the passed Vector3 in its local space.
  14134. * @param vector3 the distance to translate in localspace
  14135. * @returns the TransformNode.
  14136. */
  14137. locallyTranslate(vector3: Vector3): TransformNode;
  14138. private static _lookAtVectorCache;
  14139. /**
  14140. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14141. * @param targetPoint the position (must be in same space as current mesh) to look at
  14142. * @param yawCor optional yaw (y-axis) correction in radians
  14143. * @param pitchCor optional pitch (x-axis) correction in radians
  14144. * @param rollCor optional roll (z-axis) correction in radians
  14145. * @param space the choosen space of the target
  14146. * @returns the TransformNode.
  14147. */
  14148. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14149. /**
  14150. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14151. * This Vector3 is expressed in the World space.
  14152. * @param localAxis axis to rotate
  14153. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14154. */
  14155. getDirection(localAxis: Vector3): Vector3;
  14156. /**
  14157. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14158. * localAxis is expressed in the mesh local space.
  14159. * result is computed in the Wordl space from the mesh World matrix.
  14160. * @param localAxis axis to rotate
  14161. * @param result the resulting transformnode
  14162. * @returns this TransformNode.
  14163. */
  14164. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14165. /**
  14166. * Sets this transform node rotation to the given local axis.
  14167. * @param localAxis the axis in local space
  14168. * @param yawCor optional yaw (y-axis) correction in radians
  14169. * @param pitchCor optional pitch (x-axis) correction in radians
  14170. * @param rollCor optional roll (z-axis) correction in radians
  14171. * @returns this TransformNode
  14172. */
  14173. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14174. /**
  14175. * Sets a new pivot point to the current node
  14176. * @param point defines the new pivot point to use
  14177. * @param space defines if the point is in world or local space (local by default)
  14178. * @returns the current TransformNode
  14179. */
  14180. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14181. /**
  14182. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14183. * @returns the pivot point
  14184. */
  14185. getPivotPoint(): Vector3;
  14186. /**
  14187. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14188. * @param result the vector3 to store the result
  14189. * @returns this TransformNode.
  14190. */
  14191. getPivotPointToRef(result: Vector3): TransformNode;
  14192. /**
  14193. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14194. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14195. */
  14196. getAbsolutePivotPoint(): Vector3;
  14197. /**
  14198. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14199. * @param result vector3 to store the result
  14200. * @returns this TransformNode.
  14201. */
  14202. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14203. /**
  14204. * Defines the passed node as the parent of the current node.
  14205. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14206. * @see https://doc.babylonjs.com/how_to/parenting
  14207. * @param node the node ot set as the parent
  14208. * @returns this TransformNode.
  14209. */
  14210. setParent(node: Nullable<Node>): TransformNode;
  14211. private _nonUniformScaling;
  14212. /**
  14213. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14214. */
  14215. readonly nonUniformScaling: boolean;
  14216. /** @hidden */
  14217. _updateNonUniformScalingState(value: boolean): boolean;
  14218. /**
  14219. * Attach the current TransformNode to another TransformNode associated with a bone
  14220. * @param bone Bone affecting the TransformNode
  14221. * @param affectedTransformNode TransformNode associated with the bone
  14222. * @returns this object
  14223. */
  14224. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14225. /**
  14226. * Detach the transform node if its associated with a bone
  14227. * @returns this object
  14228. */
  14229. detachFromBone(): TransformNode;
  14230. private static _rotationAxisCache;
  14231. /**
  14232. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14233. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14234. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14235. * The passed axis is also normalized.
  14236. * @param axis the axis to rotate around
  14237. * @param amount the amount to rotate in radians
  14238. * @param space Space to rotate in (Default: local)
  14239. * @returns the TransformNode.
  14240. */
  14241. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14242. /**
  14243. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14244. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14245. * The passed axis is also normalized. .
  14246. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14247. * @param point the point to rotate around
  14248. * @param axis the axis to rotate around
  14249. * @param amount the amount to rotate in radians
  14250. * @returns the TransformNode
  14251. */
  14252. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14253. /**
  14254. * Translates the mesh along the axis vector for the passed distance in the given space.
  14255. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14256. * @param axis the axis to translate in
  14257. * @param distance the distance to translate
  14258. * @param space Space to rotate in (Default: local)
  14259. * @returns the TransformNode.
  14260. */
  14261. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14262. /**
  14263. * Adds a rotation step to the mesh current rotation.
  14264. * x, y, z are Euler angles expressed in radians.
  14265. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14266. * This means this rotation is made in the mesh local space only.
  14267. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14268. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14269. * ```javascript
  14270. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14271. * ```
  14272. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14273. * 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.
  14274. * @param x Rotation to add
  14275. * @param y Rotation to add
  14276. * @param z Rotation to add
  14277. * @returns the TransformNode.
  14278. */
  14279. addRotation(x: number, y: number, z: number): TransformNode;
  14280. /**
  14281. * @hidden
  14282. */
  14283. protected _getEffectiveParent(): Nullable<Node>;
  14284. /**
  14285. * Computes the world matrix of the node
  14286. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14287. * @returns the world matrix
  14288. */
  14289. computeWorldMatrix(force?: boolean): Matrix;
  14290. protected _afterComputeWorldMatrix(): void;
  14291. /**
  14292. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14293. * @param func callback function to add
  14294. *
  14295. * @returns the TransformNode.
  14296. */
  14297. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14298. /**
  14299. * Removes a registered callback function.
  14300. * @param func callback function to remove
  14301. * @returns the TransformNode.
  14302. */
  14303. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14304. /**
  14305. * Gets the position of the current mesh in camera space
  14306. * @param camera defines the camera to use
  14307. * @returns a position
  14308. */
  14309. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14310. /**
  14311. * Returns the distance from the mesh to the active camera
  14312. * @param camera defines the camera to use
  14313. * @returns the distance
  14314. */
  14315. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14316. /**
  14317. * Clone the current transform node
  14318. * @param name Name of the new clone
  14319. * @param newParent New parent for the clone
  14320. * @param doNotCloneChildren Do not clone children hierarchy
  14321. * @returns the new transform node
  14322. */
  14323. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14324. /**
  14325. * Serializes the objects information.
  14326. * @param currentSerializationObject defines the object to serialize in
  14327. * @returns the serialized object
  14328. */
  14329. serialize(currentSerializationObject?: any): any;
  14330. /**
  14331. * Returns a new TransformNode object parsed from the source provided.
  14332. * @param parsedTransformNode is the source.
  14333. * @param scene the scne the object belongs to
  14334. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14335. * @returns a new TransformNode object parsed from the source provided.
  14336. */
  14337. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14338. /**
  14339. * Get all child-transformNodes of this node
  14340. * @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
  14341. * @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
  14342. * @returns an array of TransformNode
  14343. */
  14344. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14345. /**
  14346. * Releases resources associated with this transform node.
  14347. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14348. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14349. */
  14350. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14351. /**
  14352. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14353. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14354. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14355. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14356. * @returns the current mesh
  14357. */
  14358. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14359. private _syncAbsoluteScalingAndRotation;
  14360. }
  14361. }
  14362. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14363. import { Observable } from "babylonjs/Misc/observable";
  14364. import { Nullable } from "babylonjs/types";
  14365. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14368. import { Ray } from "babylonjs/Culling/ray";
  14369. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14370. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14371. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14372. /**
  14373. * Defines the types of pose enabled controllers that are supported
  14374. */
  14375. export enum PoseEnabledControllerType {
  14376. /**
  14377. * HTC Vive
  14378. */
  14379. VIVE = 0,
  14380. /**
  14381. * Oculus Rift
  14382. */
  14383. OCULUS = 1,
  14384. /**
  14385. * Windows mixed reality
  14386. */
  14387. WINDOWS = 2,
  14388. /**
  14389. * Samsung gear VR
  14390. */
  14391. GEAR_VR = 3,
  14392. /**
  14393. * Google Daydream
  14394. */
  14395. DAYDREAM = 4,
  14396. /**
  14397. * Generic
  14398. */
  14399. GENERIC = 5
  14400. }
  14401. /**
  14402. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14403. */
  14404. export interface MutableGamepadButton {
  14405. /**
  14406. * Value of the button/trigger
  14407. */
  14408. value: number;
  14409. /**
  14410. * If the button/trigger is currently touched
  14411. */
  14412. touched: boolean;
  14413. /**
  14414. * If the button/trigger is currently pressed
  14415. */
  14416. pressed: boolean;
  14417. }
  14418. /**
  14419. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14420. * @hidden
  14421. */
  14422. export interface ExtendedGamepadButton extends GamepadButton {
  14423. /**
  14424. * If the button/trigger is currently pressed
  14425. */
  14426. readonly pressed: boolean;
  14427. /**
  14428. * If the button/trigger is currently touched
  14429. */
  14430. readonly touched: boolean;
  14431. /**
  14432. * Value of the button/trigger
  14433. */
  14434. readonly value: number;
  14435. }
  14436. /** @hidden */
  14437. export interface _GamePadFactory {
  14438. /**
  14439. * Returns wether or not the current gamepad can be created for this type of controller.
  14440. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14441. * @returns true if it can be created, otherwise false
  14442. */
  14443. canCreate(gamepadInfo: any): boolean;
  14444. /**
  14445. * Creates a new instance of the Gamepad.
  14446. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14447. * @returns the new gamepad instance
  14448. */
  14449. create(gamepadInfo: any): Gamepad;
  14450. }
  14451. /**
  14452. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14453. */
  14454. export class PoseEnabledControllerHelper {
  14455. /** @hidden */
  14456. static _ControllerFactories: _GamePadFactory[];
  14457. /** @hidden */
  14458. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14459. /**
  14460. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14461. * @param vrGamepad the gamepad to initialized
  14462. * @returns a vr controller of the type the gamepad identified as
  14463. */
  14464. static InitiateController(vrGamepad: any): Gamepad;
  14465. }
  14466. /**
  14467. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14468. */
  14469. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14470. /**
  14471. * If the controller is used in a webXR session
  14472. */
  14473. isXR: boolean;
  14474. private _deviceRoomPosition;
  14475. private _deviceRoomRotationQuaternion;
  14476. /**
  14477. * The device position in babylon space
  14478. */
  14479. devicePosition: Vector3;
  14480. /**
  14481. * The device rotation in babylon space
  14482. */
  14483. deviceRotationQuaternion: Quaternion;
  14484. /**
  14485. * The scale factor of the device in babylon space
  14486. */
  14487. deviceScaleFactor: number;
  14488. /**
  14489. * (Likely devicePosition should be used instead) The device position in its room space
  14490. */
  14491. position: Vector3;
  14492. /**
  14493. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14494. */
  14495. rotationQuaternion: Quaternion;
  14496. /**
  14497. * The type of controller (Eg. Windows mixed reality)
  14498. */
  14499. controllerType: PoseEnabledControllerType;
  14500. protected _calculatedPosition: Vector3;
  14501. private _calculatedRotation;
  14502. /**
  14503. * The raw pose from the device
  14504. */
  14505. rawPose: DevicePose;
  14506. private _trackPosition;
  14507. private _maxRotationDistFromHeadset;
  14508. private _draggedRoomRotation;
  14509. /**
  14510. * @hidden
  14511. */
  14512. _disableTrackPosition(fixedPosition: Vector3): void;
  14513. /**
  14514. * Internal, the mesh attached to the controller
  14515. * @hidden
  14516. */
  14517. _mesh: Nullable<AbstractMesh>;
  14518. private _poseControlledCamera;
  14519. private _leftHandSystemQuaternion;
  14520. /**
  14521. * Internal, matrix used to convert room space to babylon space
  14522. * @hidden
  14523. */
  14524. _deviceToWorld: Matrix;
  14525. /**
  14526. * Node to be used when casting a ray from the controller
  14527. * @hidden
  14528. */
  14529. _pointingPoseNode: Nullable<TransformNode>;
  14530. /**
  14531. * Name of the child mesh that can be used to cast a ray from the controller
  14532. */
  14533. static readonly POINTING_POSE: string;
  14534. /**
  14535. * Creates a new PoseEnabledController from a gamepad
  14536. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14537. */
  14538. constructor(browserGamepad: any);
  14539. private _workingMatrix;
  14540. /**
  14541. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14542. */
  14543. update(): void;
  14544. /**
  14545. * Updates only the pose device and mesh without doing any button event checking
  14546. */
  14547. protected _updatePoseAndMesh(): void;
  14548. /**
  14549. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14550. * @param poseData raw pose fromthe device
  14551. */
  14552. updateFromDevice(poseData: DevicePose): void;
  14553. /**
  14554. * @hidden
  14555. */
  14556. _meshAttachedObservable: Observable<AbstractMesh>;
  14557. /**
  14558. * Attaches a mesh to the controller
  14559. * @param mesh the mesh to be attached
  14560. */
  14561. attachToMesh(mesh: AbstractMesh): void;
  14562. /**
  14563. * Attaches the controllers mesh to a camera
  14564. * @param camera the camera the mesh should be attached to
  14565. */
  14566. attachToPoseControlledCamera(camera: TargetCamera): void;
  14567. /**
  14568. * Disposes of the controller
  14569. */
  14570. dispose(): void;
  14571. /**
  14572. * The mesh that is attached to the controller
  14573. */
  14574. readonly mesh: Nullable<AbstractMesh>;
  14575. /**
  14576. * Gets the ray of the controller in the direction the controller is pointing
  14577. * @param length the length the resulting ray should be
  14578. * @returns a ray in the direction the controller is pointing
  14579. */
  14580. getForwardRay(length?: number): Ray;
  14581. }
  14582. }
  14583. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14584. import { Observable } from "babylonjs/Misc/observable";
  14585. import { Scene } from "babylonjs/scene";
  14586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14587. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14588. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14589. /**
  14590. * Defines the WebVRController object that represents controllers tracked in 3D space
  14591. */
  14592. export abstract class WebVRController extends PoseEnabledController {
  14593. /**
  14594. * Internal, the default controller model for the controller
  14595. */
  14596. protected _defaultModel: AbstractMesh;
  14597. /**
  14598. * Fired when the trigger state has changed
  14599. */
  14600. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14601. /**
  14602. * Fired when the main button state has changed
  14603. */
  14604. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14605. /**
  14606. * Fired when the secondary button state has changed
  14607. */
  14608. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14609. /**
  14610. * Fired when the pad state has changed
  14611. */
  14612. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14613. /**
  14614. * Fired when controllers stick values have changed
  14615. */
  14616. onPadValuesChangedObservable: Observable<StickValues>;
  14617. /**
  14618. * Array of button availible on the controller
  14619. */
  14620. protected _buttons: Array<MutableGamepadButton>;
  14621. private _onButtonStateChange;
  14622. /**
  14623. * Fired when a controller button's state has changed
  14624. * @param callback the callback containing the button that was modified
  14625. */
  14626. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14627. /**
  14628. * X and Y axis corresponding to the controllers joystick
  14629. */
  14630. pad: StickValues;
  14631. /**
  14632. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14633. */
  14634. hand: string;
  14635. /**
  14636. * The default controller model for the controller
  14637. */
  14638. readonly defaultModel: AbstractMesh;
  14639. /**
  14640. * Creates a new WebVRController from a gamepad
  14641. * @param vrGamepad the gamepad that the WebVRController should be created from
  14642. */
  14643. constructor(vrGamepad: any);
  14644. /**
  14645. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14646. */
  14647. update(): void;
  14648. /**
  14649. * Function to be called when a button is modified
  14650. */
  14651. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14652. /**
  14653. * Loads a mesh and attaches it to the controller
  14654. * @param scene the scene the mesh should be added to
  14655. * @param meshLoaded callback for when the mesh has been loaded
  14656. */
  14657. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14658. private _setButtonValue;
  14659. private _changes;
  14660. private _checkChanges;
  14661. /**
  14662. * Disposes of th webVRCOntroller
  14663. */
  14664. dispose(): void;
  14665. }
  14666. }
  14667. declare module "babylonjs/Lights/hemisphericLight" {
  14668. import { Nullable } from "babylonjs/types";
  14669. import { Scene } from "babylonjs/scene";
  14670. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14671. import { Color3 } from "babylonjs/Maths/math.color";
  14672. import { Effect } from "babylonjs/Materials/effect";
  14673. import { Light } from "babylonjs/Lights/light";
  14674. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14675. /**
  14676. * The HemisphericLight simulates the ambient environment light,
  14677. * so the passed direction is the light reflection direction, not the incoming direction.
  14678. */
  14679. export class HemisphericLight extends Light {
  14680. /**
  14681. * The groundColor is the light in the opposite direction to the one specified during creation.
  14682. * 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.
  14683. */
  14684. groundColor: Color3;
  14685. /**
  14686. * The light reflection direction, not the incoming direction.
  14687. */
  14688. direction: Vector3;
  14689. /**
  14690. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14691. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14692. * The HemisphericLight can't cast shadows.
  14693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14694. * @param name The friendly name of the light
  14695. * @param direction The direction of the light reflection
  14696. * @param scene The scene the light belongs to
  14697. */
  14698. constructor(name: string, direction: Vector3, scene: Scene);
  14699. protected _buildUniformLayout(): void;
  14700. /**
  14701. * Returns the string "HemisphericLight".
  14702. * @return The class name
  14703. */
  14704. getClassName(): string;
  14705. /**
  14706. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14707. * Returns the updated direction.
  14708. * @param target The target the direction should point to
  14709. * @return The computed direction
  14710. */
  14711. setDirectionToTarget(target: Vector3): Vector3;
  14712. /**
  14713. * Returns the shadow generator associated to the light.
  14714. * @returns Always null for hemispheric lights because it does not support shadows.
  14715. */
  14716. getShadowGenerator(): Nullable<IShadowGenerator>;
  14717. /**
  14718. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14719. * @param effect The effect to update
  14720. * @param lightIndex The index of the light in the effect to update
  14721. * @returns The hemispheric light
  14722. */
  14723. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14724. /**
  14725. * Computes the world matrix of the node
  14726. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14727. * @param useWasUpdatedFlag defines a reserved property
  14728. * @returns the world matrix
  14729. */
  14730. computeWorldMatrix(): Matrix;
  14731. /**
  14732. * Returns the integer 3.
  14733. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14734. */
  14735. getTypeID(): number;
  14736. /**
  14737. * Prepares the list of defines specific to the light type.
  14738. * @param defines the list of defines
  14739. * @param lightIndex defines the index of the light for the effect
  14740. */
  14741. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14742. }
  14743. }
  14744. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14745. /** @hidden */
  14746. export var vrMultiviewToSingleviewPixelShader: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14752. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14753. import { Scene } from "babylonjs/scene";
  14754. /**
  14755. * Renders to multiple views with a single draw call
  14756. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14757. */
  14758. export class MultiviewRenderTarget extends RenderTargetTexture {
  14759. /**
  14760. * Creates a multiview render target
  14761. * @param scene scene used with the render target
  14762. * @param size the size of the render target (used for each view)
  14763. */
  14764. constructor(scene: Scene, size?: number | {
  14765. width: number;
  14766. height: number;
  14767. } | {
  14768. ratio: number;
  14769. });
  14770. /**
  14771. * @hidden
  14772. * @param faceIndex the face index, if its a cube texture
  14773. */
  14774. _bindFrameBuffer(faceIndex?: number): void;
  14775. /**
  14776. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14777. * @returns the view count
  14778. */
  14779. getViewCount(): number;
  14780. }
  14781. }
  14782. declare module "babylonjs/Maths/math.frustum" {
  14783. import { Matrix } from "babylonjs/Maths/math.vector";
  14784. import { DeepImmutable } from "babylonjs/types";
  14785. import { Plane } from "babylonjs/Maths/math.plane";
  14786. /**
  14787. * Reprasents a camera frustum
  14788. */
  14789. export class Frustum {
  14790. /**
  14791. * Gets the planes representing the frustum
  14792. * @param transform matrix to be applied to the returned planes
  14793. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14794. */
  14795. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14796. /**
  14797. * Gets the near frustum plane transformed by the transform matrix
  14798. * @param transform transformation matrix to be applied to the resulting frustum plane
  14799. * @param frustumPlane the resuling frustum plane
  14800. */
  14801. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14802. /**
  14803. * Gets the far frustum plane transformed by the transform matrix
  14804. * @param transform transformation matrix to be applied to the resulting frustum plane
  14805. * @param frustumPlane the resuling frustum plane
  14806. */
  14807. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14808. /**
  14809. * Gets the left frustum plane transformed by the transform matrix
  14810. * @param transform transformation matrix to be applied to the resulting frustum plane
  14811. * @param frustumPlane the resuling frustum plane
  14812. */
  14813. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14814. /**
  14815. * Gets the right frustum plane transformed by the transform matrix
  14816. * @param transform transformation matrix to be applied to the resulting frustum plane
  14817. * @param frustumPlane the resuling frustum plane
  14818. */
  14819. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14820. /**
  14821. * Gets the top frustum plane transformed by the transform matrix
  14822. * @param transform transformation matrix to be applied to the resulting frustum plane
  14823. * @param frustumPlane the resuling frustum plane
  14824. */
  14825. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14826. /**
  14827. * Gets the bottom frustum plane transformed by the transform matrix
  14828. * @param transform transformation matrix to be applied to the resulting frustum plane
  14829. * @param frustumPlane the resuling frustum plane
  14830. */
  14831. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14832. /**
  14833. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14834. * @param transform transformation matrix to be applied to the resulting frustum planes
  14835. * @param frustumPlanes the resuling frustum planes
  14836. */
  14837. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14838. }
  14839. }
  14840. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14841. import { Camera } from "babylonjs/Cameras/camera";
  14842. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14843. import { Nullable } from "babylonjs/types";
  14844. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14845. import { Matrix } from "babylonjs/Maths/math.vector";
  14846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14847. module "babylonjs/Engines/engine" {
  14848. interface Engine {
  14849. /**
  14850. * Creates a new multiview render target
  14851. * @param width defines the width of the texture
  14852. * @param height defines the height of the texture
  14853. * @returns the created multiview texture
  14854. */
  14855. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14856. /**
  14857. * Binds a multiview framebuffer to be drawn to
  14858. * @param multiviewTexture texture to bind
  14859. */
  14860. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14861. }
  14862. }
  14863. module "babylonjs/Cameras/camera" {
  14864. interface Camera {
  14865. /**
  14866. * @hidden
  14867. * 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)
  14868. */
  14869. _useMultiviewToSingleView: boolean;
  14870. /**
  14871. * @hidden
  14872. * 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)
  14873. */
  14874. _multiviewTexture: Nullable<RenderTargetTexture>;
  14875. /**
  14876. * @hidden
  14877. * ensures the multiview texture of the camera exists and has the specified width/height
  14878. * @param width height to set on the multiview texture
  14879. * @param height width to set on the multiview texture
  14880. */
  14881. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14882. }
  14883. }
  14884. module "babylonjs/scene" {
  14885. interface Scene {
  14886. /** @hidden */
  14887. _transformMatrixR: Matrix;
  14888. /** @hidden */
  14889. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14890. /** @hidden */
  14891. _createMultiviewUbo(): void;
  14892. /** @hidden */
  14893. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14894. /** @hidden */
  14895. _renderMultiviewToSingleView(camera: Camera): void;
  14896. }
  14897. }
  14898. }
  14899. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14900. import { Camera } from "babylonjs/Cameras/camera";
  14901. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14902. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14903. import "babylonjs/Engines/Extensions/engine.multiview";
  14904. /**
  14905. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14906. * This will not be used for webXR as it supports displaying texture arrays directly
  14907. */
  14908. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14909. /**
  14910. * Initializes a VRMultiviewToSingleview
  14911. * @param name name of the post process
  14912. * @param camera camera to be applied to
  14913. * @param scaleFactor scaling factor to the size of the output texture
  14914. */
  14915. constructor(name: string, camera: Camera, scaleFactor: number);
  14916. }
  14917. }
  14918. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14919. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Size } from "babylonjs/Maths/math.size";
  14922. import { Observable } from "babylonjs/Misc/observable";
  14923. module "babylonjs/Engines/engine" {
  14924. interface Engine {
  14925. /** @hidden */
  14926. _vrDisplay: any;
  14927. /** @hidden */
  14928. _vrSupported: boolean;
  14929. /** @hidden */
  14930. _oldSize: Size;
  14931. /** @hidden */
  14932. _oldHardwareScaleFactor: number;
  14933. /** @hidden */
  14934. _vrExclusivePointerMode: boolean;
  14935. /** @hidden */
  14936. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14937. /** @hidden */
  14938. _onVRDisplayPointerRestricted: () => void;
  14939. /** @hidden */
  14940. _onVRDisplayPointerUnrestricted: () => void;
  14941. /** @hidden */
  14942. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14943. /** @hidden */
  14944. _onVrDisplayDisconnect: Nullable<() => void>;
  14945. /** @hidden */
  14946. _onVrDisplayPresentChange: Nullable<() => void>;
  14947. /**
  14948. * Observable signaled when VR display mode changes
  14949. */
  14950. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14951. /**
  14952. * Observable signaled when VR request present is complete
  14953. */
  14954. onVRRequestPresentComplete: Observable<boolean>;
  14955. /**
  14956. * Observable signaled when VR request present starts
  14957. */
  14958. onVRRequestPresentStart: Observable<Engine>;
  14959. /**
  14960. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14961. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14962. */
  14963. isInVRExclusivePointerMode: boolean;
  14964. /**
  14965. * Gets a boolean indicating if a webVR device was detected
  14966. * @returns true if a webVR device was detected
  14967. */
  14968. isVRDevicePresent(): boolean;
  14969. /**
  14970. * Gets the current webVR device
  14971. * @returns the current webVR device (or null)
  14972. */
  14973. getVRDevice(): any;
  14974. /**
  14975. * Initializes a webVR display and starts listening to display change events
  14976. * The onVRDisplayChangedObservable will be notified upon these changes
  14977. * @returns A promise containing a VRDisplay and if vr is supported
  14978. */
  14979. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14980. /** @hidden */
  14981. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14982. /**
  14983. * Call this function to switch to webVR mode
  14984. * Will do nothing if webVR is not supported or if there is no webVR device
  14985. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14986. */
  14987. enableVR(): void;
  14988. /** @hidden */
  14989. _onVRFullScreenTriggered(): void;
  14990. }
  14991. }
  14992. }
  14993. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14994. import { Nullable } from "babylonjs/types";
  14995. import { Observable } from "babylonjs/Misc/observable";
  14996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14997. import { Scene } from "babylonjs/scene";
  14998. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14999. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15000. import { Node } from "babylonjs/node";
  15001. import { Ray } from "babylonjs/Culling/ray";
  15002. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15003. import "babylonjs/Engines/Extensions/engine.webVR";
  15004. /**
  15005. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15006. * IMPORTANT!! The data is right-hand data.
  15007. * @export
  15008. * @interface DevicePose
  15009. */
  15010. export interface DevicePose {
  15011. /**
  15012. * The position of the device, values in array are [x,y,z].
  15013. */
  15014. readonly position: Nullable<Float32Array>;
  15015. /**
  15016. * The linearVelocity of the device, values in array are [x,y,z].
  15017. */
  15018. readonly linearVelocity: Nullable<Float32Array>;
  15019. /**
  15020. * The linearAcceleration of the device, values in array are [x,y,z].
  15021. */
  15022. readonly linearAcceleration: Nullable<Float32Array>;
  15023. /**
  15024. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15025. */
  15026. readonly orientation: Nullable<Float32Array>;
  15027. /**
  15028. * The angularVelocity of the device, values in array are [x,y,z].
  15029. */
  15030. readonly angularVelocity: Nullable<Float32Array>;
  15031. /**
  15032. * The angularAcceleration of the device, values in array are [x,y,z].
  15033. */
  15034. readonly angularAcceleration: Nullable<Float32Array>;
  15035. }
  15036. /**
  15037. * Interface representing a pose controlled object in Babylon.
  15038. * A pose controlled object has both regular pose values as well as pose values
  15039. * from an external device such as a VR head mounted display
  15040. */
  15041. export interface PoseControlled {
  15042. /**
  15043. * The position of the object in babylon space.
  15044. */
  15045. position: Vector3;
  15046. /**
  15047. * The rotation quaternion of the object in babylon space.
  15048. */
  15049. rotationQuaternion: Quaternion;
  15050. /**
  15051. * The position of the device in babylon space.
  15052. */
  15053. devicePosition?: Vector3;
  15054. /**
  15055. * The rotation quaternion of the device in babylon space.
  15056. */
  15057. deviceRotationQuaternion: Quaternion;
  15058. /**
  15059. * The raw pose coming from the device.
  15060. */
  15061. rawPose: Nullable<DevicePose>;
  15062. /**
  15063. * The scale of the device to be used when translating from device space to babylon space.
  15064. */
  15065. deviceScaleFactor: number;
  15066. /**
  15067. * Updates the poseControlled values based on the input device pose.
  15068. * @param poseData the pose data to update the object with
  15069. */
  15070. updateFromDevice(poseData: DevicePose): void;
  15071. }
  15072. /**
  15073. * Set of options to customize the webVRCamera
  15074. */
  15075. export interface WebVROptions {
  15076. /**
  15077. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15078. */
  15079. trackPosition?: boolean;
  15080. /**
  15081. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15082. */
  15083. positionScale?: number;
  15084. /**
  15085. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15086. */
  15087. displayName?: string;
  15088. /**
  15089. * Should the native controller meshes be initialized. (default: true)
  15090. */
  15091. controllerMeshes?: boolean;
  15092. /**
  15093. * Creating a default HemiLight only on controllers. (default: true)
  15094. */
  15095. defaultLightingOnControllers?: boolean;
  15096. /**
  15097. * If you don't want to use the default VR button of the helper. (default: false)
  15098. */
  15099. useCustomVRButton?: boolean;
  15100. /**
  15101. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15102. */
  15103. customVRButton?: HTMLButtonElement;
  15104. /**
  15105. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15106. */
  15107. rayLength?: number;
  15108. /**
  15109. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15110. */
  15111. defaultHeight?: number;
  15112. /**
  15113. * If multiview should be used if availible (default: false)
  15114. */
  15115. useMultiview?: boolean;
  15116. }
  15117. /**
  15118. * This represents a WebVR camera.
  15119. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15120. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15121. */
  15122. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15123. private webVROptions;
  15124. /**
  15125. * @hidden
  15126. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15127. */
  15128. _vrDevice: any;
  15129. /**
  15130. * The rawPose of the vrDevice.
  15131. */
  15132. rawPose: Nullable<DevicePose>;
  15133. private _onVREnabled;
  15134. private _specsVersion;
  15135. private _attached;
  15136. private _frameData;
  15137. protected _descendants: Array<Node>;
  15138. private _deviceRoomPosition;
  15139. /** @hidden */
  15140. _deviceRoomRotationQuaternion: Quaternion;
  15141. private _standingMatrix;
  15142. /**
  15143. * Represents device position in babylon space.
  15144. */
  15145. devicePosition: Vector3;
  15146. /**
  15147. * Represents device rotation in babylon space.
  15148. */
  15149. deviceRotationQuaternion: Quaternion;
  15150. /**
  15151. * The scale of the device to be used when translating from device space to babylon space.
  15152. */
  15153. deviceScaleFactor: number;
  15154. private _deviceToWorld;
  15155. private _worldToDevice;
  15156. /**
  15157. * References to the webVR controllers for the vrDevice.
  15158. */
  15159. controllers: Array<WebVRController>;
  15160. /**
  15161. * Emits an event when a controller is attached.
  15162. */
  15163. onControllersAttachedObservable: Observable<WebVRController[]>;
  15164. /**
  15165. * Emits an event when a controller's mesh has been loaded;
  15166. */
  15167. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15168. /**
  15169. * Emits an event when the HMD's pose has been updated.
  15170. */
  15171. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15172. private _poseSet;
  15173. /**
  15174. * If the rig cameras be used as parent instead of this camera.
  15175. */
  15176. rigParenting: boolean;
  15177. private _lightOnControllers;
  15178. private _defaultHeight?;
  15179. /**
  15180. * Instantiates a WebVRFreeCamera.
  15181. * @param name The name of the WebVRFreeCamera
  15182. * @param position The starting anchor position for the camera
  15183. * @param scene The scene the camera belongs to
  15184. * @param webVROptions a set of customizable options for the webVRCamera
  15185. */
  15186. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15187. /**
  15188. * Gets the device distance from the ground in meters.
  15189. * @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.
  15190. */
  15191. deviceDistanceToRoomGround(): number;
  15192. /**
  15193. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15194. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15195. */
  15196. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15197. /**
  15198. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15199. * @returns A promise with a boolean set to if the standing matrix is supported.
  15200. */
  15201. useStandingMatrixAsync(): Promise<boolean>;
  15202. /**
  15203. * Disposes the camera
  15204. */
  15205. dispose(): void;
  15206. /**
  15207. * Gets a vrController by name.
  15208. * @param name The name of the controller to retreive
  15209. * @returns the controller matching the name specified or null if not found
  15210. */
  15211. getControllerByName(name: string): Nullable<WebVRController>;
  15212. private _leftController;
  15213. /**
  15214. * The controller corresponding to the users left hand.
  15215. */
  15216. readonly leftController: Nullable<WebVRController>;
  15217. private _rightController;
  15218. /**
  15219. * The controller corresponding to the users right hand.
  15220. */
  15221. readonly rightController: Nullable<WebVRController>;
  15222. /**
  15223. * Casts a ray forward from the vrCamera's gaze.
  15224. * @param length Length of the ray (default: 100)
  15225. * @returns the ray corresponding to the gaze
  15226. */
  15227. getForwardRay(length?: number): Ray;
  15228. /**
  15229. * @hidden
  15230. * Updates the camera based on device's frame data
  15231. */
  15232. _checkInputs(): void;
  15233. /**
  15234. * Updates the poseControlled values based on the input device pose.
  15235. * @param poseData Pose coming from the device
  15236. */
  15237. updateFromDevice(poseData: DevicePose): void;
  15238. private _htmlElementAttached;
  15239. private _detachIfAttached;
  15240. /**
  15241. * WebVR's attach control will start broadcasting frames to the device.
  15242. * Note that in certain browsers (chrome for example) this function must be called
  15243. * within a user-interaction callback. Example:
  15244. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15245. *
  15246. * @param element html element to attach the vrDevice to
  15247. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15248. */
  15249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15250. /**
  15251. * Detaches the camera from the html element and disables VR
  15252. *
  15253. * @param element html element to detach from
  15254. */
  15255. detachControl(element: HTMLElement): void;
  15256. /**
  15257. * @returns the name of this class
  15258. */
  15259. getClassName(): string;
  15260. /**
  15261. * Calls resetPose on the vrDisplay
  15262. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15263. */
  15264. resetToCurrentRotation(): void;
  15265. /**
  15266. * @hidden
  15267. * Updates the rig cameras (left and right eye)
  15268. */
  15269. _updateRigCameras(): void;
  15270. private _workingVector;
  15271. private _oneVector;
  15272. private _workingMatrix;
  15273. private updateCacheCalled;
  15274. private _correctPositionIfNotTrackPosition;
  15275. /**
  15276. * @hidden
  15277. * Updates the cached values of the camera
  15278. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15279. */
  15280. _updateCache(ignoreParentClass?: boolean): void;
  15281. /**
  15282. * @hidden
  15283. * Get current device position in babylon world
  15284. */
  15285. _computeDevicePosition(): void;
  15286. /**
  15287. * Updates the current device position and rotation in the babylon world
  15288. */
  15289. update(): void;
  15290. /**
  15291. * @hidden
  15292. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15293. * @returns an identity matrix
  15294. */
  15295. _getViewMatrix(): Matrix;
  15296. private _tmpMatrix;
  15297. /**
  15298. * This function is called by the two RIG cameras.
  15299. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15300. * @hidden
  15301. */
  15302. _getWebVRViewMatrix(): Matrix;
  15303. /** @hidden */
  15304. _getWebVRProjectionMatrix(): Matrix;
  15305. private _onGamepadConnectedObserver;
  15306. private _onGamepadDisconnectedObserver;
  15307. private _updateCacheWhenTrackingDisabledObserver;
  15308. /**
  15309. * Initializes the controllers and their meshes
  15310. */
  15311. initControllers(): void;
  15312. }
  15313. }
  15314. declare module "babylonjs/PostProcesses/postProcess" {
  15315. import { Nullable } from "babylonjs/types";
  15316. import { SmartArray } from "babylonjs/Misc/smartArray";
  15317. import { Observable } from "babylonjs/Misc/observable";
  15318. import { Vector2 } from "babylonjs/Maths/math.vector";
  15319. import { Camera } from "babylonjs/Cameras/camera";
  15320. import { Effect } from "babylonjs/Materials/effect";
  15321. import "babylonjs/Shaders/postprocess.vertex";
  15322. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15323. import { Engine } from "babylonjs/Engines/engine";
  15324. import { Color4 } from "babylonjs/Maths/math.color";
  15325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15326. /**
  15327. * Size options for a post process
  15328. */
  15329. export type PostProcessOptions = {
  15330. width: number;
  15331. height: number;
  15332. };
  15333. /**
  15334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15336. */
  15337. export class PostProcess {
  15338. /** Name of the PostProcess. */
  15339. name: string;
  15340. /**
  15341. * Gets or sets the unique id of the post process
  15342. */
  15343. uniqueId: number;
  15344. /**
  15345. * Width of the texture to apply the post process on
  15346. */
  15347. width: number;
  15348. /**
  15349. * Height of the texture to apply the post process on
  15350. */
  15351. height: number;
  15352. /**
  15353. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15354. * @hidden
  15355. */
  15356. _outputTexture: Nullable<InternalTexture>;
  15357. /**
  15358. * Sampling mode used by the shader
  15359. * See https://doc.babylonjs.com/classes/3.1/texture
  15360. */
  15361. renderTargetSamplingMode: number;
  15362. /**
  15363. * Clear color to use when screen clearing
  15364. */
  15365. clearColor: Color4;
  15366. /**
  15367. * If the buffer needs to be cleared before applying the post process. (default: true)
  15368. * Should be set to false if shader will overwrite all previous pixels.
  15369. */
  15370. autoClear: boolean;
  15371. /**
  15372. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15373. */
  15374. alphaMode: number;
  15375. /**
  15376. * Sets the setAlphaBlendConstants of the babylon engine
  15377. */
  15378. alphaConstants: Color4;
  15379. /**
  15380. * Animations to be used for the post processing
  15381. */
  15382. animations: import("babylonjs/Animations/animation").Animation[];
  15383. /**
  15384. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15385. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15386. */
  15387. enablePixelPerfectMode: boolean;
  15388. /**
  15389. * Force the postprocess to be applied without taking in account viewport
  15390. */
  15391. forceFullscreenViewport: boolean;
  15392. /**
  15393. * List of inspectable custom properties (used by the Inspector)
  15394. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15395. */
  15396. inspectableCustomProperties: IInspectable[];
  15397. /**
  15398. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15399. *
  15400. * | Value | Type | Description |
  15401. * | ----- | ----------------------------------- | ----------- |
  15402. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15403. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15404. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15405. *
  15406. */
  15407. scaleMode: number;
  15408. /**
  15409. * Force textures to be a power of two (default: false)
  15410. */
  15411. alwaysForcePOT: boolean;
  15412. private _samples;
  15413. /**
  15414. * Number of sample textures (default: 1)
  15415. */
  15416. samples: number;
  15417. /**
  15418. * Modify the scale of the post process to be the same as the viewport (default: false)
  15419. */
  15420. adaptScaleToCurrentViewport: boolean;
  15421. private _camera;
  15422. private _scene;
  15423. private _engine;
  15424. private _options;
  15425. private _reusable;
  15426. private _textureType;
  15427. /**
  15428. * Smart array of input and output textures for the post process.
  15429. * @hidden
  15430. */
  15431. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15432. /**
  15433. * The index in _textures that corresponds to the output texture.
  15434. * @hidden
  15435. */
  15436. _currentRenderTextureInd: number;
  15437. private _effect;
  15438. private _samplers;
  15439. private _fragmentUrl;
  15440. private _vertexUrl;
  15441. private _parameters;
  15442. private _scaleRatio;
  15443. protected _indexParameters: any;
  15444. private _shareOutputWithPostProcess;
  15445. private _texelSize;
  15446. private _forcedOutputTexture;
  15447. /**
  15448. * Returns the fragment url or shader name used in the post process.
  15449. * @returns the fragment url or name in the shader store.
  15450. */
  15451. getEffectName(): string;
  15452. /**
  15453. * An event triggered when the postprocess is activated.
  15454. */
  15455. onActivateObservable: Observable<Camera>;
  15456. private _onActivateObserver;
  15457. /**
  15458. * A function that is added to the onActivateObservable
  15459. */
  15460. onActivate: Nullable<(camera: Camera) => void>;
  15461. /**
  15462. * An event triggered when the postprocess changes its size.
  15463. */
  15464. onSizeChangedObservable: Observable<PostProcess>;
  15465. private _onSizeChangedObserver;
  15466. /**
  15467. * A function that is added to the onSizeChangedObservable
  15468. */
  15469. onSizeChanged: (postProcess: PostProcess) => void;
  15470. /**
  15471. * An event triggered when the postprocess applies its effect.
  15472. */
  15473. onApplyObservable: Observable<Effect>;
  15474. private _onApplyObserver;
  15475. /**
  15476. * A function that is added to the onApplyObservable
  15477. */
  15478. onApply: (effect: Effect) => void;
  15479. /**
  15480. * An event triggered before rendering the postprocess
  15481. */
  15482. onBeforeRenderObservable: Observable<Effect>;
  15483. private _onBeforeRenderObserver;
  15484. /**
  15485. * A function that is added to the onBeforeRenderObservable
  15486. */
  15487. onBeforeRender: (effect: Effect) => void;
  15488. /**
  15489. * An event triggered after rendering the postprocess
  15490. */
  15491. onAfterRenderObservable: Observable<Effect>;
  15492. private _onAfterRenderObserver;
  15493. /**
  15494. * A function that is added to the onAfterRenderObservable
  15495. */
  15496. onAfterRender: (efect: Effect) => void;
  15497. /**
  15498. * 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
  15499. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15500. */
  15501. inputTexture: InternalTexture;
  15502. /**
  15503. * Gets the camera which post process is applied to.
  15504. * @returns The camera the post process is applied to.
  15505. */
  15506. getCamera(): Camera;
  15507. /**
  15508. * Gets the texel size of the postprocess.
  15509. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15510. */
  15511. readonly texelSize: Vector2;
  15512. /**
  15513. * Creates a new instance PostProcess
  15514. * @param name The name of the PostProcess.
  15515. * @param fragmentUrl The url of the fragment shader to be used.
  15516. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15517. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15518. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15519. * @param camera The camera to apply the render pass to.
  15520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15521. * @param engine The engine which the post process will be applied. (default: current engine)
  15522. * @param reusable If the post process can be reused on the same frame. (default: false)
  15523. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15524. * @param textureType Type of textures used when performing the post process. (default: 0)
  15525. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15526. * @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
  15527. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15528. */
  15529. constructor(
  15530. /** Name of the PostProcess. */
  15531. 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);
  15532. /**
  15533. * Gets a string idenfifying the name of the class
  15534. * @returns "PostProcess" string
  15535. */
  15536. getClassName(): string;
  15537. /**
  15538. * Gets the engine which this post process belongs to.
  15539. * @returns The engine the post process was enabled with.
  15540. */
  15541. getEngine(): Engine;
  15542. /**
  15543. * The effect that is created when initializing the post process.
  15544. * @returns The created effect corresponding the the postprocess.
  15545. */
  15546. getEffect(): Effect;
  15547. /**
  15548. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15549. * @param postProcess The post process to share the output with.
  15550. * @returns This post process.
  15551. */
  15552. shareOutputWith(postProcess: PostProcess): PostProcess;
  15553. /**
  15554. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15555. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15556. */
  15557. useOwnOutput(): void;
  15558. /**
  15559. * Updates the effect with the current post process compile time values and recompiles the shader.
  15560. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15561. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15562. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15563. * @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
  15564. * @param onCompiled Called when the shader has been compiled.
  15565. * @param onError Called if there is an error when compiling a shader.
  15566. */
  15567. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15568. /**
  15569. * The post process is reusable if it can be used multiple times within one frame.
  15570. * @returns If the post process is reusable
  15571. */
  15572. isReusable(): boolean;
  15573. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15574. markTextureDirty(): void;
  15575. /**
  15576. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15577. * 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.
  15578. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15579. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15580. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15581. * @returns The target texture that was bound to be written to.
  15582. */
  15583. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15584. /**
  15585. * If the post process is supported.
  15586. */
  15587. readonly isSupported: boolean;
  15588. /**
  15589. * The aspect ratio of the output texture.
  15590. */
  15591. readonly aspectRatio: number;
  15592. /**
  15593. * Get a value indicating if the post-process is ready to be used
  15594. * @returns true if the post-process is ready (shader is compiled)
  15595. */
  15596. isReady(): boolean;
  15597. /**
  15598. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15599. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15600. */
  15601. apply(): Nullable<Effect>;
  15602. private _disposeTextures;
  15603. /**
  15604. * Disposes the post process.
  15605. * @param camera The camera to dispose the post process on.
  15606. */
  15607. dispose(camera?: Camera): void;
  15608. }
  15609. }
  15610. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15611. /** @hidden */
  15612. export var kernelBlurVaryingDeclaration: {
  15613. name: string;
  15614. shader: string;
  15615. };
  15616. }
  15617. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15618. /** @hidden */
  15619. export var kernelBlurFragment: {
  15620. name: string;
  15621. shader: string;
  15622. };
  15623. }
  15624. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15625. /** @hidden */
  15626. export var kernelBlurFragment2: {
  15627. name: string;
  15628. shader: string;
  15629. };
  15630. }
  15631. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15632. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15633. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15634. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15635. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15636. /** @hidden */
  15637. export var kernelBlurPixelShader: {
  15638. name: string;
  15639. shader: string;
  15640. };
  15641. }
  15642. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15643. /** @hidden */
  15644. export var kernelBlurVertex: {
  15645. name: string;
  15646. shader: string;
  15647. };
  15648. }
  15649. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15650. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15651. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15652. /** @hidden */
  15653. export var kernelBlurVertexShader: {
  15654. name: string;
  15655. shader: string;
  15656. };
  15657. }
  15658. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15659. import { Vector2 } from "babylonjs/Maths/math.vector";
  15660. import { Nullable } from "babylonjs/types";
  15661. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15662. import { Camera } from "babylonjs/Cameras/camera";
  15663. import { Effect } from "babylonjs/Materials/effect";
  15664. import { Engine } from "babylonjs/Engines/engine";
  15665. import "babylonjs/Shaders/kernelBlur.fragment";
  15666. import "babylonjs/Shaders/kernelBlur.vertex";
  15667. /**
  15668. * The Blur Post Process which blurs an image based on a kernel and direction.
  15669. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15670. */
  15671. export class BlurPostProcess extends PostProcess {
  15672. /** The direction in which to blur the image. */
  15673. direction: Vector2;
  15674. private blockCompilation;
  15675. protected _kernel: number;
  15676. protected _idealKernel: number;
  15677. protected _packedFloat: boolean;
  15678. private _staticDefines;
  15679. /**
  15680. * Sets the length in pixels of the blur sample region
  15681. */
  15682. /**
  15683. * Gets the length in pixels of the blur sample region
  15684. */
  15685. kernel: number;
  15686. /**
  15687. * Sets wether or not the blur needs to unpack/repack floats
  15688. */
  15689. /**
  15690. * Gets wether or not the blur is unpacking/repacking floats
  15691. */
  15692. packedFloat: boolean;
  15693. /**
  15694. * Creates a new instance BlurPostProcess
  15695. * @param name The name of the effect.
  15696. * @param direction The direction in which to blur the image.
  15697. * @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.
  15698. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15699. * @param camera The camera to apply the render pass to.
  15700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15701. * @param engine The engine which the post process will be applied. (default: current engine)
  15702. * @param reusable If the post process can be reused on the same frame. (default: false)
  15703. * @param textureType Type of textures used when performing the post process. (default: 0)
  15704. * @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)
  15705. */
  15706. constructor(name: string,
  15707. /** The direction in which to blur the image. */
  15708. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15709. /**
  15710. * Updates the effect with the current post process compile time values and recompiles the shader.
  15711. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15712. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15713. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15714. * @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
  15715. * @param onCompiled Called when the shader has been compiled.
  15716. * @param onError Called if there is an error when compiling a shader.
  15717. */
  15718. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15719. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15720. /**
  15721. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15722. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15723. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15724. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15725. * The gaps between physical kernels are compensated for in the weighting of the samples
  15726. * @param idealKernel Ideal blur kernel.
  15727. * @return Nearest best kernel.
  15728. */
  15729. protected _nearestBestKernel(idealKernel: number): number;
  15730. /**
  15731. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15732. * @param x The point on the Gaussian distribution to sample.
  15733. * @return the value of the Gaussian function at x.
  15734. */
  15735. protected _gaussianWeight(x: number): number;
  15736. /**
  15737. * Generates a string that can be used as a floating point number in GLSL.
  15738. * @param x Value to print.
  15739. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15740. * @return GLSL float string.
  15741. */
  15742. protected _glslFloat(x: number, decimalFigures?: number): string;
  15743. }
  15744. }
  15745. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15746. import { Scene } from "babylonjs/scene";
  15747. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15748. import { Plane } from "babylonjs/Maths/math.plane";
  15749. /**
  15750. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15751. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15752. * You can then easily use it as a reflectionTexture on a flat surface.
  15753. * In case the surface is not a plane, please consider relying on reflection probes.
  15754. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15755. */
  15756. export class MirrorTexture extends RenderTargetTexture {
  15757. private scene;
  15758. /**
  15759. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15760. * 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.
  15761. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15762. */
  15763. mirrorPlane: Plane;
  15764. /**
  15765. * Define the blur ratio used to blur the reflection if needed.
  15766. */
  15767. blurRatio: number;
  15768. /**
  15769. * Define the adaptive blur kernel used to blur the reflection if needed.
  15770. * This will autocompute the closest best match for the `blurKernel`
  15771. */
  15772. adaptiveBlurKernel: number;
  15773. /**
  15774. * Define the blur kernel used to blur the reflection if needed.
  15775. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15776. */
  15777. blurKernel: number;
  15778. /**
  15779. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15780. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15781. */
  15782. blurKernelX: number;
  15783. /**
  15784. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15785. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15786. */
  15787. blurKernelY: number;
  15788. private _autoComputeBlurKernel;
  15789. protected _onRatioRescale(): void;
  15790. private _updateGammaSpace;
  15791. private _imageProcessingConfigChangeObserver;
  15792. private _transformMatrix;
  15793. private _mirrorMatrix;
  15794. private _savedViewMatrix;
  15795. private _blurX;
  15796. private _blurY;
  15797. private _adaptiveBlurKernel;
  15798. private _blurKernelX;
  15799. private _blurKernelY;
  15800. private _blurRatio;
  15801. /**
  15802. * Instantiates a Mirror Texture.
  15803. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15804. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15805. * You can then easily use it as a reflectionTexture on a flat surface.
  15806. * In case the surface is not a plane, please consider relying on reflection probes.
  15807. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15808. * @param name
  15809. * @param size
  15810. * @param scene
  15811. * @param generateMipMaps
  15812. * @param type
  15813. * @param samplingMode
  15814. * @param generateDepthBuffer
  15815. */
  15816. constructor(name: string, size: number | {
  15817. width: number;
  15818. height: number;
  15819. } | {
  15820. ratio: number;
  15821. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15822. private _preparePostProcesses;
  15823. /**
  15824. * Clone the mirror texture.
  15825. * @returns the cloned texture
  15826. */
  15827. clone(): MirrorTexture;
  15828. /**
  15829. * Serialize the texture to a JSON representation you could use in Parse later on
  15830. * @returns the serialized JSON representation
  15831. */
  15832. serialize(): any;
  15833. /**
  15834. * Dispose the texture and release its associated resources.
  15835. */
  15836. dispose(): void;
  15837. }
  15838. }
  15839. declare module "babylonjs/Materials/Textures/texture" {
  15840. import { Observable } from "babylonjs/Misc/observable";
  15841. import { Nullable } from "babylonjs/types";
  15842. import { Scene } from "babylonjs/scene";
  15843. import { Matrix } from "babylonjs/Maths/math.vector";
  15844. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15845. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15846. import { Engine } from "babylonjs/Engines/engine";
  15847. /**
  15848. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15849. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15850. */
  15851. export class Texture extends BaseTexture {
  15852. /** @hidden */
  15853. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15854. /** @hidden */
  15855. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15856. /** @hidden */
  15857. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15858. /** nearest is mag = nearest and min = nearest and mip = linear */
  15859. static readonly NEAREST_SAMPLINGMODE: number;
  15860. /** nearest is mag = nearest and min = nearest and mip = linear */
  15861. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15863. static readonly BILINEAR_SAMPLINGMODE: number;
  15864. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15865. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15866. /** Trilinear is mag = linear and min = linear and mip = linear */
  15867. static readonly TRILINEAR_SAMPLINGMODE: number;
  15868. /** Trilinear is mag = linear and min = linear and mip = linear */
  15869. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15870. /** mag = nearest and min = nearest and mip = nearest */
  15871. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15872. /** mag = nearest and min = linear and mip = nearest */
  15873. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15874. /** mag = nearest and min = linear and mip = linear */
  15875. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15876. /** mag = nearest and min = linear and mip = none */
  15877. static readonly NEAREST_LINEAR: number;
  15878. /** mag = nearest and min = nearest and mip = none */
  15879. static readonly NEAREST_NEAREST: number;
  15880. /** mag = linear and min = nearest and mip = nearest */
  15881. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15882. /** mag = linear and min = nearest and mip = linear */
  15883. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15884. /** mag = linear and min = linear and mip = none */
  15885. static readonly LINEAR_LINEAR: number;
  15886. /** mag = linear and min = nearest and mip = none */
  15887. static readonly LINEAR_NEAREST: number;
  15888. /** Explicit coordinates mode */
  15889. static readonly EXPLICIT_MODE: number;
  15890. /** Spherical coordinates mode */
  15891. static readonly SPHERICAL_MODE: number;
  15892. /** Planar coordinates mode */
  15893. static readonly PLANAR_MODE: number;
  15894. /** Cubic coordinates mode */
  15895. static readonly CUBIC_MODE: number;
  15896. /** Projection coordinates mode */
  15897. static readonly PROJECTION_MODE: number;
  15898. /** Inverse Cubic coordinates mode */
  15899. static readonly SKYBOX_MODE: number;
  15900. /** Inverse Cubic coordinates mode */
  15901. static readonly INVCUBIC_MODE: number;
  15902. /** Equirectangular coordinates mode */
  15903. static readonly EQUIRECTANGULAR_MODE: number;
  15904. /** Equirectangular Fixed coordinates mode */
  15905. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15906. /** Equirectangular Fixed Mirrored coordinates mode */
  15907. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15908. /** Texture is not repeating outside of 0..1 UVs */
  15909. static readonly CLAMP_ADDRESSMODE: number;
  15910. /** Texture is repeating outside of 0..1 UVs */
  15911. static readonly WRAP_ADDRESSMODE: number;
  15912. /** Texture is repeating and mirrored */
  15913. static readonly MIRROR_ADDRESSMODE: number;
  15914. /**
  15915. * 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
  15916. */
  15917. static UseSerializedUrlIfAny: boolean;
  15918. /**
  15919. * Define the url of the texture.
  15920. */
  15921. url: Nullable<string>;
  15922. /**
  15923. * Define an offset on the texture to offset the u coordinates of the UVs
  15924. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15925. */
  15926. uOffset: number;
  15927. /**
  15928. * Define an offset on the texture to offset the v coordinates of the UVs
  15929. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15930. */
  15931. vOffset: number;
  15932. /**
  15933. * Define an offset on the texture to scale the u coordinates of the UVs
  15934. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15935. */
  15936. uScale: number;
  15937. /**
  15938. * Define an offset on the texture to scale the v coordinates of the UVs
  15939. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15940. */
  15941. vScale: number;
  15942. /**
  15943. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15944. * @see http://doc.babylonjs.com/how_to/more_materials
  15945. */
  15946. uAng: number;
  15947. /**
  15948. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15949. * @see http://doc.babylonjs.com/how_to/more_materials
  15950. */
  15951. vAng: number;
  15952. /**
  15953. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15954. * @see http://doc.babylonjs.com/how_to/more_materials
  15955. */
  15956. wAng: number;
  15957. /**
  15958. * Defines the center of rotation (U)
  15959. */
  15960. uRotationCenter: number;
  15961. /**
  15962. * Defines the center of rotation (V)
  15963. */
  15964. vRotationCenter: number;
  15965. /**
  15966. * Defines the center of rotation (W)
  15967. */
  15968. wRotationCenter: number;
  15969. /**
  15970. * Are mip maps generated for this texture or not.
  15971. */
  15972. readonly noMipmap: boolean;
  15973. /**
  15974. * List of inspectable custom properties (used by the Inspector)
  15975. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15976. */
  15977. inspectableCustomProperties: Nullable<IInspectable[]>;
  15978. private _noMipmap;
  15979. /** @hidden */
  15980. _invertY: boolean;
  15981. private _rowGenerationMatrix;
  15982. private _cachedTextureMatrix;
  15983. private _projectionModeMatrix;
  15984. private _t0;
  15985. private _t1;
  15986. private _t2;
  15987. private _cachedUOffset;
  15988. private _cachedVOffset;
  15989. private _cachedUScale;
  15990. private _cachedVScale;
  15991. private _cachedUAng;
  15992. private _cachedVAng;
  15993. private _cachedWAng;
  15994. private _cachedProjectionMatrixId;
  15995. private _cachedCoordinatesMode;
  15996. /** @hidden */
  15997. protected _initialSamplingMode: number;
  15998. /** @hidden */
  15999. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  16000. private _deleteBuffer;
  16001. protected _format: Nullable<number>;
  16002. private _delayedOnLoad;
  16003. private _delayedOnError;
  16004. /**
  16005. * Observable triggered once the texture has been loaded.
  16006. */
  16007. onLoadObservable: Observable<Texture>;
  16008. protected _isBlocking: boolean;
  16009. /**
  16010. * Is the texture preventing material to render while loading.
  16011. * If false, a default texture will be used instead of the loading one during the preparation step.
  16012. */
  16013. isBlocking: boolean;
  16014. /**
  16015. * Get the current sampling mode associated with the texture.
  16016. */
  16017. readonly samplingMode: number;
  16018. /**
  16019. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16020. */
  16021. readonly invertY: boolean;
  16022. /**
  16023. * Instantiates a new texture.
  16024. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16025. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16026. * @param url define the url of the picture to load as a texture
  16027. * @param scene define the scene or engine the texture will belong to
  16028. * @param noMipmap define if the texture will require mip maps or not
  16029. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16030. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16031. * @param onLoad define a callback triggered when the texture has been loaded
  16032. * @param onError define a callback triggered when an error occurred during the loading session
  16033. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16034. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16035. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16036. */
  16037. 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);
  16038. /**
  16039. * Update the url (and optional buffer) of this texture if url was null during construction.
  16040. * @param url the url of the texture
  16041. * @param buffer the buffer of the texture (defaults to null)
  16042. * @param onLoad callback called when the texture is loaded (defaults to null)
  16043. */
  16044. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16045. /**
  16046. * Finish the loading sequence of a texture flagged as delayed load.
  16047. * @hidden
  16048. */
  16049. delayLoad(): void;
  16050. private _prepareRowForTextureGeneration;
  16051. /**
  16052. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16053. * @returns the transform matrix of the texture.
  16054. */
  16055. getTextureMatrix(): Matrix;
  16056. /**
  16057. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16058. * @returns The reflection texture transform
  16059. */
  16060. getReflectionTextureMatrix(): Matrix;
  16061. /**
  16062. * Clones the texture.
  16063. * @returns the cloned texture
  16064. */
  16065. clone(): Texture;
  16066. /**
  16067. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16068. * @returns The JSON representation of the texture
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Get the current class name of the texture useful for serialization or dynamic coding.
  16073. * @returns "Texture"
  16074. */
  16075. getClassName(): string;
  16076. /**
  16077. * Dispose the texture and release its associated resources.
  16078. */
  16079. dispose(): void;
  16080. /**
  16081. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16082. * @param parsedTexture Define the JSON representation of the texture
  16083. * @param scene Define the scene the parsed texture should be instantiated in
  16084. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16085. * @returns The parsed texture if successful
  16086. */
  16087. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16088. /**
  16089. * Creates a texture from its base 64 representation.
  16090. * @param data Define the base64 payload without the data: prefix
  16091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16092. * @param scene Define the scene the texture should belong to
  16093. * @param noMipmap Forces the texture to not create mip map information if true
  16094. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16095. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16096. * @param onLoad define a callback triggered when the texture has been loaded
  16097. * @param onError define a callback triggered when an error occurred during the loading session
  16098. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16099. * @returns the created texture
  16100. */
  16101. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16102. /**
  16103. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16104. * @param data Define the base64 payload without the data: prefix
  16105. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16106. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16107. * @param scene Define the scene the texture should belong to
  16108. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16109. * @param noMipmap Forces the texture to not create mip map information if true
  16110. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16111. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16112. * @param onLoad define a callback triggered when the texture has been loaded
  16113. * @param onError define a callback triggered when an error occurred during the loading session
  16114. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16115. * @returns the created texture
  16116. */
  16117. 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;
  16118. }
  16119. }
  16120. declare module "babylonjs/PostProcesses/postProcessManager" {
  16121. import { Nullable } from "babylonjs/types";
  16122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16124. import { Scene } from "babylonjs/scene";
  16125. /**
  16126. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16127. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16128. */
  16129. export class PostProcessManager {
  16130. private _scene;
  16131. private _indexBuffer;
  16132. private _vertexBuffers;
  16133. /**
  16134. * Creates a new instance PostProcess
  16135. * @param scene The scene that the post process is associated with.
  16136. */
  16137. constructor(scene: Scene);
  16138. private _prepareBuffers;
  16139. private _buildIndexBuffer;
  16140. /**
  16141. * Rebuilds the vertex buffers of the manager.
  16142. * @hidden
  16143. */
  16144. _rebuild(): void;
  16145. /**
  16146. * Prepares a frame to be run through a post process.
  16147. * @param sourceTexture The input texture to the post procesess. (default: null)
  16148. * @param postProcesses An array of post processes to be run. (default: null)
  16149. * @returns True if the post processes were able to be run.
  16150. * @hidden
  16151. */
  16152. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16153. /**
  16154. * Manually render a set of post processes to a texture.
  16155. * @param postProcesses An array of post processes to be run.
  16156. * @param targetTexture The target texture to render to.
  16157. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16158. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16159. * @param lodLevel defines which lod of the texture to render to
  16160. */
  16161. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16162. /**
  16163. * Finalize the result of the output of the postprocesses.
  16164. * @param doNotPresent If true the result will not be displayed to the screen.
  16165. * @param targetTexture The target texture to render to.
  16166. * @param faceIndex The index of the face to bind the target texture to.
  16167. * @param postProcesses The array of post processes to render.
  16168. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16169. * @hidden
  16170. */
  16171. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16172. /**
  16173. * Disposes of the post process manager.
  16174. */
  16175. dispose(): void;
  16176. }
  16177. }
  16178. declare module "babylonjs/Misc/gradients" {
  16179. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16180. /** Interface used by value gradients (color, factor, ...) */
  16181. export interface IValueGradient {
  16182. /**
  16183. * Gets or sets the gradient value (between 0 and 1)
  16184. */
  16185. gradient: number;
  16186. }
  16187. /** Class used to store color4 gradient */
  16188. export class ColorGradient implements IValueGradient {
  16189. /**
  16190. * Gets or sets the gradient value (between 0 and 1)
  16191. */
  16192. gradient: number;
  16193. /**
  16194. * Gets or sets first associated color
  16195. */
  16196. color1: Color4;
  16197. /**
  16198. * Gets or sets second associated color
  16199. */
  16200. color2?: Color4;
  16201. /**
  16202. * Will get a color picked randomly between color1 and color2.
  16203. * If color2 is undefined then color1 will be used
  16204. * @param result defines the target Color4 to store the result in
  16205. */
  16206. getColorToRef(result: Color4): void;
  16207. }
  16208. /** Class used to store color 3 gradient */
  16209. export class Color3Gradient implements IValueGradient {
  16210. /**
  16211. * Gets or sets the gradient value (between 0 and 1)
  16212. */
  16213. gradient: number;
  16214. /**
  16215. * Gets or sets the associated color
  16216. */
  16217. color: Color3;
  16218. }
  16219. /** Class used to store factor gradient */
  16220. export class FactorGradient implements IValueGradient {
  16221. /**
  16222. * Gets or sets the gradient value (between 0 and 1)
  16223. */
  16224. gradient: number;
  16225. /**
  16226. * Gets or sets first associated factor
  16227. */
  16228. factor1: number;
  16229. /**
  16230. * Gets or sets second associated factor
  16231. */
  16232. factor2?: number;
  16233. /**
  16234. * Will get a number picked randomly between factor1 and factor2.
  16235. * If factor2 is undefined then factor1 will be used
  16236. * @returns the picked number
  16237. */
  16238. getFactor(): number;
  16239. }
  16240. /**
  16241. * Helper used to simplify some generic gradient tasks
  16242. */
  16243. export class GradientHelper {
  16244. /**
  16245. * Gets the current gradient from an array of IValueGradient
  16246. * @param ratio defines the current ratio to get
  16247. * @param gradients defines the array of IValueGradient
  16248. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16249. */
  16250. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16251. }
  16252. }
  16253. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16254. import { Scene } from "babylonjs/scene";
  16255. import { ISceneComponent } from "babylonjs/sceneComponent";
  16256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16257. module "babylonjs/abstractScene" {
  16258. interface AbstractScene {
  16259. /**
  16260. * The list of procedural textures added to the scene
  16261. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16262. */
  16263. proceduralTextures: Array<ProceduralTexture>;
  16264. }
  16265. }
  16266. /**
  16267. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16268. * in a given scene.
  16269. */
  16270. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16271. /**
  16272. * The component name helpfull to identify the component in the list of scene components.
  16273. */
  16274. readonly name: string;
  16275. /**
  16276. * The scene the component belongs to.
  16277. */
  16278. scene: Scene;
  16279. /**
  16280. * Creates a new instance of the component for the given scene
  16281. * @param scene Defines the scene to register the component in
  16282. */
  16283. constructor(scene: Scene);
  16284. /**
  16285. * Registers the component in a given scene
  16286. */
  16287. register(): void;
  16288. /**
  16289. * Rebuilds the elements related to this component in case of
  16290. * context lost for instance.
  16291. */
  16292. rebuild(): void;
  16293. /**
  16294. * Disposes the component and the associated ressources.
  16295. */
  16296. dispose(): void;
  16297. private _beforeClear;
  16298. }
  16299. }
  16300. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16301. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16302. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16303. module "babylonjs/Engines/engine" {
  16304. interface Engine {
  16305. /**
  16306. * Creates a new render target cube texture
  16307. * @param size defines the size of the texture
  16308. * @param options defines the options used to create the texture
  16309. * @returns a new render target cube texture stored in an InternalTexture
  16310. */
  16311. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16312. }
  16313. }
  16314. }
  16315. declare module "babylonjs/Shaders/procedural.vertex" {
  16316. /** @hidden */
  16317. export var proceduralVertexShader: {
  16318. name: string;
  16319. shader: string;
  16320. };
  16321. }
  16322. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16323. import { Observable } from "babylonjs/Misc/observable";
  16324. import { Nullable } from "babylonjs/types";
  16325. import { Scene } from "babylonjs/scene";
  16326. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16327. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16328. import { Effect } from "babylonjs/Materials/effect";
  16329. import { Texture } from "babylonjs/Materials/Textures/texture";
  16330. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16331. import "babylonjs/Shaders/procedural.vertex";
  16332. /**
  16333. * 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.
  16334. * This is the base class of any Procedural texture and contains most of the shareable code.
  16335. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16336. */
  16337. export class ProceduralTexture extends Texture {
  16338. isCube: boolean;
  16339. /**
  16340. * Define if the texture is enabled or not (disabled texture will not render)
  16341. */
  16342. isEnabled: boolean;
  16343. /**
  16344. * Define if the texture must be cleared before rendering (default is true)
  16345. */
  16346. autoClear: boolean;
  16347. /**
  16348. * Callback called when the texture is generated
  16349. */
  16350. onGenerated: () => void;
  16351. /**
  16352. * Event raised when the texture is generated
  16353. */
  16354. onGeneratedObservable: Observable<ProceduralTexture>;
  16355. /** @hidden */
  16356. _generateMipMaps: boolean;
  16357. /** @hidden **/
  16358. _effect: Effect;
  16359. /** @hidden */
  16360. _textures: {
  16361. [key: string]: Texture;
  16362. };
  16363. private _size;
  16364. private _currentRefreshId;
  16365. private _refreshRate;
  16366. private _vertexBuffers;
  16367. private _indexBuffer;
  16368. private _uniforms;
  16369. private _samplers;
  16370. private _fragment;
  16371. private _floats;
  16372. private _ints;
  16373. private _floatsArrays;
  16374. private _colors3;
  16375. private _colors4;
  16376. private _vectors2;
  16377. private _vectors3;
  16378. private _matrices;
  16379. private _fallbackTexture;
  16380. private _fallbackTextureUsed;
  16381. private _engine;
  16382. private _cachedDefines;
  16383. private _contentUpdateId;
  16384. private _contentData;
  16385. /**
  16386. * Instantiates a new procedural texture.
  16387. * 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.
  16388. * This is the base class of any Procedural texture and contains most of the shareable code.
  16389. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16390. * @param name Define the name of the texture
  16391. * @param size Define the size of the texture to create
  16392. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16393. * @param scene Define the scene the texture belongs to
  16394. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16395. * @param generateMipMaps Define if the texture should creates mip maps or not
  16396. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16397. */
  16398. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16399. /**
  16400. * The effect that is created when initializing the post process.
  16401. * @returns The created effect corresponding the the postprocess.
  16402. */
  16403. getEffect(): Effect;
  16404. /**
  16405. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16406. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16407. */
  16408. getContent(): Nullable<ArrayBufferView>;
  16409. private _createIndexBuffer;
  16410. /** @hidden */
  16411. _rebuild(): void;
  16412. /**
  16413. * Resets the texture in order to recreate its associated resources.
  16414. * This can be called in case of context loss
  16415. */
  16416. reset(): void;
  16417. protected _getDefines(): string;
  16418. /**
  16419. * Is the texture ready to be used ? (rendered at least once)
  16420. * @returns true if ready, otherwise, false.
  16421. */
  16422. isReady(): boolean;
  16423. /**
  16424. * Resets the refresh counter of the texture and start bak from scratch.
  16425. * Could be useful to regenerate the texture if it is setup to render only once.
  16426. */
  16427. resetRefreshCounter(): void;
  16428. /**
  16429. * Set the fragment shader to use in order to render the texture.
  16430. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16431. */
  16432. setFragment(fragment: any): void;
  16433. /**
  16434. * Define the refresh rate of the texture or the rendering frequency.
  16435. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16436. */
  16437. refreshRate: number;
  16438. /** @hidden */
  16439. _shouldRender(): boolean;
  16440. /**
  16441. * Get the size the texture is rendering at.
  16442. * @returns the size (texture is always squared)
  16443. */
  16444. getRenderSize(): number;
  16445. /**
  16446. * Resize the texture to new value.
  16447. * @param size Define the new size the texture should have
  16448. * @param generateMipMaps Define whether the new texture should create mip maps
  16449. */
  16450. resize(size: number, generateMipMaps: boolean): void;
  16451. private _checkUniform;
  16452. /**
  16453. * Set a texture in the shader program used to render.
  16454. * @param name Define the name of the uniform samplers as defined in the shader
  16455. * @param texture Define the texture to bind to this sampler
  16456. * @return the texture itself allowing "fluent" like uniform updates
  16457. */
  16458. setTexture(name: string, texture: Texture): ProceduralTexture;
  16459. /**
  16460. * Set a float in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the texture itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloat(name: string, value: number): ProceduralTexture;
  16466. /**
  16467. * Set a int in the shader.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the texture itself allowing "fluent" like uniform updates
  16471. */
  16472. setInt(name: string, value: number): ProceduralTexture;
  16473. /**
  16474. * Set an array of floats in the shader.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the texture itself allowing "fluent" like uniform updates
  16478. */
  16479. setFloats(name: string, value: number[]): ProceduralTexture;
  16480. /**
  16481. * Set a vec3 in the shader from a Color3.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the texture itself allowing "fluent" like uniform updates
  16485. */
  16486. setColor3(name: string, value: Color3): ProceduralTexture;
  16487. /**
  16488. * Set a vec4 in the shader from a Color4.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the texture itself allowing "fluent" like uniform updates
  16492. */
  16493. setColor4(name: string, value: Color4): ProceduralTexture;
  16494. /**
  16495. * Set a vec2 in the shader from a Vector2.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the texture itself allowing "fluent" like uniform updates
  16499. */
  16500. setVector2(name: string, value: Vector2): ProceduralTexture;
  16501. /**
  16502. * Set a vec3 in the shader from a Vector3.
  16503. * @param name Define the name of the uniform as defined in the shader
  16504. * @param value Define the value to give to the uniform
  16505. * @return the texture itself allowing "fluent" like uniform updates
  16506. */
  16507. setVector3(name: string, value: Vector3): ProceduralTexture;
  16508. /**
  16509. * Set a mat4 in the shader from a MAtrix.
  16510. * @param name Define the name of the uniform as defined in the shader
  16511. * @param value Define the value to give to the uniform
  16512. * @return the texture itself allowing "fluent" like uniform updates
  16513. */
  16514. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16515. /**
  16516. * Render the texture to its associated render target.
  16517. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16518. */
  16519. render(useCameraPostProcess?: boolean): void;
  16520. /**
  16521. * Clone the texture.
  16522. * @returns the cloned texture
  16523. */
  16524. clone(): ProceduralTexture;
  16525. /**
  16526. * Dispose the texture and release its asoociated resources.
  16527. */
  16528. dispose(): void;
  16529. }
  16530. }
  16531. declare module "babylonjs/Particles/baseParticleSystem" {
  16532. import { Nullable } from "babylonjs/types";
  16533. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16535. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16536. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16537. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16538. import { Scene } from "babylonjs/scene";
  16539. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16540. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import { Color4 } from "babylonjs/Maths/math.color";
  16543. import { Animation } from "babylonjs/Animations/animation";
  16544. /**
  16545. * This represents the base class for particle system in Babylon.
  16546. * 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.
  16547. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16548. * @example https://doc.babylonjs.com/babylon101/particles
  16549. */
  16550. export class BaseParticleSystem {
  16551. /**
  16552. * Source color is added to the destination color without alpha affecting the result
  16553. */
  16554. static BLENDMODE_ONEONE: number;
  16555. /**
  16556. * Blend current color and particle color using particle’s alpha
  16557. */
  16558. static BLENDMODE_STANDARD: number;
  16559. /**
  16560. * Add current color and particle color multiplied by particle’s alpha
  16561. */
  16562. static BLENDMODE_ADD: number;
  16563. /**
  16564. * Multiply current color with particle color
  16565. */
  16566. static BLENDMODE_MULTIPLY: number;
  16567. /**
  16568. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16569. */
  16570. static BLENDMODE_MULTIPLYADD: number;
  16571. /**
  16572. * List of animations used by the particle system.
  16573. */
  16574. animations: Animation[];
  16575. /**
  16576. * The id of the Particle system.
  16577. */
  16578. id: string;
  16579. /**
  16580. * The friendly name of the Particle system.
  16581. */
  16582. name: string;
  16583. /**
  16584. * The rendering group used by the Particle system to chose when to render.
  16585. */
  16586. renderingGroupId: number;
  16587. /**
  16588. * The emitter represents the Mesh or position we are attaching the particle system to.
  16589. */
  16590. emitter: Nullable<AbstractMesh | Vector3>;
  16591. /**
  16592. * The maximum number of particles to emit per frame
  16593. */
  16594. emitRate: number;
  16595. /**
  16596. * If you want to launch only a few particles at once, that can be done, as well.
  16597. */
  16598. manualEmitCount: number;
  16599. /**
  16600. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16601. */
  16602. updateSpeed: number;
  16603. /**
  16604. * The amount of time the particle system is running (depends of the overall update speed).
  16605. */
  16606. targetStopDuration: number;
  16607. /**
  16608. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16609. */
  16610. disposeOnStop: boolean;
  16611. /**
  16612. * Minimum power of emitting particles.
  16613. */
  16614. minEmitPower: number;
  16615. /**
  16616. * Maximum power of emitting particles.
  16617. */
  16618. maxEmitPower: number;
  16619. /**
  16620. * Minimum life time of emitting particles.
  16621. */
  16622. minLifeTime: number;
  16623. /**
  16624. * Maximum life time of emitting particles.
  16625. */
  16626. maxLifeTime: number;
  16627. /**
  16628. * Minimum Size of emitting particles.
  16629. */
  16630. minSize: number;
  16631. /**
  16632. * Maximum Size of emitting particles.
  16633. */
  16634. maxSize: number;
  16635. /**
  16636. * Minimum scale of emitting particles on X axis.
  16637. */
  16638. minScaleX: number;
  16639. /**
  16640. * Maximum scale of emitting particles on X axis.
  16641. */
  16642. maxScaleX: number;
  16643. /**
  16644. * Minimum scale of emitting particles on Y axis.
  16645. */
  16646. minScaleY: number;
  16647. /**
  16648. * Maximum scale of emitting particles on Y axis.
  16649. */
  16650. maxScaleY: number;
  16651. /**
  16652. * Gets or sets the minimal initial rotation in radians.
  16653. */
  16654. minInitialRotation: number;
  16655. /**
  16656. * Gets or sets the maximal initial rotation in radians.
  16657. */
  16658. maxInitialRotation: number;
  16659. /**
  16660. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16661. */
  16662. minAngularSpeed: number;
  16663. /**
  16664. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16665. */
  16666. maxAngularSpeed: number;
  16667. /**
  16668. * The texture used to render each particle. (this can be a spritesheet)
  16669. */
  16670. particleTexture: Nullable<Texture>;
  16671. /**
  16672. * The layer mask we are rendering the particles through.
  16673. */
  16674. layerMask: number;
  16675. /**
  16676. * This can help using your own shader to render the particle system.
  16677. * The according effect will be created
  16678. */
  16679. customShader: any;
  16680. /**
  16681. * By default particle system starts as soon as they are created. This prevents the
  16682. * automatic start to happen and let you decide when to start emitting particles.
  16683. */
  16684. preventAutoStart: boolean;
  16685. private _noiseTexture;
  16686. /**
  16687. * Gets or sets a texture used to add random noise to particle positions
  16688. */
  16689. noiseTexture: Nullable<ProceduralTexture>;
  16690. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16691. noiseStrength: Vector3;
  16692. /**
  16693. * Callback triggered when the particle animation is ending.
  16694. */
  16695. onAnimationEnd: Nullable<() => void>;
  16696. /**
  16697. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16698. */
  16699. blendMode: number;
  16700. /**
  16701. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16702. * to override the particles.
  16703. */
  16704. forceDepthWrite: boolean;
  16705. /** 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 */
  16706. preWarmCycles: number;
  16707. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16708. preWarmStepOffset: number;
  16709. /**
  16710. * 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)
  16711. */
  16712. spriteCellChangeSpeed: number;
  16713. /**
  16714. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16715. */
  16716. startSpriteCellID: number;
  16717. /**
  16718. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16719. */
  16720. endSpriteCellID: number;
  16721. /**
  16722. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16723. */
  16724. spriteCellWidth: number;
  16725. /**
  16726. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16727. */
  16728. spriteCellHeight: number;
  16729. /**
  16730. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16731. */
  16732. spriteRandomStartCell: boolean;
  16733. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16734. translationPivot: Vector2;
  16735. /** @hidden */
  16736. protected _isAnimationSheetEnabled: boolean;
  16737. /**
  16738. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16739. */
  16740. beginAnimationOnStart: boolean;
  16741. /**
  16742. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16743. */
  16744. beginAnimationFrom: number;
  16745. /**
  16746. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16747. */
  16748. beginAnimationTo: number;
  16749. /**
  16750. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16751. */
  16752. beginAnimationLoop: boolean;
  16753. /**
  16754. * Gets or sets a world offset applied to all particles
  16755. */
  16756. worldOffset: Vector3;
  16757. /**
  16758. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16759. */
  16760. isAnimationSheetEnabled: boolean;
  16761. /**
  16762. * Get hosting scene
  16763. * @returns the scene
  16764. */
  16765. getScene(): Scene;
  16766. /**
  16767. * You can use gravity if you want to give an orientation to your particles.
  16768. */
  16769. gravity: Vector3;
  16770. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16771. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16772. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16773. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16774. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16775. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16776. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16777. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16778. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16779. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16780. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16781. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16782. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16783. /**
  16784. * Defines the delay in milliseconds before starting the system (0 by default)
  16785. */
  16786. startDelay: number;
  16787. /**
  16788. * Gets the current list of drag gradients.
  16789. * You must use addDragGradient and removeDragGradient to udpate this list
  16790. * @returns the list of drag gradients
  16791. */
  16792. getDragGradients(): Nullable<Array<FactorGradient>>;
  16793. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16794. limitVelocityDamping: number;
  16795. /**
  16796. * Gets the current list of limit velocity gradients.
  16797. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16798. * @returns the list of limit velocity gradients
  16799. */
  16800. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16801. /**
  16802. * Gets the current list of color gradients.
  16803. * You must use addColorGradient and removeColorGradient to udpate this list
  16804. * @returns the list of color gradients
  16805. */
  16806. getColorGradients(): Nullable<Array<ColorGradient>>;
  16807. /**
  16808. * Gets the current list of size gradients.
  16809. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16810. * @returns the list of size gradients
  16811. */
  16812. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16813. /**
  16814. * Gets the current list of color remap gradients.
  16815. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16816. * @returns the list of color remap gradients
  16817. */
  16818. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16819. /**
  16820. * Gets the current list of alpha remap gradients.
  16821. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16822. * @returns the list of alpha remap gradients
  16823. */
  16824. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16825. /**
  16826. * Gets the current list of life time gradients.
  16827. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16828. * @returns the list of life time gradients
  16829. */
  16830. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16831. /**
  16832. * Gets the current list of angular speed gradients.
  16833. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16834. * @returns the list of angular speed gradients
  16835. */
  16836. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16837. /**
  16838. * Gets the current list of velocity gradients.
  16839. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16840. * @returns the list of velocity gradients
  16841. */
  16842. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16843. /**
  16844. * Gets the current list of start size gradients.
  16845. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16846. * @returns the list of start size gradients
  16847. */
  16848. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16849. /**
  16850. * Gets the current list of emit rate gradients.
  16851. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16852. * @returns the list of emit rate gradients
  16853. */
  16854. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16855. /**
  16856. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16857. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16858. */
  16859. direction1: Vector3;
  16860. /**
  16861. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16862. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16863. */
  16864. direction2: Vector3;
  16865. /**
  16866. * 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.
  16867. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16868. */
  16869. minEmitBox: Vector3;
  16870. /**
  16871. * 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.
  16872. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16873. */
  16874. maxEmitBox: Vector3;
  16875. /**
  16876. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16877. */
  16878. color1: Color4;
  16879. /**
  16880. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16881. */
  16882. color2: Color4;
  16883. /**
  16884. * Color the particle will have at the end of its lifetime
  16885. */
  16886. colorDead: Color4;
  16887. /**
  16888. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16889. */
  16890. textureMask: Color4;
  16891. /**
  16892. * The particle emitter type defines the emitter used by the particle system.
  16893. * It can be for example box, sphere, or cone...
  16894. */
  16895. particleEmitterType: IParticleEmitterType;
  16896. /** @hidden */
  16897. _isSubEmitter: boolean;
  16898. /**
  16899. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16900. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16901. */
  16902. billboardMode: number;
  16903. protected _isBillboardBased: boolean;
  16904. /**
  16905. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16906. */
  16907. isBillboardBased: boolean;
  16908. /**
  16909. * The scene the particle system belongs to.
  16910. */
  16911. protected _scene: Scene;
  16912. /**
  16913. * Local cache of defines for image processing.
  16914. */
  16915. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16916. /**
  16917. * Default configuration related to image processing available in the standard Material.
  16918. */
  16919. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16920. /**
  16921. * Gets the image processing configuration used either in this material.
  16922. */
  16923. /**
  16924. * Sets the Default image processing configuration used either in the this material.
  16925. *
  16926. * If sets to null, the scene one is in use.
  16927. */
  16928. imageProcessingConfiguration: ImageProcessingConfiguration;
  16929. /**
  16930. * Attaches a new image processing configuration to the Standard Material.
  16931. * @param configuration
  16932. */
  16933. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16934. /** @hidden */
  16935. protected _reset(): void;
  16936. /** @hidden */
  16937. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16938. /**
  16939. * Instantiates a particle system.
  16940. * 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.
  16941. * @param name The name of the particle system
  16942. */
  16943. constructor(name: string);
  16944. /**
  16945. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16946. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16947. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16948. * @returns the emitter
  16949. */
  16950. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16951. /**
  16952. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16953. * @param radius The radius of the hemisphere to emit from
  16954. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16955. * @returns the emitter
  16956. */
  16957. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16958. /**
  16959. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16960. * @param radius The radius of the sphere to emit from
  16961. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16962. * @returns the emitter
  16963. */
  16964. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16965. /**
  16966. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16967. * @param radius The radius of the sphere to emit from
  16968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16970. * @returns the emitter
  16971. */
  16972. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16973. /**
  16974. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16975. * @param radius The radius of the emission cylinder
  16976. * @param height The height of the emission cylinder
  16977. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16978. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16979. * @returns the emitter
  16980. */
  16981. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16982. /**
  16983. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16984. * @param radius The radius of the cylinder to emit from
  16985. * @param height The height of the emission cylinder
  16986. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16989. * @returns the emitter
  16990. */
  16991. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16992. /**
  16993. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16994. * @param radius The radius of the cone to emit from
  16995. * @param angle The base angle of the cone
  16996. * @returns the emitter
  16997. */
  16998. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16999. /**
  17000. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17001. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17002. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17003. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17004. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17005. * @returns the emitter
  17006. */
  17007. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17008. }
  17009. }
  17010. declare module "babylonjs/Particles/subEmitter" {
  17011. import { Scene } from "babylonjs/scene";
  17012. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17013. /**
  17014. * Type of sub emitter
  17015. */
  17016. export enum SubEmitterType {
  17017. /**
  17018. * Attached to the particle over it's lifetime
  17019. */
  17020. ATTACHED = 0,
  17021. /**
  17022. * Created when the particle dies
  17023. */
  17024. END = 1
  17025. }
  17026. /**
  17027. * Sub emitter class used to emit particles from an existing particle
  17028. */
  17029. export class SubEmitter {
  17030. /**
  17031. * the particle system to be used by the sub emitter
  17032. */
  17033. particleSystem: ParticleSystem;
  17034. /**
  17035. * Type of the submitter (Default: END)
  17036. */
  17037. type: SubEmitterType;
  17038. /**
  17039. * 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)
  17040. * Note: This only is supported when using an emitter of type Mesh
  17041. */
  17042. inheritDirection: boolean;
  17043. /**
  17044. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17045. */
  17046. inheritedVelocityAmount: number;
  17047. /**
  17048. * Creates a sub emitter
  17049. * @param particleSystem the particle system to be used by the sub emitter
  17050. */
  17051. constructor(
  17052. /**
  17053. * the particle system to be used by the sub emitter
  17054. */
  17055. particleSystem: ParticleSystem);
  17056. /**
  17057. * Clones the sub emitter
  17058. * @returns the cloned sub emitter
  17059. */
  17060. clone(): SubEmitter;
  17061. /**
  17062. * Serialize current object to a JSON object
  17063. * @returns the serialized object
  17064. */
  17065. serialize(): any;
  17066. /** @hidden */
  17067. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17068. /**
  17069. * Creates a new SubEmitter from a serialized JSON version
  17070. * @param serializationObject defines the JSON object to read from
  17071. * @param scene defines the hosting scene
  17072. * @param rootUrl defines the rootUrl for data loading
  17073. * @returns a new SubEmitter
  17074. */
  17075. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17076. /** Release associated resources */
  17077. dispose(): void;
  17078. }
  17079. }
  17080. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17081. /** @hidden */
  17082. export var clipPlaneFragmentDeclaration: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17088. /** @hidden */
  17089. export var imageProcessingDeclaration: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17095. /** @hidden */
  17096. export var imageProcessingFunctions: {
  17097. name: string;
  17098. shader: string;
  17099. };
  17100. }
  17101. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17102. /** @hidden */
  17103. export var clipPlaneFragment: {
  17104. name: string;
  17105. shader: string;
  17106. };
  17107. }
  17108. declare module "babylonjs/Shaders/particles.fragment" {
  17109. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17110. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17111. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17112. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17113. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17114. /** @hidden */
  17115. export var particlesPixelShader: {
  17116. name: string;
  17117. shader: string;
  17118. };
  17119. }
  17120. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17121. /** @hidden */
  17122. export var clipPlaneVertexDeclaration: {
  17123. name: string;
  17124. shader: string;
  17125. };
  17126. }
  17127. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17128. /** @hidden */
  17129. export var clipPlaneVertex: {
  17130. name: string;
  17131. shader: string;
  17132. };
  17133. }
  17134. declare module "babylonjs/Shaders/particles.vertex" {
  17135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17136. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17137. /** @hidden */
  17138. export var particlesVertexShader: {
  17139. name: string;
  17140. shader: string;
  17141. };
  17142. }
  17143. declare module "babylonjs/Particles/particleSystem" {
  17144. import { Nullable } from "babylonjs/types";
  17145. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17146. import { Observable } from "babylonjs/Misc/observable";
  17147. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17148. import { Effect } from "babylonjs/Materials/effect";
  17149. import { Scene, IDisposable } from "babylonjs/scene";
  17150. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17151. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17152. import { Particle } from "babylonjs/Particles/particle";
  17153. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17154. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17155. import "babylonjs/Shaders/particles.fragment";
  17156. import "babylonjs/Shaders/particles.vertex";
  17157. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17158. /**
  17159. * This represents a particle system in Babylon.
  17160. * 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.
  17161. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17162. * @example https://doc.babylonjs.com/babylon101/particles
  17163. */
  17164. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17165. /**
  17166. * Billboard mode will only apply to Y axis
  17167. */
  17168. static readonly BILLBOARDMODE_Y: number;
  17169. /**
  17170. * Billboard mode will apply to all axes
  17171. */
  17172. static readonly BILLBOARDMODE_ALL: number;
  17173. /**
  17174. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17175. */
  17176. static readonly BILLBOARDMODE_STRETCHED: number;
  17177. /**
  17178. * This function can be defined to provide custom update for active particles.
  17179. * This function will be called instead of regular update (age, position, color, etc.).
  17180. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17181. */
  17182. updateFunction: (particles: Particle[]) => void;
  17183. private _emitterWorldMatrix;
  17184. /**
  17185. * This function can be defined to specify initial direction for every new particle.
  17186. * It by default use the emitterType defined function
  17187. */
  17188. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17189. /**
  17190. * This function can be defined to specify initial position for every new particle.
  17191. * It by default use the emitterType defined function
  17192. */
  17193. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17194. /**
  17195. * @hidden
  17196. */
  17197. _inheritedVelocityOffset: Vector3;
  17198. /**
  17199. * An event triggered when the system is disposed
  17200. */
  17201. onDisposeObservable: Observable<ParticleSystem>;
  17202. private _onDisposeObserver;
  17203. /**
  17204. * Sets a callback that will be triggered when the system is disposed
  17205. */
  17206. onDispose: () => void;
  17207. private _particles;
  17208. private _epsilon;
  17209. private _capacity;
  17210. private _stockParticles;
  17211. private _newPartsExcess;
  17212. private _vertexData;
  17213. private _vertexBuffer;
  17214. private _vertexBuffers;
  17215. private _spriteBuffer;
  17216. private _indexBuffer;
  17217. private _effect;
  17218. private _customEffect;
  17219. private _cachedDefines;
  17220. private _scaledColorStep;
  17221. private _colorDiff;
  17222. private _scaledDirection;
  17223. private _scaledGravity;
  17224. private _currentRenderId;
  17225. private _alive;
  17226. private _useInstancing;
  17227. private _started;
  17228. private _stopped;
  17229. private _actualFrame;
  17230. private _scaledUpdateSpeed;
  17231. private _vertexBufferSize;
  17232. /** @hidden */
  17233. _currentEmitRateGradient: Nullable<FactorGradient>;
  17234. /** @hidden */
  17235. _currentEmitRate1: number;
  17236. /** @hidden */
  17237. _currentEmitRate2: number;
  17238. /** @hidden */
  17239. _currentStartSizeGradient: Nullable<FactorGradient>;
  17240. /** @hidden */
  17241. _currentStartSize1: number;
  17242. /** @hidden */
  17243. _currentStartSize2: number;
  17244. private readonly _rawTextureWidth;
  17245. private _rampGradientsTexture;
  17246. private _useRampGradients;
  17247. /** Gets or sets a boolean indicating that ramp gradients must be used
  17248. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17249. */
  17250. useRampGradients: boolean;
  17251. /**
  17252. * 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.
  17253. * 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: [])
  17254. */
  17255. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17256. private _subEmitters;
  17257. /**
  17258. * @hidden
  17259. * If the particle systems emitter should be disposed when the particle system is disposed
  17260. */
  17261. _disposeEmitterOnDispose: boolean;
  17262. /**
  17263. * The current active Sub-systems, this property is used by the root particle system only.
  17264. */
  17265. activeSubSystems: Array<ParticleSystem>;
  17266. private _rootParticleSystem;
  17267. /**
  17268. * Gets the current list of active particles
  17269. */
  17270. readonly particles: Particle[];
  17271. /**
  17272. * Returns the string "ParticleSystem"
  17273. * @returns a string containing the class name
  17274. */
  17275. getClassName(): string;
  17276. /**
  17277. * Instantiates a particle system.
  17278. * 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.
  17279. * @param name The name of the particle system
  17280. * @param capacity The max number of particles alive at the same time
  17281. * @param scene The scene the particle system belongs to
  17282. * @param customEffect a custom effect used to change the way particles are rendered by default
  17283. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17284. * @param epsilon Offset used to render the particles
  17285. */
  17286. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17287. private _addFactorGradient;
  17288. private _removeFactorGradient;
  17289. /**
  17290. * Adds a new life time gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param factor defines the life time factor to affect to the specified gradient
  17293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17294. * @returns the current particle system
  17295. */
  17296. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17297. /**
  17298. * Remove a specific life time gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns the current particle system
  17301. */
  17302. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17303. /**
  17304. * Adds a new size gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param factor defines the size factor to affect to the specified gradient
  17307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17308. * @returns the current particle system
  17309. */
  17310. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific size gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeSizeGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new color remap gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param min defines the color remap minimal range
  17321. * @param max defines the color remap maximal range
  17322. * @returns the current particle system
  17323. */
  17324. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific color remap gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeColorRemapGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new alpha remap gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param min defines the alpha remap minimal range
  17335. * @param max defines the alpha remap maximal range
  17336. * @returns the current particle system
  17337. */
  17338. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific alpha remap gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new angular speed gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the angular speed to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific angular speed gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new velocity gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the velocity to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific velocity gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeVelocityGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new limit velocity gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the limit velocity value to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific limit velocity gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new drag gradient
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the drag value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific drag gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeDragGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the emit rate value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific emit rate gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeEmitRateGradient(gradient: number): IParticleSystem;
  17415. /**
  17416. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17417. * @param gradient defines the gradient to use (between 0 and 1)
  17418. * @param factor defines the start size value to affect to the specified gradient
  17419. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17420. * @returns the current particle system
  17421. */
  17422. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17423. /**
  17424. * Remove a specific start size gradient
  17425. * @param gradient defines the gradient to remove
  17426. * @returns the current particle system
  17427. */
  17428. removeStartSizeGradient(gradient: number): IParticleSystem;
  17429. private _createRampGradientTexture;
  17430. /**
  17431. * Gets the current list of ramp gradients.
  17432. * You must use addRampGradient and removeRampGradient to udpate this list
  17433. * @returns the list of ramp gradients
  17434. */
  17435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17436. /**
  17437. * Adds a new ramp gradient used to remap particle colors
  17438. * @param gradient defines the gradient to use (between 0 and 1)
  17439. * @param color defines the color to affect to the specified gradient
  17440. * @returns the current particle system
  17441. */
  17442. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17443. /**
  17444. * Remove a specific ramp gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns the current particle system
  17447. */
  17448. removeRampGradient(gradient: number): ParticleSystem;
  17449. /**
  17450. * Adds a new color gradient
  17451. * @param gradient defines the gradient to use (between 0 and 1)
  17452. * @param color1 defines the color to affect to the specified gradient
  17453. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17454. * @returns this particle system
  17455. */
  17456. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17457. /**
  17458. * Remove a specific color gradient
  17459. * @param gradient defines the gradient to remove
  17460. * @returns this particle system
  17461. */
  17462. removeColorGradient(gradient: number): IParticleSystem;
  17463. private _fetchR;
  17464. protected _reset(): void;
  17465. private _resetEffect;
  17466. private _createVertexBuffers;
  17467. private _createIndexBuffer;
  17468. /**
  17469. * Gets the maximum number of particles active at the same time.
  17470. * @returns The max number of active particles.
  17471. */
  17472. getCapacity(): number;
  17473. /**
  17474. * Gets whether there are still active particles in the system.
  17475. * @returns True if it is alive, otherwise false.
  17476. */
  17477. isAlive(): boolean;
  17478. /**
  17479. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17480. * @returns True if it has been started, otherwise false.
  17481. */
  17482. isStarted(): boolean;
  17483. private _prepareSubEmitterInternalArray;
  17484. /**
  17485. * Starts the particle system and begins to emit
  17486. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17487. */
  17488. start(delay?: number): void;
  17489. /**
  17490. * Stops the particle system.
  17491. * @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.
  17492. */
  17493. stop(stopSubEmitters?: boolean): void;
  17494. /**
  17495. * Remove all active particles
  17496. */
  17497. reset(): void;
  17498. /**
  17499. * @hidden (for internal use only)
  17500. */
  17501. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17502. /**
  17503. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17504. * Its lifetime will start back at 0.
  17505. */
  17506. recycleParticle: (particle: Particle) => void;
  17507. private _stopSubEmitters;
  17508. private _createParticle;
  17509. private _removeFromRoot;
  17510. private _emitFromParticle;
  17511. private _update;
  17512. /** @hidden */
  17513. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17514. /** @hidden */
  17515. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17516. /** @hidden */
  17517. private _getEffect;
  17518. /**
  17519. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17520. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17521. */
  17522. animate(preWarmOnly?: boolean): void;
  17523. private _appendParticleVertices;
  17524. /**
  17525. * Rebuilds the particle system.
  17526. */
  17527. rebuild(): void;
  17528. /**
  17529. * Is this system ready to be used/rendered
  17530. * @return true if the system is ready
  17531. */
  17532. isReady(): boolean;
  17533. private _render;
  17534. /**
  17535. * Renders the particle system in its current state.
  17536. * @returns the current number of particles
  17537. */
  17538. render(): number;
  17539. /**
  17540. * Disposes the particle system and free the associated resources
  17541. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17542. */
  17543. dispose(disposeTexture?: boolean): void;
  17544. /**
  17545. * Clones the particle system.
  17546. * @param name The name of the cloned object
  17547. * @param newEmitter The new emitter to use
  17548. * @returns the cloned particle system
  17549. */
  17550. clone(name: string, newEmitter: any): ParticleSystem;
  17551. /**
  17552. * Serializes the particle system to a JSON object.
  17553. * @returns the JSON object
  17554. */
  17555. serialize(): any;
  17556. /** @hidden */
  17557. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17558. /** @hidden */
  17559. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17560. /**
  17561. * Parses a JSON object to create a particle system.
  17562. * @param parsedParticleSystem The JSON object to parse
  17563. * @param scene The scene to create the particle system in
  17564. * @param rootUrl The root url to use to load external dependencies like texture
  17565. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17566. * @returns the Parsed particle system
  17567. */
  17568. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17569. }
  17570. }
  17571. declare module "babylonjs/Particles/particle" {
  17572. import { Nullable } from "babylonjs/types";
  17573. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17574. import { Color4 } from "babylonjs/Maths/math.color";
  17575. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17576. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17577. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17578. /**
  17579. * A particle represents one of the element emitted by a particle system.
  17580. * This is mainly define by its coordinates, direction, velocity and age.
  17581. */
  17582. export class Particle {
  17583. /**
  17584. * The particle system the particle belongs to.
  17585. */
  17586. particleSystem: ParticleSystem;
  17587. private static _Count;
  17588. /**
  17589. * Unique ID of the particle
  17590. */
  17591. id: number;
  17592. /**
  17593. * The world position of the particle in the scene.
  17594. */
  17595. position: Vector3;
  17596. /**
  17597. * The world direction of the particle in the scene.
  17598. */
  17599. direction: Vector3;
  17600. /**
  17601. * The color of the particle.
  17602. */
  17603. color: Color4;
  17604. /**
  17605. * The color change of the particle per step.
  17606. */
  17607. colorStep: Color4;
  17608. /**
  17609. * Defines how long will the life of the particle be.
  17610. */
  17611. lifeTime: number;
  17612. /**
  17613. * The current age of the particle.
  17614. */
  17615. age: number;
  17616. /**
  17617. * The current size of the particle.
  17618. */
  17619. size: number;
  17620. /**
  17621. * The current scale of the particle.
  17622. */
  17623. scale: Vector2;
  17624. /**
  17625. * The current angle of the particle.
  17626. */
  17627. angle: number;
  17628. /**
  17629. * Defines how fast is the angle changing.
  17630. */
  17631. angularSpeed: number;
  17632. /**
  17633. * Defines the cell index used by the particle to be rendered from a sprite.
  17634. */
  17635. cellIndex: number;
  17636. /**
  17637. * The information required to support color remapping
  17638. */
  17639. remapData: Vector4;
  17640. /** @hidden */
  17641. _randomCellOffset?: number;
  17642. /** @hidden */
  17643. _initialDirection: Nullable<Vector3>;
  17644. /** @hidden */
  17645. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17646. /** @hidden */
  17647. _initialStartSpriteCellID: number;
  17648. /** @hidden */
  17649. _initialEndSpriteCellID: number;
  17650. /** @hidden */
  17651. _currentColorGradient: Nullable<ColorGradient>;
  17652. /** @hidden */
  17653. _currentColor1: Color4;
  17654. /** @hidden */
  17655. _currentColor2: Color4;
  17656. /** @hidden */
  17657. _currentSizeGradient: Nullable<FactorGradient>;
  17658. /** @hidden */
  17659. _currentSize1: number;
  17660. /** @hidden */
  17661. _currentSize2: number;
  17662. /** @hidden */
  17663. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17664. /** @hidden */
  17665. _currentAngularSpeed1: number;
  17666. /** @hidden */
  17667. _currentAngularSpeed2: number;
  17668. /** @hidden */
  17669. _currentVelocityGradient: Nullable<FactorGradient>;
  17670. /** @hidden */
  17671. _currentVelocity1: number;
  17672. /** @hidden */
  17673. _currentVelocity2: number;
  17674. /** @hidden */
  17675. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17676. /** @hidden */
  17677. _currentLimitVelocity1: number;
  17678. /** @hidden */
  17679. _currentLimitVelocity2: number;
  17680. /** @hidden */
  17681. _currentDragGradient: Nullable<FactorGradient>;
  17682. /** @hidden */
  17683. _currentDrag1: number;
  17684. /** @hidden */
  17685. _currentDrag2: number;
  17686. /** @hidden */
  17687. _randomNoiseCoordinates1: Vector3;
  17688. /** @hidden */
  17689. _randomNoiseCoordinates2: Vector3;
  17690. /**
  17691. * Creates a new instance Particle
  17692. * @param particleSystem the particle system the particle belongs to
  17693. */
  17694. constructor(
  17695. /**
  17696. * The particle system the particle belongs to.
  17697. */
  17698. particleSystem: ParticleSystem);
  17699. private updateCellInfoFromSystem;
  17700. /**
  17701. * Defines how the sprite cell index is updated for the particle
  17702. */
  17703. updateCellIndex(): void;
  17704. /** @hidden */
  17705. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17706. /** @hidden */
  17707. _inheritParticleInfoToSubEmitters(): void;
  17708. /** @hidden */
  17709. _reset(): void;
  17710. /**
  17711. * Copy the properties of particle to another one.
  17712. * @param other the particle to copy the information to.
  17713. */
  17714. copyTo(other: Particle): void;
  17715. }
  17716. }
  17717. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17718. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17719. import { Effect } from "babylonjs/Materials/effect";
  17720. import { Particle } from "babylonjs/Particles/particle";
  17721. /**
  17722. * Particle emitter represents a volume emitting particles.
  17723. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17724. */
  17725. export interface IParticleEmitterType {
  17726. /**
  17727. * Called by the particle System when the direction is computed for the created particle.
  17728. * @param worldMatrix is the world matrix of the particle system
  17729. * @param directionToUpdate is the direction vector to update with the result
  17730. * @param particle is the particle we are computed the direction for
  17731. */
  17732. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17733. /**
  17734. * Called by the particle System when the position is computed for the created particle.
  17735. * @param worldMatrix is the world matrix of the particle system
  17736. * @param positionToUpdate is the position vector to update with the result
  17737. * @param particle is the particle we are computed the position for
  17738. */
  17739. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17740. /**
  17741. * Clones the current emitter and returns a copy of it
  17742. * @returns the new emitter
  17743. */
  17744. clone(): IParticleEmitterType;
  17745. /**
  17746. * Called by the GPUParticleSystem to setup the update shader
  17747. * @param effect defines the update shader
  17748. */
  17749. applyToShader(effect: Effect): void;
  17750. /**
  17751. * Returns a string to use to update the GPU particles update shader
  17752. * @returns the effect defines string
  17753. */
  17754. getEffectDefines(): string;
  17755. /**
  17756. * Returns a string representing the class name
  17757. * @returns a string containing the class name
  17758. */
  17759. getClassName(): string;
  17760. /**
  17761. * Serializes the particle system to a JSON object.
  17762. * @returns the JSON object
  17763. */
  17764. serialize(): any;
  17765. /**
  17766. * Parse properties from a JSON object
  17767. * @param serializationObject defines the JSON object
  17768. */
  17769. parse(serializationObject: any): void;
  17770. }
  17771. }
  17772. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17774. import { Effect } from "babylonjs/Materials/effect";
  17775. import { Particle } from "babylonjs/Particles/particle";
  17776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17777. /**
  17778. * Particle emitter emitting particles from the inside of a box.
  17779. * It emits the particles randomly between 2 given directions.
  17780. */
  17781. export class BoxParticleEmitter implements IParticleEmitterType {
  17782. /**
  17783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17784. */
  17785. direction1: Vector3;
  17786. /**
  17787. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17788. */
  17789. direction2: Vector3;
  17790. /**
  17791. * 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.
  17792. */
  17793. minEmitBox: Vector3;
  17794. /**
  17795. * 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.
  17796. */
  17797. maxEmitBox: Vector3;
  17798. /**
  17799. * Creates a new instance BoxParticleEmitter
  17800. */
  17801. constructor();
  17802. /**
  17803. * Called by the particle System when the direction is computed for the created particle.
  17804. * @param worldMatrix is the world matrix of the particle system
  17805. * @param directionToUpdate is the direction vector to update with the result
  17806. * @param particle is the particle we are computed the direction for
  17807. */
  17808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17809. /**
  17810. * Called by the particle System when the position is computed for the created particle.
  17811. * @param worldMatrix is the world matrix of the particle system
  17812. * @param positionToUpdate is the position vector to update with the result
  17813. * @param particle is the particle we are computed the position for
  17814. */
  17815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17816. /**
  17817. * Clones the current emitter and returns a copy of it
  17818. * @returns the new emitter
  17819. */
  17820. clone(): BoxParticleEmitter;
  17821. /**
  17822. * Called by the GPUParticleSystem to setup the update shader
  17823. * @param effect defines the update shader
  17824. */
  17825. applyToShader(effect: Effect): void;
  17826. /**
  17827. * Returns a string to use to update the GPU particles update shader
  17828. * @returns a string containng the defines string
  17829. */
  17830. getEffectDefines(): string;
  17831. /**
  17832. * Returns the string "BoxParticleEmitter"
  17833. * @returns a string containing the class name
  17834. */
  17835. getClassName(): string;
  17836. /**
  17837. * Serializes the particle system to a JSON object.
  17838. * @returns the JSON object
  17839. */
  17840. serialize(): any;
  17841. /**
  17842. * Parse properties from a JSON object
  17843. * @param serializationObject defines the JSON object
  17844. */
  17845. parse(serializationObject: any): void;
  17846. }
  17847. }
  17848. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17849. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17850. import { Effect } from "babylonjs/Materials/effect";
  17851. import { Particle } from "babylonjs/Particles/particle";
  17852. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17853. /**
  17854. * Particle emitter emitting particles from the inside of a cone.
  17855. * It emits the particles alongside the cone volume from the base to the particle.
  17856. * The emission direction might be randomized.
  17857. */
  17858. export class ConeParticleEmitter implements IParticleEmitterType {
  17859. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17860. directionRandomizer: number;
  17861. private _radius;
  17862. private _angle;
  17863. private _height;
  17864. /**
  17865. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17866. */
  17867. radiusRange: number;
  17868. /**
  17869. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17870. */
  17871. heightRange: number;
  17872. /**
  17873. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17874. */
  17875. emitFromSpawnPointOnly: boolean;
  17876. /**
  17877. * Gets or sets the radius of the emission cone
  17878. */
  17879. radius: number;
  17880. /**
  17881. * Gets or sets the angle of the emission cone
  17882. */
  17883. angle: number;
  17884. private _buildHeight;
  17885. /**
  17886. * Creates a new instance ConeParticleEmitter
  17887. * @param radius the radius of the emission cone (1 by default)
  17888. * @param angle the cone base angle (PI by default)
  17889. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17890. */
  17891. constructor(radius?: number, angle?: number,
  17892. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17893. directionRandomizer?: number);
  17894. /**
  17895. * Called by the particle System when the direction is computed for the created particle.
  17896. * @param worldMatrix is the world matrix of the particle system
  17897. * @param directionToUpdate is the direction vector to update with the result
  17898. * @param particle is the particle we are computed the direction for
  17899. */
  17900. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17901. /**
  17902. * Called by the particle System when the position is computed for the created particle.
  17903. * @param worldMatrix is the world matrix of the particle system
  17904. * @param positionToUpdate is the position vector to update with the result
  17905. * @param particle is the particle we are computed the position for
  17906. */
  17907. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17908. /**
  17909. * Clones the current emitter and returns a copy of it
  17910. * @returns the new emitter
  17911. */
  17912. clone(): ConeParticleEmitter;
  17913. /**
  17914. * Called by the GPUParticleSystem to setup the update shader
  17915. * @param effect defines the update shader
  17916. */
  17917. applyToShader(effect: Effect): void;
  17918. /**
  17919. * Returns a string to use to update the GPU particles update shader
  17920. * @returns a string containng the defines string
  17921. */
  17922. getEffectDefines(): string;
  17923. /**
  17924. * Returns the string "ConeParticleEmitter"
  17925. * @returns a string containing the class name
  17926. */
  17927. getClassName(): string;
  17928. /**
  17929. * Serializes the particle system to a JSON object.
  17930. * @returns the JSON object
  17931. */
  17932. serialize(): any;
  17933. /**
  17934. * Parse properties from a JSON object
  17935. * @param serializationObject defines the JSON object
  17936. */
  17937. parse(serializationObject: any): void;
  17938. }
  17939. }
  17940. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17941. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17942. import { Effect } from "babylonjs/Materials/effect";
  17943. import { Particle } from "babylonjs/Particles/particle";
  17944. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17945. /**
  17946. * Particle emitter emitting particles from the inside of a cylinder.
  17947. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17948. */
  17949. export class CylinderParticleEmitter implements IParticleEmitterType {
  17950. /**
  17951. * The radius of the emission cylinder.
  17952. */
  17953. radius: number;
  17954. /**
  17955. * The height of the emission cylinder.
  17956. */
  17957. height: number;
  17958. /**
  17959. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17960. */
  17961. radiusRange: number;
  17962. /**
  17963. * How much to randomize the particle direction [0-1].
  17964. */
  17965. directionRandomizer: number;
  17966. /**
  17967. * Creates a new instance CylinderParticleEmitter
  17968. * @param radius the radius of the emission cylinder (1 by default)
  17969. * @param height the height of the emission cylinder (1 by default)
  17970. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17971. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17972. */
  17973. constructor(
  17974. /**
  17975. * The radius of the emission cylinder.
  17976. */
  17977. radius?: number,
  17978. /**
  17979. * The height of the emission cylinder.
  17980. */
  17981. height?: number,
  17982. /**
  17983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17984. */
  17985. radiusRange?: number,
  17986. /**
  17987. * How much to randomize the particle direction [0-1].
  17988. */
  17989. directionRandomizer?: number);
  17990. /**
  17991. * Called by the particle System when the direction is computed for the created particle.
  17992. * @param worldMatrix is the world matrix of the particle system
  17993. * @param directionToUpdate is the direction vector to update with the result
  17994. * @param particle is the particle we are computed the direction for
  17995. */
  17996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17997. /**
  17998. * Called by the particle System when the position is computed for the created particle.
  17999. * @param worldMatrix is the world matrix of the particle system
  18000. * @param positionToUpdate is the position vector to update with the result
  18001. * @param particle is the particle we are computed the position for
  18002. */
  18003. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18004. /**
  18005. * Clones the current emitter and returns a copy of it
  18006. * @returns the new emitter
  18007. */
  18008. clone(): CylinderParticleEmitter;
  18009. /**
  18010. * Called by the GPUParticleSystem to setup the update shader
  18011. * @param effect defines the update shader
  18012. */
  18013. applyToShader(effect: Effect): void;
  18014. /**
  18015. * Returns a string to use to update the GPU particles update shader
  18016. * @returns a string containng the defines string
  18017. */
  18018. getEffectDefines(): string;
  18019. /**
  18020. * Returns the string "CylinderParticleEmitter"
  18021. * @returns a string containing the class name
  18022. */
  18023. getClassName(): string;
  18024. /**
  18025. * Serializes the particle system to a JSON object.
  18026. * @returns the JSON object
  18027. */
  18028. serialize(): any;
  18029. /**
  18030. * Parse properties from a JSON object
  18031. * @param serializationObject defines the JSON object
  18032. */
  18033. parse(serializationObject: any): void;
  18034. }
  18035. /**
  18036. * Particle emitter emitting particles from the inside of a cylinder.
  18037. * It emits the particles randomly between two vectors.
  18038. */
  18039. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18040. /**
  18041. * The min limit of the emission direction.
  18042. */
  18043. direction1: Vector3;
  18044. /**
  18045. * The max limit of the emission direction.
  18046. */
  18047. direction2: Vector3;
  18048. /**
  18049. * Creates a new instance CylinderDirectedParticleEmitter
  18050. * @param radius the radius of the emission cylinder (1 by default)
  18051. * @param height the height of the emission cylinder (1 by default)
  18052. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18053. * @param direction1 the min limit of the emission direction (up vector by default)
  18054. * @param direction2 the max limit of the emission direction (up vector by default)
  18055. */
  18056. constructor(radius?: number, height?: number, radiusRange?: number,
  18057. /**
  18058. * The min limit of the emission direction.
  18059. */
  18060. direction1?: Vector3,
  18061. /**
  18062. * The max limit of the emission direction.
  18063. */
  18064. direction2?: Vector3);
  18065. /**
  18066. * Called by the particle System when the direction is computed for the created particle.
  18067. * @param worldMatrix is the world matrix of the particle system
  18068. * @param directionToUpdate is the direction vector to update with the result
  18069. * @param particle is the particle we are computed the direction for
  18070. */
  18071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18072. /**
  18073. * Clones the current emitter and returns a copy of it
  18074. * @returns the new emitter
  18075. */
  18076. clone(): CylinderDirectedParticleEmitter;
  18077. /**
  18078. * Called by the GPUParticleSystem to setup the update shader
  18079. * @param effect defines the update shader
  18080. */
  18081. applyToShader(effect: Effect): void;
  18082. /**
  18083. * Returns a string to use to update the GPU particles update shader
  18084. * @returns a string containng the defines string
  18085. */
  18086. getEffectDefines(): string;
  18087. /**
  18088. * Returns the string "CylinderDirectedParticleEmitter"
  18089. * @returns a string containing the class name
  18090. */
  18091. getClassName(): string;
  18092. /**
  18093. * Serializes the particle system to a JSON object.
  18094. * @returns the JSON object
  18095. */
  18096. serialize(): any;
  18097. /**
  18098. * Parse properties from a JSON object
  18099. * @param serializationObject defines the JSON object
  18100. */
  18101. parse(serializationObject: any): void;
  18102. }
  18103. }
  18104. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18106. import { Effect } from "babylonjs/Materials/effect";
  18107. import { Particle } from "babylonjs/Particles/particle";
  18108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18109. /**
  18110. * Particle emitter emitting particles from the inside of a hemisphere.
  18111. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18112. */
  18113. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18114. /**
  18115. * The radius of the emission hemisphere.
  18116. */
  18117. radius: number;
  18118. /**
  18119. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18120. */
  18121. radiusRange: number;
  18122. /**
  18123. * How much to randomize the particle direction [0-1].
  18124. */
  18125. directionRandomizer: number;
  18126. /**
  18127. * Creates a new instance HemisphericParticleEmitter
  18128. * @param radius the radius of the emission hemisphere (1 by default)
  18129. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18130. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18131. */
  18132. constructor(
  18133. /**
  18134. * The radius of the emission hemisphere.
  18135. */
  18136. radius?: number,
  18137. /**
  18138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18139. */
  18140. radiusRange?: number,
  18141. /**
  18142. * How much to randomize the particle direction [0-1].
  18143. */
  18144. directionRandomizer?: number);
  18145. /**
  18146. * Called by the particle System when the direction is computed for the created particle.
  18147. * @param worldMatrix is the world matrix of the particle system
  18148. * @param directionToUpdate is the direction vector to update with the result
  18149. * @param particle is the particle we are computed the direction for
  18150. */
  18151. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18152. /**
  18153. * Called by the particle System when the position is computed for the created particle.
  18154. * @param worldMatrix is the world matrix of the particle system
  18155. * @param positionToUpdate is the position vector to update with the result
  18156. * @param particle is the particle we are computed the position for
  18157. */
  18158. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18159. /**
  18160. * Clones the current emitter and returns a copy of it
  18161. * @returns the new emitter
  18162. */
  18163. clone(): HemisphericParticleEmitter;
  18164. /**
  18165. * Called by the GPUParticleSystem to setup the update shader
  18166. * @param effect defines the update shader
  18167. */
  18168. applyToShader(effect: Effect): void;
  18169. /**
  18170. * Returns a string to use to update the GPU particles update shader
  18171. * @returns a string containng the defines string
  18172. */
  18173. getEffectDefines(): string;
  18174. /**
  18175. * Returns the string "HemisphericParticleEmitter"
  18176. * @returns a string containing the class name
  18177. */
  18178. getClassName(): string;
  18179. /**
  18180. * Serializes the particle system to a JSON object.
  18181. * @returns the JSON object
  18182. */
  18183. serialize(): any;
  18184. /**
  18185. * Parse properties from a JSON object
  18186. * @param serializationObject defines the JSON object
  18187. */
  18188. parse(serializationObject: any): void;
  18189. }
  18190. }
  18191. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18192. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18193. import { Effect } from "babylonjs/Materials/effect";
  18194. import { Particle } from "babylonjs/Particles/particle";
  18195. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18196. /**
  18197. * Particle emitter emitting particles from a point.
  18198. * It emits the particles randomly between 2 given directions.
  18199. */
  18200. export class PointParticleEmitter implements IParticleEmitterType {
  18201. /**
  18202. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18203. */
  18204. direction1: Vector3;
  18205. /**
  18206. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18207. */
  18208. direction2: Vector3;
  18209. /**
  18210. * Creates a new instance PointParticleEmitter
  18211. */
  18212. constructor();
  18213. /**
  18214. * Called by the particle System when the direction is computed for the created particle.
  18215. * @param worldMatrix is the world matrix of the particle system
  18216. * @param directionToUpdate is the direction vector to update with the result
  18217. * @param particle is the particle we are computed the direction for
  18218. */
  18219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18220. /**
  18221. * Called by the particle System when the position is computed for the created particle.
  18222. * @param worldMatrix is the world matrix of the particle system
  18223. * @param positionToUpdate is the position vector to update with the result
  18224. * @param particle is the particle we are computed the position for
  18225. */
  18226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18227. /**
  18228. * Clones the current emitter and returns a copy of it
  18229. * @returns the new emitter
  18230. */
  18231. clone(): PointParticleEmitter;
  18232. /**
  18233. * Called by the GPUParticleSystem to setup the update shader
  18234. * @param effect defines the update shader
  18235. */
  18236. applyToShader(effect: Effect): void;
  18237. /**
  18238. * Returns a string to use to update the GPU particles update shader
  18239. * @returns a string containng the defines string
  18240. */
  18241. getEffectDefines(): string;
  18242. /**
  18243. * Returns the string "PointParticleEmitter"
  18244. * @returns a string containing the class name
  18245. */
  18246. getClassName(): string;
  18247. /**
  18248. * Serializes the particle system to a JSON object.
  18249. * @returns the JSON object
  18250. */
  18251. serialize(): any;
  18252. /**
  18253. * Parse properties from a JSON object
  18254. * @param serializationObject defines the JSON object
  18255. */
  18256. parse(serializationObject: any): void;
  18257. }
  18258. }
  18259. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18260. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18261. import { Effect } from "babylonjs/Materials/effect";
  18262. import { Particle } from "babylonjs/Particles/particle";
  18263. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18264. /**
  18265. * Particle emitter emitting particles from the inside of a sphere.
  18266. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18267. */
  18268. export class SphereParticleEmitter implements IParticleEmitterType {
  18269. /**
  18270. * The radius of the emission sphere.
  18271. */
  18272. radius: number;
  18273. /**
  18274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18275. */
  18276. radiusRange: number;
  18277. /**
  18278. * How much to randomize the particle direction [0-1].
  18279. */
  18280. directionRandomizer: number;
  18281. /**
  18282. * Creates a new instance SphereParticleEmitter
  18283. * @param radius the radius of the emission sphere (1 by default)
  18284. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18285. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18286. */
  18287. constructor(
  18288. /**
  18289. * The radius of the emission sphere.
  18290. */
  18291. radius?: number,
  18292. /**
  18293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18294. */
  18295. radiusRange?: number,
  18296. /**
  18297. * How much to randomize the particle direction [0-1].
  18298. */
  18299. directionRandomizer?: number);
  18300. /**
  18301. * Called by the particle System when the direction is computed for the created particle.
  18302. * @param worldMatrix is the world matrix of the particle system
  18303. * @param directionToUpdate is the direction vector to update with the result
  18304. * @param particle is the particle we are computed the direction for
  18305. */
  18306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18307. /**
  18308. * Called by the particle System when the position is computed for the created particle.
  18309. * @param worldMatrix is the world matrix of the particle system
  18310. * @param positionToUpdate is the position vector to update with the result
  18311. * @param particle is the particle we are computed the position for
  18312. */
  18313. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18314. /**
  18315. * Clones the current emitter and returns a copy of it
  18316. * @returns the new emitter
  18317. */
  18318. clone(): SphereParticleEmitter;
  18319. /**
  18320. * Called by the GPUParticleSystem to setup the update shader
  18321. * @param effect defines the update shader
  18322. */
  18323. applyToShader(effect: Effect): void;
  18324. /**
  18325. * Returns a string to use to update the GPU particles update shader
  18326. * @returns a string containng the defines string
  18327. */
  18328. getEffectDefines(): string;
  18329. /**
  18330. * Returns the string "SphereParticleEmitter"
  18331. * @returns a string containing the class name
  18332. */
  18333. getClassName(): string;
  18334. /**
  18335. * Serializes the particle system to a JSON object.
  18336. * @returns the JSON object
  18337. */
  18338. serialize(): any;
  18339. /**
  18340. * Parse properties from a JSON object
  18341. * @param serializationObject defines the JSON object
  18342. */
  18343. parse(serializationObject: any): void;
  18344. }
  18345. /**
  18346. * Particle emitter emitting particles from the inside of a sphere.
  18347. * It emits the particles randomly between two vectors.
  18348. */
  18349. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18350. /**
  18351. * The min limit of the emission direction.
  18352. */
  18353. direction1: Vector3;
  18354. /**
  18355. * The max limit of the emission direction.
  18356. */
  18357. direction2: Vector3;
  18358. /**
  18359. * Creates a new instance SphereDirectedParticleEmitter
  18360. * @param radius the radius of the emission sphere (1 by default)
  18361. * @param direction1 the min limit of the emission direction (up vector by default)
  18362. * @param direction2 the max limit of the emission direction (up vector by default)
  18363. */
  18364. constructor(radius?: number,
  18365. /**
  18366. * The min limit of the emission direction.
  18367. */
  18368. direction1?: Vector3,
  18369. /**
  18370. * The max limit of the emission direction.
  18371. */
  18372. direction2?: Vector3);
  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. * Clones the current emitter and returns a copy of it
  18382. * @returns the new emitter
  18383. */
  18384. clone(): SphereDirectedParticleEmitter;
  18385. /**
  18386. * Called by the GPUParticleSystem to setup the update shader
  18387. * @param effect defines the update shader
  18388. */
  18389. applyToShader(effect: Effect): void;
  18390. /**
  18391. * Returns a string to use to update the GPU particles update shader
  18392. * @returns a string containng the defines string
  18393. */
  18394. getEffectDefines(): string;
  18395. /**
  18396. * Returns the string "SphereDirectedParticleEmitter"
  18397. * @returns a string containing the class name
  18398. */
  18399. getClassName(): string;
  18400. /**
  18401. * Serializes the particle system to a JSON object.
  18402. * @returns the JSON object
  18403. */
  18404. serialize(): any;
  18405. /**
  18406. * Parse properties from a JSON object
  18407. * @param serializationObject defines the JSON object
  18408. */
  18409. parse(serializationObject: any): void;
  18410. }
  18411. }
  18412. declare module "babylonjs/Particles/EmitterTypes/index" {
  18413. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18414. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18415. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18416. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18417. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18418. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18419. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18420. }
  18421. declare module "babylonjs/Particles/IParticleSystem" {
  18422. import { Nullable } from "babylonjs/types";
  18423. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18424. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18427. import { Texture } from "babylonjs/Materials/Textures/texture";
  18428. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18429. import { Scene } from "babylonjs/scene";
  18430. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18431. import { Animation } from "babylonjs/Animations/animation";
  18432. /**
  18433. * Interface representing a particle system in Babylon.js.
  18434. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18435. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18436. */
  18437. export interface IParticleSystem {
  18438. /**
  18439. * List of animations used by the particle system.
  18440. */
  18441. animations: Animation[];
  18442. /**
  18443. * The id of the Particle system.
  18444. */
  18445. id: string;
  18446. /**
  18447. * The name of the Particle system.
  18448. */
  18449. name: string;
  18450. /**
  18451. * The emitter represents the Mesh or position we are attaching the particle system to.
  18452. */
  18453. emitter: Nullable<AbstractMesh | Vector3>;
  18454. /**
  18455. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18456. */
  18457. isBillboardBased: boolean;
  18458. /**
  18459. * The rendering group used by the Particle system to chose when to render.
  18460. */
  18461. renderingGroupId: number;
  18462. /**
  18463. * The layer mask we are rendering the particles through.
  18464. */
  18465. layerMask: number;
  18466. /**
  18467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18468. */
  18469. updateSpeed: number;
  18470. /**
  18471. * The amount of time the particle system is running (depends of the overall update speed).
  18472. */
  18473. targetStopDuration: number;
  18474. /**
  18475. * The texture used to render each particle. (this can be a spritesheet)
  18476. */
  18477. particleTexture: Nullable<Texture>;
  18478. /**
  18479. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18480. */
  18481. blendMode: number;
  18482. /**
  18483. * Minimum life time of emitting particles.
  18484. */
  18485. minLifeTime: number;
  18486. /**
  18487. * Maximum life time of emitting particles.
  18488. */
  18489. maxLifeTime: number;
  18490. /**
  18491. * Minimum Size of emitting particles.
  18492. */
  18493. minSize: number;
  18494. /**
  18495. * Maximum Size of emitting particles.
  18496. */
  18497. maxSize: number;
  18498. /**
  18499. * Minimum scale of emitting particles on X axis.
  18500. */
  18501. minScaleX: number;
  18502. /**
  18503. * Maximum scale of emitting particles on X axis.
  18504. */
  18505. maxScaleX: number;
  18506. /**
  18507. * Minimum scale of emitting particles on Y axis.
  18508. */
  18509. minScaleY: number;
  18510. /**
  18511. * Maximum scale of emitting particles on Y axis.
  18512. */
  18513. maxScaleY: number;
  18514. /**
  18515. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18516. */
  18517. color1: Color4;
  18518. /**
  18519. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18520. */
  18521. color2: Color4;
  18522. /**
  18523. * Color the particle will have at the end of its lifetime.
  18524. */
  18525. colorDead: Color4;
  18526. /**
  18527. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18528. */
  18529. emitRate: number;
  18530. /**
  18531. * You can use gravity if you want to give an orientation to your particles.
  18532. */
  18533. gravity: Vector3;
  18534. /**
  18535. * Minimum power of emitting particles.
  18536. */
  18537. minEmitPower: number;
  18538. /**
  18539. * Maximum power of emitting particles.
  18540. */
  18541. maxEmitPower: number;
  18542. /**
  18543. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18544. */
  18545. minAngularSpeed: number;
  18546. /**
  18547. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18548. */
  18549. maxAngularSpeed: number;
  18550. /**
  18551. * Gets or sets the minimal initial rotation in radians.
  18552. */
  18553. minInitialRotation: number;
  18554. /**
  18555. * Gets or sets the maximal initial rotation in radians.
  18556. */
  18557. maxInitialRotation: number;
  18558. /**
  18559. * The particle emitter type defines the emitter used by the particle system.
  18560. * It can be for example box, sphere, or cone...
  18561. */
  18562. particleEmitterType: Nullable<IParticleEmitterType>;
  18563. /**
  18564. * Defines the delay in milliseconds before starting the system (0 by default)
  18565. */
  18566. startDelay: number;
  18567. /**
  18568. * 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
  18569. */
  18570. preWarmCycles: number;
  18571. /**
  18572. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18573. */
  18574. preWarmStepOffset: number;
  18575. /**
  18576. * 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)
  18577. */
  18578. spriteCellChangeSpeed: number;
  18579. /**
  18580. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18581. */
  18582. startSpriteCellID: number;
  18583. /**
  18584. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18585. */
  18586. endSpriteCellID: number;
  18587. /**
  18588. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18589. */
  18590. spriteCellWidth: number;
  18591. /**
  18592. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18593. */
  18594. spriteCellHeight: number;
  18595. /**
  18596. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18597. */
  18598. spriteRandomStartCell: boolean;
  18599. /**
  18600. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18601. */
  18602. isAnimationSheetEnabled: boolean;
  18603. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18604. translationPivot: Vector2;
  18605. /**
  18606. * Gets or sets a texture used to add random noise to particle positions
  18607. */
  18608. noiseTexture: Nullable<BaseTexture>;
  18609. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18610. noiseStrength: Vector3;
  18611. /**
  18612. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18613. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18614. */
  18615. billboardMode: number;
  18616. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18617. limitVelocityDamping: number;
  18618. /**
  18619. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18620. */
  18621. beginAnimationOnStart: boolean;
  18622. /**
  18623. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18624. */
  18625. beginAnimationFrom: number;
  18626. /**
  18627. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18628. */
  18629. beginAnimationTo: number;
  18630. /**
  18631. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18632. */
  18633. beginAnimationLoop: boolean;
  18634. /**
  18635. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18636. */
  18637. disposeOnStop: boolean;
  18638. /**
  18639. * Gets the maximum number of particles active at the same time.
  18640. * @returns The max number of active particles.
  18641. */
  18642. getCapacity(): number;
  18643. /**
  18644. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18645. * @returns True if it has been started, otherwise false.
  18646. */
  18647. isStarted(): boolean;
  18648. /**
  18649. * Animates the particle system for this frame.
  18650. */
  18651. animate(): void;
  18652. /**
  18653. * Renders the particle system in its current state.
  18654. * @returns the current number of particles
  18655. */
  18656. render(): number;
  18657. /**
  18658. * Dispose the particle system and frees its associated resources.
  18659. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18660. */
  18661. dispose(disposeTexture?: boolean): void;
  18662. /**
  18663. * Clones the particle system.
  18664. * @param name The name of the cloned object
  18665. * @param newEmitter The new emitter to use
  18666. * @returns the cloned particle system
  18667. */
  18668. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18669. /**
  18670. * Serializes the particle system to a JSON object.
  18671. * @returns the JSON object
  18672. */
  18673. serialize(): any;
  18674. /**
  18675. * Rebuild the particle system
  18676. */
  18677. rebuild(): void;
  18678. /**
  18679. * Starts the particle system and begins to emit
  18680. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18681. */
  18682. start(delay?: number): void;
  18683. /**
  18684. * Stops the particle system.
  18685. */
  18686. stop(): void;
  18687. /**
  18688. * Remove all active particles
  18689. */
  18690. reset(): void;
  18691. /**
  18692. * Is this system ready to be used/rendered
  18693. * @return true if the system is ready
  18694. */
  18695. isReady(): boolean;
  18696. /**
  18697. * Adds a new color gradient
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param color1 defines the color to affect to the specified gradient
  18700. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18701. * @returns the current particle system
  18702. */
  18703. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18704. /**
  18705. * Remove a specific color gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeColorGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Adds a new size gradient
  18712. * @param gradient defines the gradient to use (between 0 and 1)
  18713. * @param factor defines the size factor to affect to the specified gradient
  18714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18715. * @returns the current particle system
  18716. */
  18717. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18718. /**
  18719. * Remove a specific size gradient
  18720. * @param gradient defines the gradient to remove
  18721. * @returns the current particle system
  18722. */
  18723. removeSizeGradient(gradient: number): IParticleSystem;
  18724. /**
  18725. * Gets the current list of color gradients.
  18726. * You must use addColorGradient and removeColorGradient to udpate this list
  18727. * @returns the list of color gradients
  18728. */
  18729. getColorGradients(): Nullable<Array<ColorGradient>>;
  18730. /**
  18731. * Gets the current list of size gradients.
  18732. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18733. * @returns the list of size gradients
  18734. */
  18735. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18736. /**
  18737. * Gets the current list of angular speed gradients.
  18738. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18739. * @returns the list of angular speed gradients
  18740. */
  18741. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18742. /**
  18743. * Adds a new angular speed gradient
  18744. * @param gradient defines the gradient to use (between 0 and 1)
  18745. * @param factor defines the angular speed to affect to the specified gradient
  18746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18747. * @returns the current particle system
  18748. */
  18749. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18750. /**
  18751. * Remove a specific angular speed gradient
  18752. * @param gradient defines the gradient to remove
  18753. * @returns the current particle system
  18754. */
  18755. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18756. /**
  18757. * Gets the current list of velocity gradients.
  18758. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18759. * @returns the list of velocity gradients
  18760. */
  18761. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18762. /**
  18763. * Adds a new velocity gradient
  18764. * @param gradient defines the gradient to use (between 0 and 1)
  18765. * @param factor defines the velocity to affect to the specified gradient
  18766. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18767. * @returns the current particle system
  18768. */
  18769. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18770. /**
  18771. * Remove a specific velocity gradient
  18772. * @param gradient defines the gradient to remove
  18773. * @returns the current particle system
  18774. */
  18775. removeVelocityGradient(gradient: number): IParticleSystem;
  18776. /**
  18777. * Gets the current list of limit velocity gradients.
  18778. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18779. * @returns the list of limit velocity gradients
  18780. */
  18781. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18782. /**
  18783. * Adds a new limit velocity gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the limit velocity to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific limit velocity gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Adds a new drag gradient
  18798. * @param gradient defines the gradient to use (between 0 and 1)
  18799. * @param factor defines the drag to affect to the specified gradient
  18800. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18801. * @returns the current particle system
  18802. */
  18803. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18804. /**
  18805. * Remove a specific drag gradient
  18806. * @param gradient defines the gradient to remove
  18807. * @returns the current particle system
  18808. */
  18809. removeDragGradient(gradient: number): IParticleSystem;
  18810. /**
  18811. * Gets the current list of drag gradients.
  18812. * You must use addDragGradient and removeDragGradient to udpate this list
  18813. * @returns the list of drag gradients
  18814. */
  18815. getDragGradients(): Nullable<Array<FactorGradient>>;
  18816. /**
  18817. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18818. * @param gradient defines the gradient to use (between 0 and 1)
  18819. * @param factor defines the emit rate to affect to the specified gradient
  18820. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18821. * @returns the current particle system
  18822. */
  18823. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18824. /**
  18825. * Remove a specific emit rate gradient
  18826. * @param gradient defines the gradient to remove
  18827. * @returns the current particle system
  18828. */
  18829. removeEmitRateGradient(gradient: number): IParticleSystem;
  18830. /**
  18831. * Gets the current list of emit rate gradients.
  18832. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18833. * @returns the list of emit rate gradients
  18834. */
  18835. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18836. /**
  18837. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18838. * @param gradient defines the gradient to use (between 0 and 1)
  18839. * @param factor defines the start size to affect to the specified gradient
  18840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18841. * @returns the current particle system
  18842. */
  18843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18844. /**
  18845. * Remove a specific start size gradient
  18846. * @param gradient defines the gradient to remove
  18847. * @returns the current particle system
  18848. */
  18849. removeStartSizeGradient(gradient: number): IParticleSystem;
  18850. /**
  18851. * Gets the current list of start size gradients.
  18852. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18853. * @returns the list of start size gradients
  18854. */
  18855. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18856. /**
  18857. * Adds a new life time gradient
  18858. * @param gradient defines the gradient to use (between 0 and 1)
  18859. * @param factor defines the life time factor to affect to the specified gradient
  18860. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18861. * @returns the current particle system
  18862. */
  18863. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18864. /**
  18865. * Remove a specific life time gradient
  18866. * @param gradient defines the gradient to remove
  18867. * @returns the current particle system
  18868. */
  18869. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18870. /**
  18871. * Gets the current list of life time gradients.
  18872. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18873. * @returns the list of life time gradients
  18874. */
  18875. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18876. /**
  18877. * Gets the current list of color gradients.
  18878. * You must use addColorGradient and removeColorGradient to udpate this list
  18879. * @returns the list of color gradients
  18880. */
  18881. getColorGradients(): Nullable<Array<ColorGradient>>;
  18882. /**
  18883. * Adds a new ramp gradient used to remap particle colors
  18884. * @param gradient defines the gradient to use (between 0 and 1)
  18885. * @param color defines the color to affect to the specified gradient
  18886. * @returns the current particle system
  18887. */
  18888. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18889. /**
  18890. * Gets the current list of ramp gradients.
  18891. * You must use addRampGradient and removeRampGradient to udpate this list
  18892. * @returns the list of ramp gradients
  18893. */
  18894. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18895. /** Gets or sets a boolean indicating that ramp gradients must be used
  18896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18897. */
  18898. useRampGradients: boolean;
  18899. /**
  18900. * Adds a new color remap gradient
  18901. * @param gradient defines the gradient to use (between 0 and 1)
  18902. * @param min defines the color remap minimal range
  18903. * @param max defines the color remap maximal range
  18904. * @returns the current particle system
  18905. */
  18906. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18907. /**
  18908. * Gets the current list of color remap gradients.
  18909. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18910. * @returns the list of color remap gradients
  18911. */
  18912. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18913. /**
  18914. * Adds a new alpha remap gradient
  18915. * @param gradient defines the gradient to use (between 0 and 1)
  18916. * @param min defines the alpha remap minimal range
  18917. * @param max defines the alpha remap maximal range
  18918. * @returns the current particle system
  18919. */
  18920. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18921. /**
  18922. * Gets the current list of alpha remap gradients.
  18923. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18924. * @returns the list of alpha remap gradients
  18925. */
  18926. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18927. /**
  18928. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18929. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18930. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18931. * @returns the emitter
  18932. */
  18933. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18934. /**
  18935. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18936. * @param radius The radius of the hemisphere to emit from
  18937. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18938. * @returns the emitter
  18939. */
  18940. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18941. /**
  18942. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18943. * @param radius The radius of the sphere to emit from
  18944. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18945. * @returns the emitter
  18946. */
  18947. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18948. /**
  18949. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18950. * @param radius The radius of the sphere to emit from
  18951. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18952. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18953. * @returns the emitter
  18954. */
  18955. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18956. /**
  18957. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18958. * @param radius The radius of the emission cylinder
  18959. * @param height The height of the emission cylinder
  18960. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18961. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18962. * @returns the emitter
  18963. */
  18964. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18965. /**
  18966. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18967. * @param radius The radius of the cylinder to emit from
  18968. * @param height The height of the emission cylinder
  18969. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18972. * @returns the emitter
  18973. */
  18974. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18975. /**
  18976. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18977. * @param radius The radius of the cone to emit from
  18978. * @param angle The base angle of the cone
  18979. * @returns the emitter
  18980. */
  18981. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18982. /**
  18983. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18986. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18987. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18988. * @returns the emitter
  18989. */
  18990. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18991. /**
  18992. * Get hosting scene
  18993. * @returns the scene
  18994. */
  18995. getScene(): Scene;
  18996. }
  18997. }
  18998. declare module "babylonjs/Meshes/instancedMesh" {
  18999. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19000. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19001. import { Camera } from "babylonjs/Cameras/camera";
  19002. import { Node } from "babylonjs/node";
  19003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19004. import { Mesh } from "babylonjs/Meshes/mesh";
  19005. import { Material } from "babylonjs/Materials/material";
  19006. import { Skeleton } from "babylonjs/Bones/skeleton";
  19007. import { Light } from "babylonjs/Lights/light";
  19008. /**
  19009. * Creates an instance based on a source mesh.
  19010. */
  19011. export class InstancedMesh extends AbstractMesh {
  19012. private _sourceMesh;
  19013. private _currentLOD;
  19014. /** @hidden */
  19015. _indexInSourceMeshInstanceArray: number;
  19016. constructor(name: string, source: Mesh);
  19017. /**
  19018. * Returns the string "InstancedMesh".
  19019. */
  19020. getClassName(): string;
  19021. /** Gets the list of lights affecting that mesh */
  19022. readonly lightSources: Light[];
  19023. _resyncLightSources(): void;
  19024. _resyncLighSource(light: Light): void;
  19025. _removeLightSource(light: Light): void;
  19026. /**
  19027. * If the source mesh receives shadows
  19028. */
  19029. readonly receiveShadows: boolean;
  19030. /**
  19031. * The material of the source mesh
  19032. */
  19033. readonly material: Nullable<Material>;
  19034. /**
  19035. * Visibility of the source mesh
  19036. */
  19037. readonly visibility: number;
  19038. /**
  19039. * Skeleton of the source mesh
  19040. */
  19041. readonly skeleton: Nullable<Skeleton>;
  19042. /**
  19043. * Rendering ground id of the source mesh
  19044. */
  19045. renderingGroupId: number;
  19046. /**
  19047. * Returns the total number of vertices (integer).
  19048. */
  19049. getTotalVertices(): number;
  19050. /**
  19051. * Returns a positive integer : the total number of indices in this mesh geometry.
  19052. * @returns the numner of indices or zero if the mesh has no geometry.
  19053. */
  19054. getTotalIndices(): number;
  19055. /**
  19056. * The source mesh of the instance
  19057. */
  19058. readonly sourceMesh: Mesh;
  19059. /**
  19060. * Is this node ready to be used/rendered
  19061. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19062. * @return {boolean} is it ready
  19063. */
  19064. isReady(completeCheck?: boolean): boolean;
  19065. /**
  19066. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19067. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19068. * @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.
  19069. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19070. */
  19071. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19072. /**
  19073. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19074. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19075. * The `data` are either a numeric array either a Float32Array.
  19076. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19077. * 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).
  19078. * Note that a new underlying VertexBuffer object is created each call.
  19079. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19080. *
  19081. * Possible `kind` values :
  19082. * - VertexBuffer.PositionKind
  19083. * - VertexBuffer.UVKind
  19084. * - VertexBuffer.UV2Kind
  19085. * - VertexBuffer.UV3Kind
  19086. * - VertexBuffer.UV4Kind
  19087. * - VertexBuffer.UV5Kind
  19088. * - VertexBuffer.UV6Kind
  19089. * - VertexBuffer.ColorKind
  19090. * - VertexBuffer.MatricesIndicesKind
  19091. * - VertexBuffer.MatricesIndicesExtraKind
  19092. * - VertexBuffer.MatricesWeightsKind
  19093. * - VertexBuffer.MatricesWeightsExtraKind
  19094. *
  19095. * Returns the Mesh.
  19096. */
  19097. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19098. /**
  19099. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19100. * If the mesh has no geometry, it is simply returned as it is.
  19101. * The `data` are either a numeric array either a Float32Array.
  19102. * No new underlying VertexBuffer object is created.
  19103. * 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.
  19104. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19105. *
  19106. * Possible `kind` values :
  19107. * - VertexBuffer.PositionKind
  19108. * - VertexBuffer.UVKind
  19109. * - VertexBuffer.UV2Kind
  19110. * - VertexBuffer.UV3Kind
  19111. * - VertexBuffer.UV4Kind
  19112. * - VertexBuffer.UV5Kind
  19113. * - VertexBuffer.UV6Kind
  19114. * - VertexBuffer.ColorKind
  19115. * - VertexBuffer.MatricesIndicesKind
  19116. * - VertexBuffer.MatricesIndicesExtraKind
  19117. * - VertexBuffer.MatricesWeightsKind
  19118. * - VertexBuffer.MatricesWeightsExtraKind
  19119. *
  19120. * Returns the Mesh.
  19121. */
  19122. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19123. /**
  19124. * Sets the mesh indices.
  19125. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19126. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19127. * This method creates a new index buffer each call.
  19128. * Returns the Mesh.
  19129. */
  19130. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19131. /**
  19132. * Boolean : True if the mesh owns the requested kind of data.
  19133. */
  19134. isVerticesDataPresent(kind: string): boolean;
  19135. /**
  19136. * Returns an array of indices (IndicesArray).
  19137. */
  19138. getIndices(): Nullable<IndicesArray>;
  19139. readonly _positions: Nullable<Vector3[]>;
  19140. /**
  19141. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19142. * This means the mesh underlying bounding box and sphere are recomputed.
  19143. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19144. * @returns the current mesh
  19145. */
  19146. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19147. /** @hidden */
  19148. _preActivate(): InstancedMesh;
  19149. /** @hidden */
  19150. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19151. /** @hidden */
  19152. _postActivate(): void;
  19153. getWorldMatrix(): Matrix;
  19154. readonly isAnInstance: boolean;
  19155. /**
  19156. * Returns the current associated LOD AbstractMesh.
  19157. */
  19158. getLOD(camera: Camera): AbstractMesh;
  19159. /** @hidden */
  19160. _syncSubMeshes(): InstancedMesh;
  19161. /** @hidden */
  19162. _generatePointsArray(): boolean;
  19163. /**
  19164. * Creates a new InstancedMesh from the current mesh.
  19165. * - name (string) : the cloned mesh name
  19166. * - newParent (optional Node) : the optional Node to parent the clone to.
  19167. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19168. *
  19169. * Returns the clone.
  19170. */
  19171. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19172. /**
  19173. * Disposes the InstancedMesh.
  19174. * Returns nothing.
  19175. */
  19176. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19177. }
  19178. }
  19179. declare module "babylonjs/Materials/shaderMaterial" {
  19180. import { Scene } from "babylonjs/scene";
  19181. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19183. import { Mesh } from "babylonjs/Meshes/mesh";
  19184. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19186. import { Texture } from "babylonjs/Materials/Textures/texture";
  19187. import { Material } from "babylonjs/Materials/material";
  19188. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19189. /**
  19190. * Defines the options associated with the creation of a shader material.
  19191. */
  19192. export interface IShaderMaterialOptions {
  19193. /**
  19194. * Does the material work in alpha blend mode
  19195. */
  19196. needAlphaBlending: boolean;
  19197. /**
  19198. * Does the material work in alpha test mode
  19199. */
  19200. needAlphaTesting: boolean;
  19201. /**
  19202. * The list of attribute names used in the shader
  19203. */
  19204. attributes: string[];
  19205. /**
  19206. * The list of unifrom names used in the shader
  19207. */
  19208. uniforms: string[];
  19209. /**
  19210. * The list of UBO names used in the shader
  19211. */
  19212. uniformBuffers: string[];
  19213. /**
  19214. * The list of sampler names used in the shader
  19215. */
  19216. samplers: string[];
  19217. /**
  19218. * The list of defines used in the shader
  19219. */
  19220. defines: string[];
  19221. }
  19222. /**
  19223. * 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.
  19224. *
  19225. * This returned material effects how the mesh will look based on the code in the shaders.
  19226. *
  19227. * @see http://doc.babylonjs.com/how_to/shader_material
  19228. */
  19229. export class ShaderMaterial extends Material {
  19230. private _shaderPath;
  19231. private _options;
  19232. private _textures;
  19233. private _textureArrays;
  19234. private _floats;
  19235. private _ints;
  19236. private _floatsArrays;
  19237. private _colors3;
  19238. private _colors3Arrays;
  19239. private _colors4;
  19240. private _colors4Arrays;
  19241. private _vectors2;
  19242. private _vectors3;
  19243. private _vectors4;
  19244. private _matrices;
  19245. private _matrices3x3;
  19246. private _matrices2x2;
  19247. private _vectors2Arrays;
  19248. private _vectors3Arrays;
  19249. private _vectors4Arrays;
  19250. private _cachedWorldViewMatrix;
  19251. private _cachedWorldViewProjectionMatrix;
  19252. private _renderId;
  19253. /**
  19254. * Instantiate a new shader material.
  19255. * 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.
  19256. * This returned material effects how the mesh will look based on the code in the shaders.
  19257. * @see http://doc.babylonjs.com/how_to/shader_material
  19258. * @param name Define the name of the material in the scene
  19259. * @param scene Define the scene the material belongs to
  19260. * @param shaderPath Defines the route to the shader code in one of three ways:
  19261. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19262. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19263. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19264. * @param options Define the options used to create the shader
  19265. */
  19266. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19267. /**
  19268. * Gets the options used to compile the shader.
  19269. * They can be modified to trigger a new compilation
  19270. */
  19271. readonly options: IShaderMaterialOptions;
  19272. /**
  19273. * Gets the current class name of the material e.g. "ShaderMaterial"
  19274. * Mainly use in serialization.
  19275. * @returns the class name
  19276. */
  19277. getClassName(): string;
  19278. /**
  19279. * Specifies if the material will require alpha blending
  19280. * @returns a boolean specifying if alpha blending is needed
  19281. */
  19282. needAlphaBlending(): boolean;
  19283. /**
  19284. * Specifies if this material should be rendered in alpha test mode
  19285. * @returns a boolean specifying if an alpha test is needed.
  19286. */
  19287. needAlphaTesting(): boolean;
  19288. private _checkUniform;
  19289. /**
  19290. * Set a texture in the shader.
  19291. * @param name Define the name of the uniform samplers as defined in the shader
  19292. * @param texture Define the texture to bind to this sampler
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setTexture(name: string, texture: Texture): ShaderMaterial;
  19296. /**
  19297. * Set a texture array in the shader.
  19298. * @param name Define the name of the uniform sampler array as defined in the shader
  19299. * @param textures Define the list of textures to bind to this sampler
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19303. /**
  19304. * Set a float in the shader.
  19305. * @param name Define the name of the uniform as defined in the shader
  19306. * @param value Define the value to give to the uniform
  19307. * @return the material itself allowing "fluent" like uniform updates
  19308. */
  19309. setFloat(name: string, value: number): ShaderMaterial;
  19310. /**
  19311. * Set a int in the shader.
  19312. * @param name Define the name of the uniform as defined in the shader
  19313. * @param value Define the value to give to the uniform
  19314. * @return the material itself allowing "fluent" like uniform updates
  19315. */
  19316. setInt(name: string, value: number): ShaderMaterial;
  19317. /**
  19318. * Set an array of floats in the shader.
  19319. * @param name Define the name of the uniform as defined in the shader
  19320. * @param value Define the value to give to the uniform
  19321. * @return the material itself allowing "fluent" like uniform updates
  19322. */
  19323. setFloats(name: string, value: number[]): ShaderMaterial;
  19324. /**
  19325. * Set a vec3 in the shader from a Color3.
  19326. * @param name Define the name of the uniform as defined in the shader
  19327. * @param value Define the value to give to the uniform
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setColor3(name: string, value: Color3): ShaderMaterial;
  19331. /**
  19332. * Set a vec3 array in the shader from a Color3 array.
  19333. * @param name Define the name of the uniform as defined in the shader
  19334. * @param value Define the value to give to the uniform
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19338. /**
  19339. * Set a vec4 in the shader from a Color4.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setColor4(name: string, value: Color4): ShaderMaterial;
  19345. /**
  19346. * Set a vec4 array in the shader from a Color4 array.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19352. /**
  19353. * Set a vec2 in the shader from a Vector2.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setVector2(name: string, value: Vector2): ShaderMaterial;
  19359. /**
  19360. * Set a vec3 in the shader from a Vector3.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setVector3(name: string, value: Vector3): ShaderMaterial;
  19366. /**
  19367. * Set a vec4 in the shader from a Vector4.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setVector4(name: string, value: Vector4): ShaderMaterial;
  19373. /**
  19374. * Set a mat4 in the shader from a Matrix.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19380. /**
  19381. * Set a mat3 in the shader from a Float32Array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19387. /**
  19388. * Set a mat2 in the shader from a Float32Array.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19394. /**
  19395. * Set a vec2 array in the shader from a number array.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setArray2(name: string, value: number[]): ShaderMaterial;
  19401. /**
  19402. * Set a vec3 array in the shader from a number array.
  19403. * @param name Define the name of the uniform as defined in the shader
  19404. * @param value Define the value to give to the uniform
  19405. * @return the material itself allowing "fluent" like uniform updates
  19406. */
  19407. setArray3(name: string, value: number[]): ShaderMaterial;
  19408. /**
  19409. * Set a vec4 array in the shader from a number array.
  19410. * @param name Define the name of the uniform as defined in the shader
  19411. * @param value Define the value to give to the uniform
  19412. * @return the material itself allowing "fluent" like uniform updates
  19413. */
  19414. setArray4(name: string, value: number[]): ShaderMaterial;
  19415. private _checkCache;
  19416. /**
  19417. * Specifies that the submesh is ready to be used
  19418. * @param mesh defines the mesh to check
  19419. * @param subMesh defines which submesh to check
  19420. * @param useInstances specifies that instances should be used
  19421. * @returns a boolean indicating that the submesh is ready or not
  19422. */
  19423. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19424. /**
  19425. * Checks if the material is ready to render the requested mesh
  19426. * @param mesh Define the mesh to render
  19427. * @param useInstances Define whether or not the material is used with instances
  19428. * @returns true if ready, otherwise false
  19429. */
  19430. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19431. /**
  19432. * Binds the world matrix to the material
  19433. * @param world defines the world transformation matrix
  19434. */
  19435. bindOnlyWorldMatrix(world: Matrix): void;
  19436. /**
  19437. * Binds the material to the mesh
  19438. * @param world defines the world transformation matrix
  19439. * @param mesh defines the mesh to bind the material to
  19440. */
  19441. bind(world: Matrix, mesh?: Mesh): void;
  19442. /**
  19443. * Gets the active textures from the material
  19444. * @returns an array of textures
  19445. */
  19446. getActiveTextures(): BaseTexture[];
  19447. /**
  19448. * Specifies if the material uses a texture
  19449. * @param texture defines the texture to check against the material
  19450. * @returns a boolean specifying if the material uses the texture
  19451. */
  19452. hasTexture(texture: BaseTexture): boolean;
  19453. /**
  19454. * Makes a duplicate of the material, and gives it a new name
  19455. * @param name defines the new name for the duplicated material
  19456. * @returns the cloned material
  19457. */
  19458. clone(name: string): ShaderMaterial;
  19459. /**
  19460. * Disposes the material
  19461. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19462. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19463. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19464. */
  19465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19466. /**
  19467. * Serializes this material in a JSON representation
  19468. * @returns the serialized material object
  19469. */
  19470. serialize(): any;
  19471. /**
  19472. * Creates a shader material from parsed shader material data
  19473. * @param source defines the JSON represnetation of the material
  19474. * @param scene defines the hosting scene
  19475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19476. * @returns a new material
  19477. */
  19478. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19479. }
  19480. }
  19481. declare module "babylonjs/Shaders/color.fragment" {
  19482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19483. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19484. /** @hidden */
  19485. export var colorPixelShader: {
  19486. name: string;
  19487. shader: string;
  19488. };
  19489. }
  19490. declare module "babylonjs/Shaders/color.vertex" {
  19491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19492. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19493. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19494. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19495. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19496. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19497. /** @hidden */
  19498. export var colorVertexShader: {
  19499. name: string;
  19500. shader: string;
  19501. };
  19502. }
  19503. declare module "babylonjs/Meshes/linesMesh" {
  19504. import { Nullable } from "babylonjs/types";
  19505. import { Scene } from "babylonjs/scene";
  19506. import { Color3 } from "babylonjs/Maths/math.color";
  19507. import { Node } from "babylonjs/node";
  19508. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19509. import { Mesh } from "babylonjs/Meshes/mesh";
  19510. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19511. import { Effect } from "babylonjs/Materials/effect";
  19512. import { Material } from "babylonjs/Materials/material";
  19513. import "babylonjs/Shaders/color.fragment";
  19514. import "babylonjs/Shaders/color.vertex";
  19515. /**
  19516. * Line mesh
  19517. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19518. */
  19519. export class LinesMesh extends Mesh {
  19520. /**
  19521. * If vertex color should be applied to the mesh
  19522. */
  19523. readonly useVertexColor?: boolean | undefined;
  19524. /**
  19525. * If vertex alpha should be applied to the mesh
  19526. */
  19527. readonly useVertexAlpha?: boolean | undefined;
  19528. /**
  19529. * Color of the line (Default: White)
  19530. */
  19531. color: Color3;
  19532. /**
  19533. * Alpha of the line (Default: 1)
  19534. */
  19535. alpha: number;
  19536. /**
  19537. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19538. * This margin is expressed in world space coordinates, so its value may vary.
  19539. * Default value is 0.1
  19540. */
  19541. intersectionThreshold: number;
  19542. private _colorShader;
  19543. private color4;
  19544. /**
  19545. * Creates a new LinesMesh
  19546. * @param name defines the name
  19547. * @param scene defines the hosting scene
  19548. * @param parent defines the parent mesh if any
  19549. * @param source defines the optional source LinesMesh used to clone data from
  19550. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19551. * When false, achieved by calling a clone(), also passing False.
  19552. * This will make creation of children, recursive.
  19553. * @param useVertexColor defines if this LinesMesh supports vertex color
  19554. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19555. */
  19556. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19557. /**
  19558. * If vertex color should be applied to the mesh
  19559. */
  19560. useVertexColor?: boolean | undefined,
  19561. /**
  19562. * If vertex alpha should be applied to the mesh
  19563. */
  19564. useVertexAlpha?: boolean | undefined);
  19565. private _addClipPlaneDefine;
  19566. private _removeClipPlaneDefine;
  19567. isReady(): boolean;
  19568. /**
  19569. * Returns the string "LineMesh"
  19570. */
  19571. getClassName(): string;
  19572. /**
  19573. * @hidden
  19574. */
  19575. /**
  19576. * @hidden
  19577. */
  19578. material: Material;
  19579. /**
  19580. * @hidden
  19581. */
  19582. readonly checkCollisions: boolean;
  19583. /** @hidden */
  19584. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19585. /** @hidden */
  19586. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19587. /**
  19588. * Disposes of the line mesh
  19589. * @param doNotRecurse If children should be disposed
  19590. */
  19591. dispose(doNotRecurse?: boolean): void;
  19592. /**
  19593. * Returns a new LineMesh object cloned from the current one.
  19594. */
  19595. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19596. /**
  19597. * Creates a new InstancedLinesMesh object from the mesh model.
  19598. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19599. * @param name defines the name of the new instance
  19600. * @returns a new InstancedLinesMesh
  19601. */
  19602. createInstance(name: string): InstancedLinesMesh;
  19603. }
  19604. /**
  19605. * Creates an instance based on a source LinesMesh
  19606. */
  19607. export class InstancedLinesMesh extends InstancedMesh {
  19608. /**
  19609. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19610. * This margin is expressed in world space coordinates, so its value may vary.
  19611. * Initilized with the intersectionThreshold value of the source LinesMesh
  19612. */
  19613. intersectionThreshold: number;
  19614. constructor(name: string, source: LinesMesh);
  19615. /**
  19616. * Returns the string "InstancedLinesMesh".
  19617. */
  19618. getClassName(): string;
  19619. }
  19620. }
  19621. declare module "babylonjs/Shaders/line.fragment" {
  19622. /** @hidden */
  19623. export var linePixelShader: {
  19624. name: string;
  19625. shader: string;
  19626. };
  19627. }
  19628. declare module "babylonjs/Shaders/line.vertex" {
  19629. /** @hidden */
  19630. export var lineVertexShader: {
  19631. name: string;
  19632. shader: string;
  19633. };
  19634. }
  19635. declare module "babylonjs/Rendering/edgesRenderer" {
  19636. import { Nullable } from "babylonjs/types";
  19637. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19639. import { Vector3 } from "babylonjs/Maths/math.vector";
  19640. import { IDisposable } from "babylonjs/scene";
  19641. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19642. import "babylonjs/Shaders/line.fragment";
  19643. import "babylonjs/Shaders/line.vertex";
  19644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19645. module "babylonjs/Meshes/abstractMesh" {
  19646. interface AbstractMesh {
  19647. /**
  19648. * Gets the edgesRenderer associated with the mesh
  19649. */
  19650. edgesRenderer: Nullable<EdgesRenderer>;
  19651. }
  19652. }
  19653. module "babylonjs/Meshes/linesMesh" {
  19654. interface LinesMesh {
  19655. /**
  19656. * Enables the edge rendering mode on the mesh.
  19657. * This mode makes the mesh edges visible
  19658. * @param epsilon defines the maximal distance between two angles to detect a face
  19659. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19660. * @returns the currentAbstractMesh
  19661. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19662. */
  19663. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19664. }
  19665. }
  19666. module "babylonjs/Meshes/linesMesh" {
  19667. interface InstancedLinesMesh {
  19668. /**
  19669. * Enables the edge rendering mode on the mesh.
  19670. * This mode makes the mesh edges visible
  19671. * @param epsilon defines the maximal distance between two angles to detect a face
  19672. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19673. * @returns the current InstancedLinesMesh
  19674. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19675. */
  19676. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19677. }
  19678. }
  19679. /**
  19680. * Defines the minimum contract an Edges renderer should follow.
  19681. */
  19682. export interface IEdgesRenderer extends IDisposable {
  19683. /**
  19684. * Gets or sets a boolean indicating if the edgesRenderer is active
  19685. */
  19686. isEnabled: boolean;
  19687. /**
  19688. * Renders the edges of the attached mesh,
  19689. */
  19690. render(): void;
  19691. /**
  19692. * Checks wether or not the edges renderer is ready to render.
  19693. * @return true if ready, otherwise false.
  19694. */
  19695. isReady(): boolean;
  19696. }
  19697. /**
  19698. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19699. */
  19700. export class EdgesRenderer implements IEdgesRenderer {
  19701. /**
  19702. * Define the size of the edges with an orthographic camera
  19703. */
  19704. edgesWidthScalerForOrthographic: number;
  19705. /**
  19706. * Define the size of the edges with a perspective camera
  19707. */
  19708. edgesWidthScalerForPerspective: number;
  19709. protected _source: AbstractMesh;
  19710. protected _linesPositions: number[];
  19711. protected _linesNormals: number[];
  19712. protected _linesIndices: number[];
  19713. protected _epsilon: number;
  19714. protected _indicesCount: number;
  19715. protected _lineShader: ShaderMaterial;
  19716. protected _ib: DataBuffer;
  19717. protected _buffers: {
  19718. [key: string]: Nullable<VertexBuffer>;
  19719. };
  19720. protected _checkVerticesInsteadOfIndices: boolean;
  19721. private _meshRebuildObserver;
  19722. private _meshDisposeObserver;
  19723. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19724. isEnabled: boolean;
  19725. /**
  19726. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19727. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19728. * @param source Mesh used to create edges
  19729. * @param epsilon sum of angles in adjacency to check for edge
  19730. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19731. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19732. */
  19733. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19734. protected _prepareRessources(): void;
  19735. /** @hidden */
  19736. _rebuild(): void;
  19737. /**
  19738. * Releases the required resources for the edges renderer
  19739. */
  19740. dispose(): void;
  19741. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19742. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19743. /**
  19744. * Checks if the pair of p0 and p1 is en edge
  19745. * @param faceIndex
  19746. * @param edge
  19747. * @param faceNormals
  19748. * @param p0
  19749. * @param p1
  19750. * @private
  19751. */
  19752. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19753. /**
  19754. * push line into the position, normal and index buffer
  19755. * @protected
  19756. */
  19757. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19758. /**
  19759. * Generates lines edges from adjacencjes
  19760. * @private
  19761. */
  19762. _generateEdgesLines(): void;
  19763. /**
  19764. * Checks wether or not the edges renderer is ready to render.
  19765. * @return true if ready, otherwise false.
  19766. */
  19767. isReady(): boolean;
  19768. /**
  19769. * Renders the edges of the attached mesh,
  19770. */
  19771. render(): void;
  19772. }
  19773. /**
  19774. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19775. */
  19776. export class LineEdgesRenderer extends EdgesRenderer {
  19777. /**
  19778. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19779. * @param source LineMesh used to generate edges
  19780. * @param epsilon not important (specified angle for edge detection)
  19781. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19782. */
  19783. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19784. /**
  19785. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19786. */
  19787. _generateEdgesLines(): void;
  19788. }
  19789. }
  19790. declare module "babylonjs/Rendering/renderingGroup" {
  19791. import { SmartArray } from "babylonjs/Misc/smartArray";
  19792. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19794. import { Nullable } from "babylonjs/types";
  19795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19796. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19797. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19798. import { Material } from "babylonjs/Materials/material";
  19799. import { Scene } from "babylonjs/scene";
  19800. /**
  19801. * This represents the object necessary to create a rendering group.
  19802. * This is exclusively used and created by the rendering manager.
  19803. * To modify the behavior, you use the available helpers in your scene or meshes.
  19804. * @hidden
  19805. */
  19806. export class RenderingGroup {
  19807. index: number;
  19808. private static _zeroVector;
  19809. private _scene;
  19810. private _opaqueSubMeshes;
  19811. private _transparentSubMeshes;
  19812. private _alphaTestSubMeshes;
  19813. private _depthOnlySubMeshes;
  19814. private _particleSystems;
  19815. private _spriteManagers;
  19816. private _opaqueSortCompareFn;
  19817. private _alphaTestSortCompareFn;
  19818. private _transparentSortCompareFn;
  19819. private _renderOpaque;
  19820. private _renderAlphaTest;
  19821. private _renderTransparent;
  19822. /** @hidden */
  19823. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19824. onBeforeTransparentRendering: () => void;
  19825. /**
  19826. * Set the opaque sort comparison function.
  19827. * If null the sub meshes will be render in the order they were created
  19828. */
  19829. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19830. /**
  19831. * Set the alpha test sort comparison function.
  19832. * If null the sub meshes will be render in the order they were created
  19833. */
  19834. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19835. /**
  19836. * Set the transparent sort comparison function.
  19837. * If null the sub meshes will be render in the order they were created
  19838. */
  19839. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19840. /**
  19841. * Creates a new rendering group.
  19842. * @param index The rendering group index
  19843. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19844. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19845. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19846. */
  19847. 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>);
  19848. /**
  19849. * Render all the sub meshes contained in the group.
  19850. * @param customRenderFunction Used to override the default render behaviour of the group.
  19851. * @returns true if rendered some submeshes.
  19852. */
  19853. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19854. /**
  19855. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19856. * @param subMeshes The submeshes to render
  19857. */
  19858. private renderOpaqueSorted;
  19859. /**
  19860. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19861. * @param subMeshes The submeshes to render
  19862. */
  19863. private renderAlphaTestSorted;
  19864. /**
  19865. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19866. * @param subMeshes The submeshes to render
  19867. */
  19868. private renderTransparentSorted;
  19869. /**
  19870. * Renders the submeshes in a specified order.
  19871. * @param subMeshes The submeshes to sort before render
  19872. * @param sortCompareFn The comparison function use to sort
  19873. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19874. * @param transparent Specifies to activate blending if true
  19875. */
  19876. private static renderSorted;
  19877. /**
  19878. * Renders the submeshes in the order they were dispatched (no sort applied).
  19879. * @param subMeshes The submeshes to render
  19880. */
  19881. private static renderUnsorted;
  19882. /**
  19883. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19884. * are rendered back to front if in the same alpha index.
  19885. *
  19886. * @param a The first submesh
  19887. * @param b The second submesh
  19888. * @returns The result of the comparison
  19889. */
  19890. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19891. /**
  19892. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19893. * are rendered back to front.
  19894. *
  19895. * @param a The first submesh
  19896. * @param b The second submesh
  19897. * @returns The result of the comparison
  19898. */
  19899. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19900. /**
  19901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19902. * are rendered front to back (prevent overdraw).
  19903. *
  19904. * @param a The first submesh
  19905. * @param b The second submesh
  19906. * @returns The result of the comparison
  19907. */
  19908. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19909. /**
  19910. * Resets the different lists of submeshes to prepare a new frame.
  19911. */
  19912. prepare(): void;
  19913. dispose(): void;
  19914. /**
  19915. * Inserts the submesh in its correct queue depending on its material.
  19916. * @param subMesh The submesh to dispatch
  19917. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19918. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19919. */
  19920. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19921. dispatchSprites(spriteManager: ISpriteManager): void;
  19922. dispatchParticles(particleSystem: IParticleSystem): void;
  19923. private _renderParticles;
  19924. private _renderSprites;
  19925. }
  19926. }
  19927. declare module "babylonjs/Rendering/renderingManager" {
  19928. import { Nullable } from "babylonjs/types";
  19929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19931. import { SmartArray } from "babylonjs/Misc/smartArray";
  19932. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19933. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19934. import { Material } from "babylonjs/Materials/material";
  19935. import { Scene } from "babylonjs/scene";
  19936. import { Camera } from "babylonjs/Cameras/camera";
  19937. /**
  19938. * Interface describing the different options available in the rendering manager
  19939. * regarding Auto Clear between groups.
  19940. */
  19941. export interface IRenderingManagerAutoClearSetup {
  19942. /**
  19943. * Defines whether or not autoclear is enable.
  19944. */
  19945. autoClear: boolean;
  19946. /**
  19947. * Defines whether or not to autoclear the depth buffer.
  19948. */
  19949. depth: boolean;
  19950. /**
  19951. * Defines whether or not to autoclear the stencil buffer.
  19952. */
  19953. stencil: boolean;
  19954. }
  19955. /**
  19956. * This class is used by the onRenderingGroupObservable
  19957. */
  19958. export class RenderingGroupInfo {
  19959. /**
  19960. * The Scene that being rendered
  19961. */
  19962. scene: Scene;
  19963. /**
  19964. * The camera currently used for the rendering pass
  19965. */
  19966. camera: Nullable<Camera>;
  19967. /**
  19968. * The ID of the renderingGroup being processed
  19969. */
  19970. renderingGroupId: number;
  19971. }
  19972. /**
  19973. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19974. * It is enable to manage the different groups as well as the different necessary sort functions.
  19975. * This should not be used directly aside of the few static configurations
  19976. */
  19977. export class RenderingManager {
  19978. /**
  19979. * The max id used for rendering groups (not included)
  19980. */
  19981. static MAX_RENDERINGGROUPS: number;
  19982. /**
  19983. * The min id used for rendering groups (included)
  19984. */
  19985. static MIN_RENDERINGGROUPS: number;
  19986. /**
  19987. * Used to globally prevent autoclearing scenes.
  19988. */
  19989. static AUTOCLEAR: boolean;
  19990. /**
  19991. * @hidden
  19992. */
  19993. _useSceneAutoClearSetup: boolean;
  19994. private _scene;
  19995. private _renderingGroups;
  19996. private _depthStencilBufferAlreadyCleaned;
  19997. private _autoClearDepthStencil;
  19998. private _customOpaqueSortCompareFn;
  19999. private _customAlphaTestSortCompareFn;
  20000. private _customTransparentSortCompareFn;
  20001. private _renderingGroupInfo;
  20002. /**
  20003. * Instantiates a new rendering group for a particular scene
  20004. * @param scene Defines the scene the groups belongs to
  20005. */
  20006. constructor(scene: Scene);
  20007. private _clearDepthStencilBuffer;
  20008. /**
  20009. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20010. * @hidden
  20011. */
  20012. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20013. /**
  20014. * Resets the different information of the group to prepare a new frame
  20015. * @hidden
  20016. */
  20017. reset(): void;
  20018. /**
  20019. * Dispose and release the group and its associated resources.
  20020. * @hidden
  20021. */
  20022. dispose(): void;
  20023. /**
  20024. * Clear the info related to rendering groups preventing retention points during dispose.
  20025. */
  20026. freeRenderingGroups(): void;
  20027. private _prepareRenderingGroup;
  20028. /**
  20029. * Add a sprite manager to the rendering manager in order to render it this frame.
  20030. * @param spriteManager Define the sprite manager to render
  20031. */
  20032. dispatchSprites(spriteManager: ISpriteManager): void;
  20033. /**
  20034. * Add a particle system to the rendering manager in order to render it this frame.
  20035. * @param particleSystem Define the particle system to render
  20036. */
  20037. dispatchParticles(particleSystem: IParticleSystem): void;
  20038. /**
  20039. * Add a submesh to the manager in order to render it this frame
  20040. * @param subMesh The submesh to dispatch
  20041. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20042. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20043. */
  20044. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20045. /**
  20046. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20047. * This allowed control for front to back rendering or reversly depending of the special needs.
  20048. *
  20049. * @param renderingGroupId The rendering group id corresponding to its index
  20050. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20051. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20052. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20053. */
  20054. 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;
  20055. /**
  20056. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20057. *
  20058. * @param renderingGroupId The rendering group id corresponding to its index
  20059. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20060. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20061. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20062. */
  20063. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20064. /**
  20065. * Gets the current auto clear configuration for one rendering group of the rendering
  20066. * manager.
  20067. * @param index the rendering group index to get the information for
  20068. * @returns The auto clear setup for the requested rendering group
  20069. */
  20070. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20071. }
  20072. }
  20073. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { SmartArray } from "babylonjs/Misc/smartArray";
  20076. import { Nullable } from "babylonjs/types";
  20077. import { Camera } from "babylonjs/Cameras/camera";
  20078. import { Scene } from "babylonjs/scene";
  20079. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20080. import { Color4 } from "babylonjs/Maths/math.color";
  20081. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20083. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20084. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20085. import { Texture } from "babylonjs/Materials/Textures/texture";
  20086. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20087. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20088. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20089. import { Engine } from "babylonjs/Engines/engine";
  20090. /**
  20091. * This Helps creating a texture that will be created from a camera in your scene.
  20092. * It is basically a dynamic texture that could be used to create special effects for instance.
  20093. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20094. */
  20095. export class RenderTargetTexture extends Texture {
  20096. isCube: boolean;
  20097. /**
  20098. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20099. */
  20100. static readonly REFRESHRATE_RENDER_ONCE: number;
  20101. /**
  20102. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20103. */
  20104. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20105. /**
  20106. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20107. * the central point of your effect and can save a lot of performances.
  20108. */
  20109. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20110. /**
  20111. * Use this predicate to dynamically define the list of mesh you want to render.
  20112. * If set, the renderList property will be overwritten.
  20113. */
  20114. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20115. private _renderList;
  20116. /**
  20117. * Use this list to define the list of mesh you want to render.
  20118. */
  20119. renderList: Nullable<Array<AbstractMesh>>;
  20120. private _hookArray;
  20121. /**
  20122. * Define if particles should be rendered in your texture.
  20123. */
  20124. renderParticles: boolean;
  20125. /**
  20126. * Define if sprites should be rendered in your texture.
  20127. */
  20128. renderSprites: boolean;
  20129. /**
  20130. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20131. */
  20132. coordinatesMode: number;
  20133. /**
  20134. * Define the camera used to render the texture.
  20135. */
  20136. activeCamera: Nullable<Camera>;
  20137. /**
  20138. * Override the render function of the texture with your own one.
  20139. */
  20140. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20141. /**
  20142. * Define if camera post processes should be use while rendering the texture.
  20143. */
  20144. useCameraPostProcesses: boolean;
  20145. /**
  20146. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20147. */
  20148. ignoreCameraViewport: boolean;
  20149. private _postProcessManager;
  20150. private _postProcesses;
  20151. private _resizeObserver;
  20152. /**
  20153. * An event triggered when the texture is unbind.
  20154. */
  20155. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20156. /**
  20157. * An event triggered when the texture is unbind.
  20158. */
  20159. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20160. private _onAfterUnbindObserver;
  20161. /**
  20162. * Set a after unbind callback in the texture.
  20163. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20164. */
  20165. onAfterUnbind: () => void;
  20166. /**
  20167. * An event triggered before rendering the texture
  20168. */
  20169. onBeforeRenderObservable: Observable<number>;
  20170. private _onBeforeRenderObserver;
  20171. /**
  20172. * Set a before render callback in the texture.
  20173. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20174. */
  20175. onBeforeRender: (faceIndex: number) => void;
  20176. /**
  20177. * An event triggered after rendering the texture
  20178. */
  20179. onAfterRenderObservable: Observable<number>;
  20180. private _onAfterRenderObserver;
  20181. /**
  20182. * Set a after render callback in the texture.
  20183. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20184. */
  20185. onAfterRender: (faceIndex: number) => void;
  20186. /**
  20187. * An event triggered after the texture clear
  20188. */
  20189. onClearObservable: Observable<Engine>;
  20190. private _onClearObserver;
  20191. /**
  20192. * Set a clear callback in the texture.
  20193. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20194. */
  20195. onClear: (Engine: Engine) => void;
  20196. /**
  20197. * Define the clear color of the Render Target if it should be different from the scene.
  20198. */
  20199. clearColor: Color4;
  20200. protected _size: number | {
  20201. width: number;
  20202. height: number;
  20203. };
  20204. protected _initialSizeParameter: number | {
  20205. width: number;
  20206. height: number;
  20207. } | {
  20208. ratio: number;
  20209. };
  20210. protected _sizeRatio: Nullable<number>;
  20211. /** @hidden */
  20212. _generateMipMaps: boolean;
  20213. protected _renderingManager: RenderingManager;
  20214. /** @hidden */
  20215. _waitingRenderList: string[];
  20216. protected _doNotChangeAspectRatio: boolean;
  20217. protected _currentRefreshId: number;
  20218. protected _refreshRate: number;
  20219. protected _textureMatrix: Matrix;
  20220. protected _samples: number;
  20221. protected _renderTargetOptions: RenderTargetCreationOptions;
  20222. /**
  20223. * Gets render target creation options that were used.
  20224. */
  20225. readonly renderTargetOptions: RenderTargetCreationOptions;
  20226. protected _engine: Engine;
  20227. protected _onRatioRescale(): void;
  20228. /**
  20229. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20230. * It must define where the camera used to render the texture is set
  20231. */
  20232. boundingBoxPosition: Vector3;
  20233. private _boundingBoxSize;
  20234. /**
  20235. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20236. * When defined, the cubemap will switch to local mode
  20237. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20238. * @example https://www.babylonjs-playground.com/#RNASML
  20239. */
  20240. boundingBoxSize: Vector3;
  20241. /**
  20242. * In case the RTT has been created with a depth texture, get the associated
  20243. * depth texture.
  20244. * Otherwise, return null.
  20245. */
  20246. depthStencilTexture: Nullable<InternalTexture>;
  20247. /**
  20248. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20249. * or used a shadow, depth texture...
  20250. * @param name The friendly name of the texture
  20251. * @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)
  20252. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20253. * @param generateMipMaps True if mip maps need to be generated after render.
  20254. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20255. * @param type The type of the buffer in the RTT (int, half float, float...)
  20256. * @param isCube True if a cube texture needs to be created
  20257. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20258. * @param generateDepthBuffer True to generate a depth buffer
  20259. * @param generateStencilBuffer True to generate a stencil buffer
  20260. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20261. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20262. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20263. */
  20264. constructor(name: string, size: number | {
  20265. width: number;
  20266. height: number;
  20267. } | {
  20268. ratio: number;
  20269. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20270. /**
  20271. * Creates a depth stencil texture.
  20272. * This is only available in WebGL 2 or with the depth texture extension available.
  20273. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20274. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20275. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20276. */
  20277. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20278. private _processSizeParameter;
  20279. /**
  20280. * Define the number of samples to use in case of MSAA.
  20281. * It defaults to one meaning no MSAA has been enabled.
  20282. */
  20283. samples: number;
  20284. /**
  20285. * Resets the refresh counter of the texture and start bak from scratch.
  20286. * Could be useful to regenerate the texture if it is setup to render only once.
  20287. */
  20288. resetRefreshCounter(): void;
  20289. /**
  20290. * Define the refresh rate of the texture or the rendering frequency.
  20291. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20292. */
  20293. refreshRate: number;
  20294. /**
  20295. * Adds a post process to the render target rendering passes.
  20296. * @param postProcess define the post process to add
  20297. */
  20298. addPostProcess(postProcess: PostProcess): void;
  20299. /**
  20300. * Clear all the post processes attached to the render target
  20301. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20302. */
  20303. clearPostProcesses(dispose?: boolean): void;
  20304. /**
  20305. * Remove one of the post process from the list of attached post processes to the texture
  20306. * @param postProcess define the post process to remove from the list
  20307. */
  20308. removePostProcess(postProcess: PostProcess): void;
  20309. /** @hidden */
  20310. _shouldRender(): boolean;
  20311. /**
  20312. * Gets the actual render size of the texture.
  20313. * @returns the width of the render size
  20314. */
  20315. getRenderSize(): number;
  20316. /**
  20317. * Gets the actual render width of the texture.
  20318. * @returns the width of the render size
  20319. */
  20320. getRenderWidth(): number;
  20321. /**
  20322. * Gets the actual render height of the texture.
  20323. * @returns the height of the render size
  20324. */
  20325. getRenderHeight(): number;
  20326. /**
  20327. * Get if the texture can be rescaled or not.
  20328. */
  20329. readonly canRescale: boolean;
  20330. /**
  20331. * Resize the texture using a ratio.
  20332. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20333. */
  20334. scale(ratio: number): void;
  20335. /**
  20336. * Get the texture reflection matrix used to rotate/transform the reflection.
  20337. * @returns the reflection matrix
  20338. */
  20339. getReflectionTextureMatrix(): Matrix;
  20340. /**
  20341. * Resize the texture to a new desired size.
  20342. * Be carrefull as it will recreate all the data in the new texture.
  20343. * @param size Define the new size. It can be:
  20344. * - a number for squared texture,
  20345. * - an object containing { width: number, height: number }
  20346. * - or an object containing a ratio { ratio: number }
  20347. */
  20348. resize(size: number | {
  20349. width: number;
  20350. height: number;
  20351. } | {
  20352. ratio: number;
  20353. }): void;
  20354. /**
  20355. * Renders all the objects from the render list into the texture.
  20356. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20357. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20358. */
  20359. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20360. private _bestReflectionRenderTargetDimension;
  20361. /**
  20362. * @hidden
  20363. * @param faceIndex face index to bind to if this is a cubetexture
  20364. */
  20365. _bindFrameBuffer(faceIndex?: number): void;
  20366. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20367. private renderToTarget;
  20368. /**
  20369. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20370. * This allowed control for front to back rendering or reversly depending of the special needs.
  20371. *
  20372. * @param renderingGroupId The rendering group id corresponding to its index
  20373. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20374. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20375. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20376. */
  20377. 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;
  20378. /**
  20379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20380. *
  20381. * @param renderingGroupId The rendering group id corresponding to its index
  20382. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20383. */
  20384. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20385. /**
  20386. * Clones the texture.
  20387. * @returns the cloned texture
  20388. */
  20389. clone(): RenderTargetTexture;
  20390. /**
  20391. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20392. * @returns The JSON representation of the texture
  20393. */
  20394. serialize(): any;
  20395. /**
  20396. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20397. */
  20398. disposeFramebufferObjects(): void;
  20399. /**
  20400. * Dispose the texture and release its associated resources.
  20401. */
  20402. dispose(): void;
  20403. /** @hidden */
  20404. _rebuild(): void;
  20405. /**
  20406. * Clear the info related to rendering groups preventing retention point in material dispose.
  20407. */
  20408. freeRenderingGroups(): void;
  20409. /**
  20410. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20411. * @returns the view count
  20412. */
  20413. getViewCount(): number;
  20414. }
  20415. }
  20416. declare module "babylonjs/Materials/material" {
  20417. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20418. import { SmartArray } from "babylonjs/Misc/smartArray";
  20419. import { Observable } from "babylonjs/Misc/observable";
  20420. import { Nullable } from "babylonjs/types";
  20421. import { Scene } from "babylonjs/scene";
  20422. import { Matrix } from "babylonjs/Maths/math.vector";
  20423. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20425. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20426. import { Effect } from "babylonjs/Materials/effect";
  20427. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20429. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20430. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20431. import { Mesh } from "babylonjs/Meshes/mesh";
  20432. import { Animation } from "babylonjs/Animations/animation";
  20433. /**
  20434. * Base class for the main features of a material in Babylon.js
  20435. */
  20436. export class Material implements IAnimatable {
  20437. /**
  20438. * Returns the triangle fill mode
  20439. */
  20440. static readonly TriangleFillMode: number;
  20441. /**
  20442. * Returns the wireframe mode
  20443. */
  20444. static readonly WireFrameFillMode: number;
  20445. /**
  20446. * Returns the point fill mode
  20447. */
  20448. static readonly PointFillMode: number;
  20449. /**
  20450. * Returns the point list draw mode
  20451. */
  20452. static readonly PointListDrawMode: number;
  20453. /**
  20454. * Returns the line list draw mode
  20455. */
  20456. static readonly LineListDrawMode: number;
  20457. /**
  20458. * Returns the line loop draw mode
  20459. */
  20460. static readonly LineLoopDrawMode: number;
  20461. /**
  20462. * Returns the line strip draw mode
  20463. */
  20464. static readonly LineStripDrawMode: number;
  20465. /**
  20466. * Returns the triangle strip draw mode
  20467. */
  20468. static readonly TriangleStripDrawMode: number;
  20469. /**
  20470. * Returns the triangle fan draw mode
  20471. */
  20472. static readonly TriangleFanDrawMode: number;
  20473. /**
  20474. * Stores the clock-wise side orientation
  20475. */
  20476. static readonly ClockWiseSideOrientation: number;
  20477. /**
  20478. * Stores the counter clock-wise side orientation
  20479. */
  20480. static readonly CounterClockWiseSideOrientation: number;
  20481. /**
  20482. * The dirty texture flag value
  20483. */
  20484. static readonly TextureDirtyFlag: number;
  20485. /**
  20486. * The dirty light flag value
  20487. */
  20488. static readonly LightDirtyFlag: number;
  20489. /**
  20490. * The dirty fresnel flag value
  20491. */
  20492. static readonly FresnelDirtyFlag: number;
  20493. /**
  20494. * The dirty attribute flag value
  20495. */
  20496. static readonly AttributesDirtyFlag: number;
  20497. /**
  20498. * The dirty misc flag value
  20499. */
  20500. static readonly MiscDirtyFlag: number;
  20501. /**
  20502. * The all dirty flag value
  20503. */
  20504. static readonly AllDirtyFlag: number;
  20505. /**
  20506. * The ID of the material
  20507. */
  20508. id: string;
  20509. /**
  20510. * Gets or sets the unique id of the material
  20511. */
  20512. uniqueId: number;
  20513. /**
  20514. * The name of the material
  20515. */
  20516. name: string;
  20517. /**
  20518. * Gets or sets user defined metadata
  20519. */
  20520. metadata: any;
  20521. /**
  20522. * For internal use only. Please do not use.
  20523. */
  20524. reservedDataStore: any;
  20525. /**
  20526. * Specifies if the ready state should be checked on each call
  20527. */
  20528. checkReadyOnEveryCall: boolean;
  20529. /**
  20530. * Specifies if the ready state should be checked once
  20531. */
  20532. checkReadyOnlyOnce: boolean;
  20533. /**
  20534. * The state of the material
  20535. */
  20536. state: string;
  20537. /**
  20538. * The alpha value of the material
  20539. */
  20540. protected _alpha: number;
  20541. /**
  20542. * List of inspectable custom properties (used by the Inspector)
  20543. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20544. */
  20545. inspectableCustomProperties: IInspectable[];
  20546. /**
  20547. * Sets the alpha value of the material
  20548. */
  20549. /**
  20550. * Gets the alpha value of the material
  20551. */
  20552. alpha: number;
  20553. /**
  20554. * Specifies if back face culling is enabled
  20555. */
  20556. protected _backFaceCulling: boolean;
  20557. /**
  20558. * Sets the back-face culling state
  20559. */
  20560. /**
  20561. * Gets the back-face culling state
  20562. */
  20563. backFaceCulling: boolean;
  20564. /**
  20565. * Stores the value for side orientation
  20566. */
  20567. sideOrientation: number;
  20568. /**
  20569. * Callback triggered when the material is compiled
  20570. */
  20571. onCompiled: Nullable<(effect: Effect) => void>;
  20572. /**
  20573. * Callback triggered when an error occurs
  20574. */
  20575. onError: Nullable<(effect: Effect, errors: string) => void>;
  20576. /**
  20577. * Callback triggered to get the render target textures
  20578. */
  20579. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20580. /**
  20581. * Gets a boolean indicating that current material needs to register RTT
  20582. */
  20583. readonly hasRenderTargetTextures: boolean;
  20584. /**
  20585. * Specifies if the material should be serialized
  20586. */
  20587. doNotSerialize: boolean;
  20588. /**
  20589. * @hidden
  20590. */
  20591. _storeEffectOnSubMeshes: boolean;
  20592. /**
  20593. * Stores the animations for the material
  20594. */
  20595. animations: Nullable<Array<Animation>>;
  20596. /**
  20597. * An event triggered when the material is disposed
  20598. */
  20599. onDisposeObservable: Observable<Material>;
  20600. /**
  20601. * An observer which watches for dispose events
  20602. */
  20603. private _onDisposeObserver;
  20604. private _onUnBindObservable;
  20605. /**
  20606. * Called during a dispose event
  20607. */
  20608. onDispose: () => void;
  20609. private _onBindObservable;
  20610. /**
  20611. * An event triggered when the material is bound
  20612. */
  20613. readonly onBindObservable: Observable<AbstractMesh>;
  20614. /**
  20615. * An observer which watches for bind events
  20616. */
  20617. private _onBindObserver;
  20618. /**
  20619. * Called during a bind event
  20620. */
  20621. onBind: (Mesh: AbstractMesh) => void;
  20622. /**
  20623. * An event triggered when the material is unbound
  20624. */
  20625. readonly onUnBindObservable: Observable<Material>;
  20626. /**
  20627. * Stores the value of the alpha mode
  20628. */
  20629. private _alphaMode;
  20630. /**
  20631. * Sets the value of the alpha mode.
  20632. *
  20633. * | Value | Type | Description |
  20634. * | --- | --- | --- |
  20635. * | 0 | ALPHA_DISABLE | |
  20636. * | 1 | ALPHA_ADD | |
  20637. * | 2 | ALPHA_COMBINE | |
  20638. * | 3 | ALPHA_SUBTRACT | |
  20639. * | 4 | ALPHA_MULTIPLY | |
  20640. * | 5 | ALPHA_MAXIMIZED | |
  20641. * | 6 | ALPHA_ONEONE | |
  20642. * | 7 | ALPHA_PREMULTIPLIED | |
  20643. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20644. * | 9 | ALPHA_INTERPOLATE | |
  20645. * | 10 | ALPHA_SCREENMODE | |
  20646. *
  20647. */
  20648. /**
  20649. * Gets the value of the alpha mode
  20650. */
  20651. alphaMode: number;
  20652. /**
  20653. * Stores the state of the need depth pre-pass value
  20654. */
  20655. private _needDepthPrePass;
  20656. /**
  20657. * Sets the need depth pre-pass value
  20658. */
  20659. /**
  20660. * Gets the depth pre-pass value
  20661. */
  20662. needDepthPrePass: boolean;
  20663. /**
  20664. * Specifies if depth writing should be disabled
  20665. */
  20666. disableDepthWrite: boolean;
  20667. /**
  20668. * Specifies if depth writing should be forced
  20669. */
  20670. forceDepthWrite: boolean;
  20671. /**
  20672. * Specifies if there should be a separate pass for culling
  20673. */
  20674. separateCullingPass: boolean;
  20675. /**
  20676. * Stores the state specifing if fog should be enabled
  20677. */
  20678. private _fogEnabled;
  20679. /**
  20680. * Sets the state for enabling fog
  20681. */
  20682. /**
  20683. * Gets the value of the fog enabled state
  20684. */
  20685. fogEnabled: boolean;
  20686. /**
  20687. * Stores the size of points
  20688. */
  20689. pointSize: number;
  20690. /**
  20691. * Stores the z offset value
  20692. */
  20693. zOffset: number;
  20694. /**
  20695. * Gets a value specifying if wireframe mode is enabled
  20696. */
  20697. /**
  20698. * Sets the state of wireframe mode
  20699. */
  20700. wireframe: boolean;
  20701. /**
  20702. * Gets the value specifying if point clouds are enabled
  20703. */
  20704. /**
  20705. * Sets the state of point cloud mode
  20706. */
  20707. pointsCloud: boolean;
  20708. /**
  20709. * Gets the material fill mode
  20710. */
  20711. /**
  20712. * Sets the material fill mode
  20713. */
  20714. fillMode: number;
  20715. /**
  20716. * @hidden
  20717. * Stores the effects for the material
  20718. */
  20719. _effect: Nullable<Effect>;
  20720. /**
  20721. * @hidden
  20722. * Specifies if the material was previously ready
  20723. */
  20724. _wasPreviouslyReady: boolean;
  20725. /**
  20726. * Specifies if uniform buffers should be used
  20727. */
  20728. private _useUBO;
  20729. /**
  20730. * Stores a reference to the scene
  20731. */
  20732. private _scene;
  20733. /**
  20734. * Stores the fill mode state
  20735. */
  20736. private _fillMode;
  20737. /**
  20738. * Specifies if the depth write state should be cached
  20739. */
  20740. private _cachedDepthWriteState;
  20741. /**
  20742. * Stores the uniform buffer
  20743. */
  20744. protected _uniformBuffer: UniformBuffer;
  20745. /** @hidden */
  20746. _indexInSceneMaterialArray: number;
  20747. /** @hidden */
  20748. meshMap: Nullable<{
  20749. [id: string]: AbstractMesh | undefined;
  20750. }>;
  20751. /**
  20752. * Creates a material instance
  20753. * @param name defines the name of the material
  20754. * @param scene defines the scene to reference
  20755. * @param doNotAdd specifies if the material should be added to the scene
  20756. */
  20757. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20758. /**
  20759. * Returns a string representation of the current material
  20760. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20761. * @returns a string with material information
  20762. */
  20763. toString(fullDetails?: boolean): string;
  20764. /**
  20765. * Gets the class name of the material
  20766. * @returns a string with the class name of the material
  20767. */
  20768. getClassName(): string;
  20769. /**
  20770. * Specifies if updates for the material been locked
  20771. */
  20772. readonly isFrozen: boolean;
  20773. /**
  20774. * Locks updates for the material
  20775. */
  20776. freeze(): void;
  20777. /**
  20778. * Unlocks updates for the material
  20779. */
  20780. unfreeze(): void;
  20781. /**
  20782. * Specifies if the material is ready to be used
  20783. * @param mesh defines the mesh to check
  20784. * @param useInstances specifies if instances should be used
  20785. * @returns a boolean indicating if the material is ready to be used
  20786. */
  20787. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20788. /**
  20789. * Specifies that the submesh is ready to be used
  20790. * @param mesh defines the mesh to check
  20791. * @param subMesh defines which submesh to check
  20792. * @param useInstances specifies that instances should be used
  20793. * @returns a boolean indicating that the submesh is ready or not
  20794. */
  20795. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20796. /**
  20797. * Returns the material effect
  20798. * @returns the effect associated with the material
  20799. */
  20800. getEffect(): Nullable<Effect>;
  20801. /**
  20802. * Returns the current scene
  20803. * @returns a Scene
  20804. */
  20805. getScene(): Scene;
  20806. /**
  20807. * Specifies if the material will require alpha blending
  20808. * @returns a boolean specifying if alpha blending is needed
  20809. */
  20810. needAlphaBlending(): boolean;
  20811. /**
  20812. * Specifies if the mesh will require alpha blending
  20813. * @param mesh defines the mesh to check
  20814. * @returns a boolean specifying if alpha blending is needed for the mesh
  20815. */
  20816. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20817. /**
  20818. * Specifies if this material should be rendered in alpha test mode
  20819. * @returns a boolean specifying if an alpha test is needed.
  20820. */
  20821. needAlphaTesting(): boolean;
  20822. /**
  20823. * Gets the texture used for the alpha test
  20824. * @returns the texture to use for alpha testing
  20825. */
  20826. getAlphaTestTexture(): Nullable<BaseTexture>;
  20827. /**
  20828. * Marks the material to indicate that it needs to be re-calculated
  20829. */
  20830. markDirty(): void;
  20831. /** @hidden */
  20832. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20833. /**
  20834. * Binds the material to the mesh
  20835. * @param world defines the world transformation matrix
  20836. * @param mesh defines the mesh to bind the material to
  20837. */
  20838. bind(world: Matrix, mesh?: Mesh): void;
  20839. /**
  20840. * Binds the submesh to the material
  20841. * @param world defines the world transformation matrix
  20842. * @param mesh defines the mesh containing the submesh
  20843. * @param subMesh defines the submesh to bind the material to
  20844. */
  20845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20846. /**
  20847. * Binds the world matrix to the material
  20848. * @param world defines the world transformation matrix
  20849. */
  20850. bindOnlyWorldMatrix(world: Matrix): void;
  20851. /**
  20852. * Binds the scene's uniform buffer to the effect.
  20853. * @param effect defines the effect to bind to the scene uniform buffer
  20854. * @param sceneUbo defines the uniform buffer storing scene data
  20855. */
  20856. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20857. /**
  20858. * Binds the view matrix to the effect
  20859. * @param effect defines the effect to bind the view matrix to
  20860. */
  20861. bindView(effect: Effect): void;
  20862. /**
  20863. * Binds the view projection matrix to the effect
  20864. * @param effect defines the effect to bind the view projection matrix to
  20865. */
  20866. bindViewProjection(effect: Effect): void;
  20867. /**
  20868. * Specifies if material alpha testing should be turned on for the mesh
  20869. * @param mesh defines the mesh to check
  20870. */
  20871. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20872. /**
  20873. * Processes to execute after binding the material to a mesh
  20874. * @param mesh defines the rendered mesh
  20875. */
  20876. protected _afterBind(mesh?: Mesh): void;
  20877. /**
  20878. * Unbinds the material from the mesh
  20879. */
  20880. unbind(): void;
  20881. /**
  20882. * Gets the active textures from the material
  20883. * @returns an array of textures
  20884. */
  20885. getActiveTextures(): BaseTexture[];
  20886. /**
  20887. * Specifies if the material uses a texture
  20888. * @param texture defines the texture to check against the material
  20889. * @returns a boolean specifying if the material uses the texture
  20890. */
  20891. hasTexture(texture: BaseTexture): boolean;
  20892. /**
  20893. * Makes a duplicate of the material, and gives it a new name
  20894. * @param name defines the new name for the duplicated material
  20895. * @returns the cloned material
  20896. */
  20897. clone(name: string): Nullable<Material>;
  20898. /**
  20899. * Gets the meshes bound to the material
  20900. * @returns an array of meshes bound to the material
  20901. */
  20902. getBindedMeshes(): AbstractMesh[];
  20903. /**
  20904. * Force shader compilation
  20905. * @param mesh defines the mesh associated with this material
  20906. * @param onCompiled defines a function to execute once the material is compiled
  20907. * @param options defines the options to configure the compilation
  20908. */
  20909. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20910. clipPlane: boolean;
  20911. }>): void;
  20912. /**
  20913. * Force shader compilation
  20914. * @param mesh defines the mesh that will use this material
  20915. * @param options defines additional options for compiling the shaders
  20916. * @returns a promise that resolves when the compilation completes
  20917. */
  20918. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20919. clipPlane: boolean;
  20920. }>): Promise<void>;
  20921. private static readonly _AllDirtyCallBack;
  20922. private static readonly _ImageProcessingDirtyCallBack;
  20923. private static readonly _TextureDirtyCallBack;
  20924. private static readonly _FresnelDirtyCallBack;
  20925. private static readonly _MiscDirtyCallBack;
  20926. private static readonly _LightsDirtyCallBack;
  20927. private static readonly _AttributeDirtyCallBack;
  20928. private static _FresnelAndMiscDirtyCallBack;
  20929. private static _TextureAndMiscDirtyCallBack;
  20930. private static readonly _DirtyCallbackArray;
  20931. private static readonly _RunDirtyCallBacks;
  20932. /**
  20933. * Marks a define in the material to indicate that it needs to be re-computed
  20934. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20935. */
  20936. markAsDirty(flag: number): void;
  20937. /**
  20938. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20939. * @param func defines a function which checks material defines against the submeshes
  20940. */
  20941. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20942. /**
  20943. * Indicates that we need to re-calculated for all submeshes
  20944. */
  20945. protected _markAllSubMeshesAsAllDirty(): void;
  20946. /**
  20947. * Indicates that image processing needs to be re-calculated for all submeshes
  20948. */
  20949. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20950. /**
  20951. * Indicates that textures need to be re-calculated for all submeshes
  20952. */
  20953. protected _markAllSubMeshesAsTexturesDirty(): void;
  20954. /**
  20955. * Indicates that fresnel needs to be re-calculated for all submeshes
  20956. */
  20957. protected _markAllSubMeshesAsFresnelDirty(): void;
  20958. /**
  20959. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20960. */
  20961. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20962. /**
  20963. * Indicates that lights need to be re-calculated for all submeshes
  20964. */
  20965. protected _markAllSubMeshesAsLightsDirty(): void;
  20966. /**
  20967. * Indicates that attributes need to be re-calculated for all submeshes
  20968. */
  20969. protected _markAllSubMeshesAsAttributesDirty(): void;
  20970. /**
  20971. * Indicates that misc needs to be re-calculated for all submeshes
  20972. */
  20973. protected _markAllSubMeshesAsMiscDirty(): void;
  20974. /**
  20975. * Indicates that textures and misc need to be re-calculated for all submeshes
  20976. */
  20977. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20978. /**
  20979. * Disposes the material
  20980. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20981. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20982. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20983. */
  20984. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20985. /** @hidden */
  20986. private releaseVertexArrayObject;
  20987. /**
  20988. * Serializes this material
  20989. * @returns the serialized material object
  20990. */
  20991. serialize(): any;
  20992. /**
  20993. * Creates a material from parsed material data
  20994. * @param parsedMaterial defines parsed material data
  20995. * @param scene defines the hosting scene
  20996. * @param rootUrl defines the root URL to use to load textures
  20997. * @returns a new material
  20998. */
  20999. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21000. }
  21001. }
  21002. declare module "babylonjs/Materials/multiMaterial" {
  21003. import { Nullable } from "babylonjs/types";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21006. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21007. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21008. import { Material } from "babylonjs/Materials/material";
  21009. /**
  21010. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21011. * separate meshes. This can be use to improve performances.
  21012. * @see http://doc.babylonjs.com/how_to/multi_materials
  21013. */
  21014. export class MultiMaterial extends Material {
  21015. private _subMaterials;
  21016. /**
  21017. * Gets or Sets the list of Materials used within the multi material.
  21018. * They need to be ordered according to the submeshes order in the associated mesh
  21019. */
  21020. subMaterials: Nullable<Material>[];
  21021. /**
  21022. * Function used to align with Node.getChildren()
  21023. * @returns the list of Materials used within the multi material
  21024. */
  21025. getChildren(): Nullable<Material>[];
  21026. /**
  21027. * Instantiates a new Multi Material
  21028. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21029. * separate meshes. This can be use to improve performances.
  21030. * @see http://doc.babylonjs.com/how_to/multi_materials
  21031. * @param name Define the name in the scene
  21032. * @param scene Define the scene the material belongs to
  21033. */
  21034. constructor(name: string, scene: Scene);
  21035. private _hookArray;
  21036. /**
  21037. * Get one of the submaterial by its index in the submaterials array
  21038. * @param index The index to look the sub material at
  21039. * @returns The Material if the index has been defined
  21040. */
  21041. getSubMaterial(index: number): Nullable<Material>;
  21042. /**
  21043. * Get the list of active textures for the whole sub materials list.
  21044. * @returns All the textures that will be used during the rendering
  21045. */
  21046. getActiveTextures(): BaseTexture[];
  21047. /**
  21048. * Gets the current class name of the material e.g. "MultiMaterial"
  21049. * Mainly use in serialization.
  21050. * @returns the class name
  21051. */
  21052. getClassName(): string;
  21053. /**
  21054. * Checks if the material is ready to render the requested sub mesh
  21055. * @param mesh Define the mesh the submesh belongs to
  21056. * @param subMesh Define the sub mesh to look readyness for
  21057. * @param useInstances Define whether or not the material is used with instances
  21058. * @returns true if ready, otherwise false
  21059. */
  21060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21061. /**
  21062. * Clones the current material and its related sub materials
  21063. * @param name Define the name of the newly cloned material
  21064. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21065. * @returns the cloned material
  21066. */
  21067. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21068. /**
  21069. * Serializes the materials into a JSON representation.
  21070. * @returns the JSON representation
  21071. */
  21072. serialize(): any;
  21073. /**
  21074. * Dispose the material and release its associated resources
  21075. * @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)
  21076. * @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)
  21077. * @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)
  21078. */
  21079. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21080. /**
  21081. * Creates a MultiMaterial from parsed MultiMaterial data.
  21082. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21083. * @param scene defines the hosting scene
  21084. * @returns a new MultiMaterial
  21085. */
  21086. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21087. }
  21088. }
  21089. declare module "babylonjs/Meshes/subMesh" {
  21090. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21091. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21092. import { Engine } from "babylonjs/Engines/engine";
  21093. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21094. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21095. import { Effect } from "babylonjs/Materials/effect";
  21096. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21097. import { Plane } from "babylonjs/Maths/math.plane";
  21098. import { Collider } from "babylonjs/Collisions/collider";
  21099. import { Material } from "babylonjs/Materials/material";
  21100. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21101. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21102. import { Mesh } from "babylonjs/Meshes/mesh";
  21103. import { Ray } from "babylonjs/Culling/ray";
  21104. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21105. /**
  21106. * Base class for submeshes
  21107. */
  21108. export class BaseSubMesh {
  21109. /** @hidden */
  21110. _materialDefines: Nullable<MaterialDefines>;
  21111. /** @hidden */
  21112. _materialEffect: Nullable<Effect>;
  21113. /**
  21114. * Gets associated effect
  21115. */
  21116. readonly effect: Nullable<Effect>;
  21117. /**
  21118. * Sets associated effect (effect used to render this submesh)
  21119. * @param effect defines the effect to associate with
  21120. * @param defines defines the set of defines used to compile this effect
  21121. */
  21122. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21123. }
  21124. /**
  21125. * Defines a subdivision inside a mesh
  21126. */
  21127. export class SubMesh extends BaseSubMesh implements ICullable {
  21128. /** the material index to use */
  21129. materialIndex: number;
  21130. /** vertex index start */
  21131. verticesStart: number;
  21132. /** vertices count */
  21133. verticesCount: number;
  21134. /** index start */
  21135. indexStart: number;
  21136. /** indices count */
  21137. indexCount: number;
  21138. /** @hidden */
  21139. _linesIndexCount: number;
  21140. private _mesh;
  21141. private _renderingMesh;
  21142. private _boundingInfo;
  21143. private _linesIndexBuffer;
  21144. /** @hidden */
  21145. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21146. /** @hidden */
  21147. _trianglePlanes: Plane[];
  21148. /** @hidden */
  21149. _lastColliderTransformMatrix: Nullable<Matrix>;
  21150. /** @hidden */
  21151. _renderId: number;
  21152. /** @hidden */
  21153. _alphaIndex: number;
  21154. /** @hidden */
  21155. _distanceToCamera: number;
  21156. /** @hidden */
  21157. _id: number;
  21158. private _currentMaterial;
  21159. /**
  21160. * Add a new submesh to a mesh
  21161. * @param materialIndex defines the material index to use
  21162. * @param verticesStart defines vertex index start
  21163. * @param verticesCount defines vertices count
  21164. * @param indexStart defines index start
  21165. * @param indexCount defines indices count
  21166. * @param mesh defines the parent mesh
  21167. * @param renderingMesh defines an optional rendering mesh
  21168. * @param createBoundingBox defines if bounding box should be created for this submesh
  21169. * @returns the new submesh
  21170. */
  21171. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21172. /**
  21173. * Creates a new submesh
  21174. * @param materialIndex defines the material index to use
  21175. * @param verticesStart defines vertex index start
  21176. * @param verticesCount defines vertices count
  21177. * @param indexStart defines index start
  21178. * @param indexCount defines indices count
  21179. * @param mesh defines the parent mesh
  21180. * @param renderingMesh defines an optional rendering mesh
  21181. * @param createBoundingBox defines if bounding box should be created for this submesh
  21182. */
  21183. constructor(
  21184. /** the material index to use */
  21185. materialIndex: number,
  21186. /** vertex index start */
  21187. verticesStart: number,
  21188. /** vertices count */
  21189. verticesCount: number,
  21190. /** index start */
  21191. indexStart: number,
  21192. /** indices count */
  21193. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21194. /**
  21195. * Returns true if this submesh covers the entire parent mesh
  21196. * @ignorenaming
  21197. */
  21198. readonly IsGlobal: boolean;
  21199. /**
  21200. * Returns the submesh BoudingInfo object
  21201. * @returns current bounding info (or mesh's one if the submesh is global)
  21202. */
  21203. getBoundingInfo(): BoundingInfo;
  21204. /**
  21205. * Sets the submesh BoundingInfo
  21206. * @param boundingInfo defines the new bounding info to use
  21207. * @returns the SubMesh
  21208. */
  21209. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21210. /**
  21211. * Returns the mesh of the current submesh
  21212. * @return the parent mesh
  21213. */
  21214. getMesh(): AbstractMesh;
  21215. /**
  21216. * Returns the rendering mesh of the submesh
  21217. * @returns the rendering mesh (could be different from parent mesh)
  21218. */
  21219. getRenderingMesh(): Mesh;
  21220. /**
  21221. * Returns the submesh material
  21222. * @returns null or the current material
  21223. */
  21224. getMaterial(): Nullable<Material>;
  21225. /**
  21226. * Sets a new updated BoundingInfo object to the submesh
  21227. * @param data defines an optional position array to use to determine the bounding info
  21228. * @returns the SubMesh
  21229. */
  21230. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21231. /** @hidden */
  21232. _checkCollision(collider: Collider): boolean;
  21233. /**
  21234. * Updates the submesh BoundingInfo
  21235. * @param world defines the world matrix to use to update the bounding info
  21236. * @returns the submesh
  21237. */
  21238. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21239. /**
  21240. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21241. * @param frustumPlanes defines the frustum planes
  21242. * @returns true if the submesh is intersecting with the frustum
  21243. */
  21244. isInFrustum(frustumPlanes: Plane[]): boolean;
  21245. /**
  21246. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21247. * @param frustumPlanes defines the frustum planes
  21248. * @returns true if the submesh is inside the frustum
  21249. */
  21250. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21251. /**
  21252. * Renders the submesh
  21253. * @param enableAlphaMode defines if alpha needs to be used
  21254. * @returns the submesh
  21255. */
  21256. render(enableAlphaMode: boolean): SubMesh;
  21257. /**
  21258. * @hidden
  21259. */
  21260. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21261. /**
  21262. * Checks if the submesh intersects with a ray
  21263. * @param ray defines the ray to test
  21264. * @returns true is the passed ray intersects the submesh bounding box
  21265. */
  21266. canIntersects(ray: Ray): boolean;
  21267. /**
  21268. * Intersects current submesh with a ray
  21269. * @param ray defines the ray to test
  21270. * @param positions defines mesh's positions array
  21271. * @param indices defines mesh's indices array
  21272. * @param fastCheck defines if only bounding info should be used
  21273. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21274. * @returns intersection info or null if no intersection
  21275. */
  21276. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21277. /** @hidden */
  21278. private _intersectLines;
  21279. /** @hidden */
  21280. private _intersectUnIndexedLines;
  21281. /** @hidden */
  21282. private _intersectTriangles;
  21283. /** @hidden */
  21284. private _intersectUnIndexedTriangles;
  21285. /** @hidden */
  21286. _rebuild(): void;
  21287. /**
  21288. * Creates a new submesh from the passed mesh
  21289. * @param newMesh defines the new hosting mesh
  21290. * @param newRenderingMesh defines an optional rendering mesh
  21291. * @returns the new submesh
  21292. */
  21293. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21294. /**
  21295. * Release associated resources
  21296. */
  21297. dispose(): void;
  21298. /**
  21299. * Gets the class name
  21300. * @returns the string "SubMesh".
  21301. */
  21302. getClassName(): string;
  21303. /**
  21304. * Creates a new submesh from indices data
  21305. * @param materialIndex the index of the main mesh material
  21306. * @param startIndex the index where to start the copy in the mesh indices array
  21307. * @param indexCount the number of indices to copy then from the startIndex
  21308. * @param mesh the main mesh to create the submesh from
  21309. * @param renderingMesh the optional rendering mesh
  21310. * @returns a new submesh
  21311. */
  21312. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21313. }
  21314. }
  21315. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21316. /**
  21317. * Class used to represent data loading progression
  21318. */
  21319. export class SceneLoaderFlags {
  21320. private static _ForceFullSceneLoadingForIncremental;
  21321. private static _ShowLoadingScreen;
  21322. private static _CleanBoneMatrixWeights;
  21323. private static _loggingLevel;
  21324. /**
  21325. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21326. */
  21327. static ForceFullSceneLoadingForIncremental: boolean;
  21328. /**
  21329. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21330. */
  21331. static ShowLoadingScreen: boolean;
  21332. /**
  21333. * Defines the current logging level (while loading the scene)
  21334. * @ignorenaming
  21335. */
  21336. static loggingLevel: number;
  21337. /**
  21338. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21339. */
  21340. static CleanBoneMatrixWeights: boolean;
  21341. }
  21342. }
  21343. declare module "babylonjs/Meshes/geometry" {
  21344. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21345. import { Scene } from "babylonjs/scene";
  21346. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21347. import { Engine } from "babylonjs/Engines/engine";
  21348. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21349. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21350. import { Effect } from "babylonjs/Materials/effect";
  21351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21352. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21353. import { Mesh } from "babylonjs/Meshes/mesh";
  21354. /**
  21355. * Class used to store geometry data (vertex buffers + index buffer)
  21356. */
  21357. export class Geometry implements IGetSetVerticesData {
  21358. /**
  21359. * Gets or sets the ID of the geometry
  21360. */
  21361. id: string;
  21362. /**
  21363. * Gets or sets the unique ID of the geometry
  21364. */
  21365. uniqueId: number;
  21366. /**
  21367. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21368. */
  21369. delayLoadState: number;
  21370. /**
  21371. * Gets the file containing the data to load when running in delay load state
  21372. */
  21373. delayLoadingFile: Nullable<string>;
  21374. /**
  21375. * Callback called when the geometry is updated
  21376. */
  21377. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21378. private _scene;
  21379. private _engine;
  21380. private _meshes;
  21381. private _totalVertices;
  21382. /** @hidden */
  21383. _indices: IndicesArray;
  21384. /** @hidden */
  21385. _vertexBuffers: {
  21386. [key: string]: VertexBuffer;
  21387. };
  21388. private _isDisposed;
  21389. private _extend;
  21390. private _boundingBias;
  21391. /** @hidden */
  21392. _delayInfo: Array<string>;
  21393. private _indexBuffer;
  21394. private _indexBufferIsUpdatable;
  21395. /** @hidden */
  21396. _boundingInfo: Nullable<BoundingInfo>;
  21397. /** @hidden */
  21398. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21399. /** @hidden */
  21400. _softwareSkinningFrameId: number;
  21401. private _vertexArrayObjects;
  21402. private _updatable;
  21403. /** @hidden */
  21404. _positions: Nullable<Vector3[]>;
  21405. /**
  21406. * 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
  21407. */
  21408. /**
  21409. * 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
  21410. */
  21411. boundingBias: Vector2;
  21412. /**
  21413. * Static function used to attach a new empty geometry to a mesh
  21414. * @param mesh defines the mesh to attach the geometry to
  21415. * @returns the new Geometry
  21416. */
  21417. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21418. /**
  21419. * Creates a new geometry
  21420. * @param id defines the unique ID
  21421. * @param scene defines the hosting scene
  21422. * @param vertexData defines the VertexData used to get geometry data
  21423. * @param updatable defines if geometry must be updatable (false by default)
  21424. * @param mesh defines the mesh that will be associated with the geometry
  21425. */
  21426. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21427. /**
  21428. * Gets the current extend of the geometry
  21429. */
  21430. readonly extend: {
  21431. minimum: Vector3;
  21432. maximum: Vector3;
  21433. };
  21434. /**
  21435. * Gets the hosting scene
  21436. * @returns the hosting Scene
  21437. */
  21438. getScene(): Scene;
  21439. /**
  21440. * Gets the hosting engine
  21441. * @returns the hosting Engine
  21442. */
  21443. getEngine(): Engine;
  21444. /**
  21445. * Defines if the geometry is ready to use
  21446. * @returns true if the geometry is ready to be used
  21447. */
  21448. isReady(): boolean;
  21449. /**
  21450. * Gets a value indicating that the geometry should not be serialized
  21451. */
  21452. readonly doNotSerialize: boolean;
  21453. /** @hidden */
  21454. _rebuild(): void;
  21455. /**
  21456. * Affects all geometry data in one call
  21457. * @param vertexData defines the geometry data
  21458. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21459. */
  21460. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21461. /**
  21462. * Set specific vertex data
  21463. * @param kind defines the data kind (Position, normal, etc...)
  21464. * @param data defines the vertex data to use
  21465. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21466. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21467. */
  21468. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21469. /**
  21470. * Removes a specific vertex data
  21471. * @param kind defines the data kind (Position, normal, etc...)
  21472. */
  21473. removeVerticesData(kind: string): void;
  21474. /**
  21475. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21476. * @param buffer defines the vertex buffer to use
  21477. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21478. */
  21479. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21480. /**
  21481. * Update a specific vertex buffer
  21482. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21483. * It will do nothing if the buffer is not updatable
  21484. * @param kind defines the data kind (Position, normal, etc...)
  21485. * @param data defines the data to use
  21486. * @param offset defines the offset in the target buffer where to store the data
  21487. * @param useBytes set to true if the offset is in bytes
  21488. */
  21489. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21490. /**
  21491. * Update a specific vertex buffer
  21492. * This function will create a new buffer if the current one is not updatable
  21493. * @param kind defines the data kind (Position, normal, etc...)
  21494. * @param data defines the data to use
  21495. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21496. */
  21497. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21498. private _updateBoundingInfo;
  21499. /** @hidden */
  21500. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21501. /**
  21502. * Gets total number of vertices
  21503. * @returns the total number of vertices
  21504. */
  21505. getTotalVertices(): number;
  21506. /**
  21507. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21508. * @param kind defines the data kind (Position, normal, etc...)
  21509. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21510. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21511. * @returns a float array containing vertex data
  21512. */
  21513. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21514. /**
  21515. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21516. * @param kind defines the data kind (Position, normal, etc...)
  21517. * @returns true if the vertex buffer with the specified kind is updatable
  21518. */
  21519. isVertexBufferUpdatable(kind: string): boolean;
  21520. /**
  21521. * Gets a specific vertex buffer
  21522. * @param kind defines the data kind (Position, normal, etc...)
  21523. * @returns a VertexBuffer
  21524. */
  21525. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21526. /**
  21527. * Returns all vertex buffers
  21528. * @return an object holding all vertex buffers indexed by kind
  21529. */
  21530. getVertexBuffers(): Nullable<{
  21531. [key: string]: VertexBuffer;
  21532. }>;
  21533. /**
  21534. * Gets a boolean indicating if specific vertex buffer is present
  21535. * @param kind defines the data kind (Position, normal, etc...)
  21536. * @returns true if data is present
  21537. */
  21538. isVerticesDataPresent(kind: string): boolean;
  21539. /**
  21540. * Gets a list of all attached data kinds (Position, normal, etc...)
  21541. * @returns a list of string containing all kinds
  21542. */
  21543. getVerticesDataKinds(): string[];
  21544. /**
  21545. * Update index buffer
  21546. * @param indices defines the indices to store in the index buffer
  21547. * @param offset defines the offset in the target buffer where to store the data
  21548. * @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)
  21549. */
  21550. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21551. /**
  21552. * Creates a new index buffer
  21553. * @param indices defines the indices to store in the index buffer
  21554. * @param totalVertices defines the total number of vertices (could be null)
  21555. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21556. */
  21557. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21558. /**
  21559. * Return the total number of indices
  21560. * @returns the total number of indices
  21561. */
  21562. getTotalIndices(): number;
  21563. /**
  21564. * Gets the index buffer array
  21565. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21566. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21567. * @returns the index buffer array
  21568. */
  21569. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21570. /**
  21571. * Gets the index buffer
  21572. * @return the index buffer
  21573. */
  21574. getIndexBuffer(): Nullable<DataBuffer>;
  21575. /** @hidden */
  21576. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21577. /**
  21578. * Release the associated resources for a specific mesh
  21579. * @param mesh defines the source mesh
  21580. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21581. */
  21582. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21583. /**
  21584. * Apply current geometry to a given mesh
  21585. * @param mesh defines the mesh to apply geometry to
  21586. */
  21587. applyToMesh(mesh: Mesh): void;
  21588. private _updateExtend;
  21589. private _applyToMesh;
  21590. private notifyUpdate;
  21591. /**
  21592. * Load the geometry if it was flagged as delay loaded
  21593. * @param scene defines the hosting scene
  21594. * @param onLoaded defines a callback called when the geometry is loaded
  21595. */
  21596. load(scene: Scene, onLoaded?: () => void): void;
  21597. private _queueLoad;
  21598. /**
  21599. * Invert the geometry to move from a right handed system to a left handed one.
  21600. */
  21601. toLeftHanded(): void;
  21602. /** @hidden */
  21603. _resetPointsArrayCache(): void;
  21604. /** @hidden */
  21605. _generatePointsArray(): boolean;
  21606. /**
  21607. * Gets a value indicating if the geometry is disposed
  21608. * @returns true if the geometry was disposed
  21609. */
  21610. isDisposed(): boolean;
  21611. private _disposeVertexArrayObjects;
  21612. /**
  21613. * Free all associated resources
  21614. */
  21615. dispose(): void;
  21616. /**
  21617. * Clone the current geometry into a new geometry
  21618. * @param id defines the unique ID of the new geometry
  21619. * @returns a new geometry object
  21620. */
  21621. copy(id: string): Geometry;
  21622. /**
  21623. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21624. * @return a JSON representation of the current geometry data (without the vertices data)
  21625. */
  21626. serialize(): any;
  21627. private toNumberArray;
  21628. /**
  21629. * Serialize all vertices data into a JSON oject
  21630. * @returns a JSON representation of the current geometry data
  21631. */
  21632. serializeVerticeData(): any;
  21633. /**
  21634. * Extracts a clone of a mesh geometry
  21635. * @param mesh defines the source mesh
  21636. * @param id defines the unique ID of the new geometry object
  21637. * @returns the new geometry object
  21638. */
  21639. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21640. /**
  21641. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21642. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21643. * Be aware Math.random() could cause collisions, but:
  21644. * "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"
  21645. * @returns a string containing a new GUID
  21646. */
  21647. static RandomId(): string;
  21648. /** @hidden */
  21649. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21650. private static _CleanMatricesWeights;
  21651. /**
  21652. * Create a new geometry from persisted data (Using .babylon file format)
  21653. * @param parsedVertexData defines the persisted data
  21654. * @param scene defines the hosting scene
  21655. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21656. * @returns the new geometry object
  21657. */
  21658. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21659. }
  21660. }
  21661. declare module "babylonjs/Meshes/mesh.vertexData" {
  21662. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21663. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21664. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21665. import { Geometry } from "babylonjs/Meshes/geometry";
  21666. import { Mesh } from "babylonjs/Meshes/mesh";
  21667. /**
  21668. * Define an interface for all classes that will get and set the data on vertices
  21669. */
  21670. export interface IGetSetVerticesData {
  21671. /**
  21672. * Gets a boolean indicating if specific vertex data is present
  21673. * @param kind defines the vertex data kind to use
  21674. * @returns true is data kind is present
  21675. */
  21676. isVerticesDataPresent(kind: string): boolean;
  21677. /**
  21678. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21679. * @param kind defines the data kind (Position, normal, etc...)
  21680. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21681. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21682. * @returns a float array containing vertex data
  21683. */
  21684. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21685. /**
  21686. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21687. * @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.
  21688. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21689. * @returns the indices array or an empty array if the mesh has no geometry
  21690. */
  21691. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21692. /**
  21693. * Set specific vertex data
  21694. * @param kind defines the data kind (Position, normal, etc...)
  21695. * @param data defines the vertex data to use
  21696. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21697. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21698. */
  21699. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21700. /**
  21701. * Update a specific associated vertex buffer
  21702. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21703. * - VertexBuffer.PositionKind
  21704. * - VertexBuffer.UVKind
  21705. * - VertexBuffer.UV2Kind
  21706. * - VertexBuffer.UV3Kind
  21707. * - VertexBuffer.UV4Kind
  21708. * - VertexBuffer.UV5Kind
  21709. * - VertexBuffer.UV6Kind
  21710. * - VertexBuffer.ColorKind
  21711. * - VertexBuffer.MatricesIndicesKind
  21712. * - VertexBuffer.MatricesIndicesExtraKind
  21713. * - VertexBuffer.MatricesWeightsKind
  21714. * - VertexBuffer.MatricesWeightsExtraKind
  21715. * @param data defines the data source
  21716. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21717. * @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)
  21718. */
  21719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21720. /**
  21721. * Creates a new index buffer
  21722. * @param indices defines the indices to store in the index buffer
  21723. * @param totalVertices defines the total number of vertices (could be null)
  21724. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21725. */
  21726. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21727. }
  21728. /**
  21729. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21730. */
  21731. export class VertexData {
  21732. /**
  21733. * Mesh side orientation : usually the external or front surface
  21734. */
  21735. static readonly FRONTSIDE: number;
  21736. /**
  21737. * Mesh side orientation : usually the internal or back surface
  21738. */
  21739. static readonly BACKSIDE: number;
  21740. /**
  21741. * Mesh side orientation : both internal and external or front and back surfaces
  21742. */
  21743. static readonly DOUBLESIDE: number;
  21744. /**
  21745. * Mesh side orientation : by default, `FRONTSIDE`
  21746. */
  21747. static readonly DEFAULTSIDE: number;
  21748. /**
  21749. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21750. */
  21751. positions: Nullable<FloatArray>;
  21752. /**
  21753. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21754. */
  21755. normals: Nullable<FloatArray>;
  21756. /**
  21757. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21758. */
  21759. tangents: Nullable<FloatArray>;
  21760. /**
  21761. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21762. */
  21763. uvs: Nullable<FloatArray>;
  21764. /**
  21765. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21766. */
  21767. uvs2: Nullable<FloatArray>;
  21768. /**
  21769. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21770. */
  21771. uvs3: Nullable<FloatArray>;
  21772. /**
  21773. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21774. */
  21775. uvs4: Nullable<FloatArray>;
  21776. /**
  21777. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21778. */
  21779. uvs5: Nullable<FloatArray>;
  21780. /**
  21781. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21782. */
  21783. uvs6: Nullable<FloatArray>;
  21784. /**
  21785. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21786. */
  21787. colors: Nullable<FloatArray>;
  21788. /**
  21789. * 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).
  21790. */
  21791. matricesIndices: Nullable<FloatArray>;
  21792. /**
  21793. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21794. */
  21795. matricesWeights: Nullable<FloatArray>;
  21796. /**
  21797. * An array extending the number of possible indices
  21798. */
  21799. matricesIndicesExtra: Nullable<FloatArray>;
  21800. /**
  21801. * An array extending the number of possible weights when the number of indices is extended
  21802. */
  21803. matricesWeightsExtra: Nullable<FloatArray>;
  21804. /**
  21805. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21806. */
  21807. indices: Nullable<IndicesArray>;
  21808. /**
  21809. * Uses the passed data array to set the set the values for the specified kind of data
  21810. * @param data a linear array of floating numbers
  21811. * @param kind the type of data that is being set, eg positions, colors etc
  21812. */
  21813. set(data: FloatArray, kind: string): void;
  21814. /**
  21815. * Associates the vertexData to the passed Mesh.
  21816. * Sets it as updatable or not (default `false`)
  21817. * @param mesh the mesh the vertexData is applied to
  21818. * @param updatable when used and having the value true allows new data to update the vertexData
  21819. * @returns the VertexData
  21820. */
  21821. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21822. /**
  21823. * Associates the vertexData to the passed Geometry.
  21824. * Sets it as updatable or not (default `false`)
  21825. * @param geometry the geometry the vertexData is applied to
  21826. * @param updatable when used and having the value true allows new data to update the vertexData
  21827. * @returns VertexData
  21828. */
  21829. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21830. /**
  21831. * Updates the associated mesh
  21832. * @param mesh the mesh to be updated
  21833. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21834. * @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
  21835. * @returns VertexData
  21836. */
  21837. updateMesh(mesh: Mesh): VertexData;
  21838. /**
  21839. * Updates the associated geometry
  21840. * @param geometry the geometry to be updated
  21841. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21842. * @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
  21843. * @returns VertexData.
  21844. */
  21845. updateGeometry(geometry: Geometry): VertexData;
  21846. private _applyTo;
  21847. private _update;
  21848. /**
  21849. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21850. * @param matrix the transforming matrix
  21851. * @returns the VertexData
  21852. */
  21853. transform(matrix: Matrix): VertexData;
  21854. /**
  21855. * Merges the passed VertexData into the current one
  21856. * @param other the VertexData to be merged into the current one
  21857. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21858. * @returns the modified VertexData
  21859. */
  21860. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21861. private _mergeElement;
  21862. private _validate;
  21863. /**
  21864. * Serializes the VertexData
  21865. * @returns a serialized object
  21866. */
  21867. serialize(): any;
  21868. /**
  21869. * Extracts the vertexData from a mesh
  21870. * @param mesh the mesh from which to extract the VertexData
  21871. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21872. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21873. * @returns the object VertexData associated to the passed mesh
  21874. */
  21875. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21876. /**
  21877. * Extracts the vertexData from the geometry
  21878. * @param geometry the geometry from which to extract the VertexData
  21879. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21880. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21881. * @returns the object VertexData associated to the passed mesh
  21882. */
  21883. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21884. private static _ExtractFrom;
  21885. /**
  21886. * Creates the VertexData for a Ribbon
  21887. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21888. * * pathArray array of paths, each of which an array of successive Vector3
  21889. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21890. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21891. * * 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
  21892. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21893. * * 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)
  21894. * * 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)
  21895. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21896. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21897. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21898. * @returns the VertexData of the ribbon
  21899. */
  21900. static CreateRibbon(options: {
  21901. pathArray: Vector3[][];
  21902. closeArray?: boolean;
  21903. closePath?: boolean;
  21904. offset?: number;
  21905. sideOrientation?: number;
  21906. frontUVs?: Vector4;
  21907. backUVs?: Vector4;
  21908. invertUV?: boolean;
  21909. uvs?: Vector2[];
  21910. colors?: Color4[];
  21911. }): VertexData;
  21912. /**
  21913. * Creates the VertexData for a box
  21914. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21915. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21916. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21917. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21918. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21919. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21920. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21921. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21922. * * 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)
  21923. * * 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)
  21924. * @returns the VertexData of the box
  21925. */
  21926. static CreateBox(options: {
  21927. size?: number;
  21928. width?: number;
  21929. height?: number;
  21930. depth?: number;
  21931. faceUV?: Vector4[];
  21932. faceColors?: Color4[];
  21933. sideOrientation?: number;
  21934. frontUVs?: Vector4;
  21935. backUVs?: Vector4;
  21936. }): VertexData;
  21937. /**
  21938. * Creates the VertexData for a tiled box
  21939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21940. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21941. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21942. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21944. * @returns the VertexData of the box
  21945. */
  21946. static CreateTiledBox(options: {
  21947. pattern?: number;
  21948. width?: number;
  21949. height?: number;
  21950. depth?: number;
  21951. tileSize?: number;
  21952. tileWidth?: number;
  21953. tileHeight?: number;
  21954. alignHorizontal?: number;
  21955. alignVertical?: number;
  21956. faceUV?: Vector4[];
  21957. faceColors?: Color4[];
  21958. sideOrientation?: number;
  21959. }): VertexData;
  21960. /**
  21961. * Creates the VertexData for a tiled plane
  21962. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21963. * * pattern a limited pattern arrangement depending on the number
  21964. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21965. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21966. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21967. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21968. * * 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)
  21969. * * 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)
  21970. * @returns the VertexData of the tiled plane
  21971. */
  21972. static CreateTiledPlane(options: {
  21973. pattern?: number;
  21974. tileSize?: number;
  21975. tileWidth?: number;
  21976. tileHeight?: number;
  21977. size?: number;
  21978. width?: number;
  21979. height?: number;
  21980. alignHorizontal?: number;
  21981. alignVertical?: number;
  21982. sideOrientation?: number;
  21983. frontUVs?: Vector4;
  21984. backUVs?: Vector4;
  21985. }): VertexData;
  21986. /**
  21987. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21989. * * segments sets the number of horizontal strips optional, default 32
  21990. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21991. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21992. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21993. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21994. * * 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
  21995. * * 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
  21996. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21997. * * 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)
  21998. * * 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)
  21999. * @returns the VertexData of the ellipsoid
  22000. */
  22001. static CreateSphere(options: {
  22002. segments?: number;
  22003. diameter?: number;
  22004. diameterX?: number;
  22005. diameterY?: number;
  22006. diameterZ?: number;
  22007. arc?: number;
  22008. slice?: number;
  22009. sideOrientation?: number;
  22010. frontUVs?: Vector4;
  22011. backUVs?: Vector4;
  22012. }): VertexData;
  22013. /**
  22014. * Creates the VertexData for a cylinder, cone or prism
  22015. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22016. * * height sets the height (y direction) of the cylinder, optional, default 2
  22017. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22018. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22019. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22020. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22021. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22022. * * 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
  22023. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22024. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22025. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22026. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22027. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22028. * * 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)
  22029. * * 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)
  22030. * @returns the VertexData of the cylinder, cone or prism
  22031. */
  22032. static CreateCylinder(options: {
  22033. height?: number;
  22034. diameterTop?: number;
  22035. diameterBottom?: number;
  22036. diameter?: number;
  22037. tessellation?: number;
  22038. subdivisions?: number;
  22039. arc?: number;
  22040. faceColors?: Color4[];
  22041. faceUV?: Vector4[];
  22042. hasRings?: boolean;
  22043. enclose?: boolean;
  22044. sideOrientation?: number;
  22045. frontUVs?: Vector4;
  22046. backUVs?: Vector4;
  22047. }): VertexData;
  22048. /**
  22049. * Creates the VertexData for a torus
  22050. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22051. * * diameter the diameter of the torus, optional default 1
  22052. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22053. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22054. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22055. * * 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)
  22056. * * 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)
  22057. * @returns the VertexData of the torus
  22058. */
  22059. static CreateTorus(options: {
  22060. diameter?: number;
  22061. thickness?: number;
  22062. tessellation?: number;
  22063. sideOrientation?: number;
  22064. frontUVs?: Vector4;
  22065. backUVs?: Vector4;
  22066. }): VertexData;
  22067. /**
  22068. * Creates the VertexData of the LineSystem
  22069. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22070. * - lines an array of lines, each line being an array of successive Vector3
  22071. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22072. * @returns the VertexData of the LineSystem
  22073. */
  22074. static CreateLineSystem(options: {
  22075. lines: Vector3[][];
  22076. colors?: Nullable<Color4[][]>;
  22077. }): VertexData;
  22078. /**
  22079. * Create the VertexData for a DashedLines
  22080. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22081. * - points an array successive Vector3
  22082. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22083. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22084. * - dashNb the intended total number of dashes, optional, default 200
  22085. * @returns the VertexData for the DashedLines
  22086. */
  22087. static CreateDashedLines(options: {
  22088. points: Vector3[];
  22089. dashSize?: number;
  22090. gapSize?: number;
  22091. dashNb?: number;
  22092. }): VertexData;
  22093. /**
  22094. * Creates the VertexData for a Ground
  22095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22096. * - width the width (x direction) of the ground, optional, default 1
  22097. * - height the height (z direction) of the ground, optional, default 1
  22098. * - subdivisions the number of subdivisions per side, optional, default 1
  22099. * @returns the VertexData of the Ground
  22100. */
  22101. static CreateGround(options: {
  22102. width?: number;
  22103. height?: number;
  22104. subdivisions?: number;
  22105. subdivisionsX?: number;
  22106. subdivisionsY?: number;
  22107. }): VertexData;
  22108. /**
  22109. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22110. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22111. * * xmin the ground minimum X coordinate, optional, default -1
  22112. * * zmin the ground minimum Z coordinate, optional, default -1
  22113. * * xmax the ground maximum X coordinate, optional, default 1
  22114. * * zmax the ground maximum Z coordinate, optional, default 1
  22115. * * 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}
  22116. * * 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}
  22117. * @returns the VertexData of the TiledGround
  22118. */
  22119. static CreateTiledGround(options: {
  22120. xmin: number;
  22121. zmin: number;
  22122. xmax: number;
  22123. zmax: number;
  22124. subdivisions?: {
  22125. w: number;
  22126. h: number;
  22127. };
  22128. precision?: {
  22129. w: number;
  22130. h: number;
  22131. };
  22132. }): VertexData;
  22133. /**
  22134. * Creates the VertexData of the Ground designed from a heightmap
  22135. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22136. * * width the width (x direction) of the ground
  22137. * * height the height (z direction) of the ground
  22138. * * subdivisions the number of subdivisions per side
  22139. * * minHeight the minimum altitude on the ground, optional, default 0
  22140. * * maxHeight the maximum altitude on the ground, optional default 1
  22141. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22142. * * buffer the array holding the image color data
  22143. * * bufferWidth the width of image
  22144. * * bufferHeight the height of image
  22145. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22146. * @returns the VertexData of the Ground designed from a heightmap
  22147. */
  22148. static CreateGroundFromHeightMap(options: {
  22149. width: number;
  22150. height: number;
  22151. subdivisions: number;
  22152. minHeight: number;
  22153. maxHeight: number;
  22154. colorFilter: Color3;
  22155. buffer: Uint8Array;
  22156. bufferWidth: number;
  22157. bufferHeight: number;
  22158. alphaFilter: number;
  22159. }): VertexData;
  22160. /**
  22161. * Creates the VertexData for a Plane
  22162. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22163. * * size sets the width and height of the plane to the value of size, optional default 1
  22164. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22165. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22166. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22167. * * 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)
  22168. * * 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)
  22169. * @returns the VertexData of the box
  22170. */
  22171. static CreatePlane(options: {
  22172. size?: number;
  22173. width?: number;
  22174. height?: number;
  22175. sideOrientation?: number;
  22176. frontUVs?: Vector4;
  22177. backUVs?: Vector4;
  22178. }): VertexData;
  22179. /**
  22180. * Creates the VertexData of the Disc or regular Polygon
  22181. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22182. * * radius the radius of the disc, optional default 0.5
  22183. * * tessellation the number of polygon sides, optional, default 64
  22184. * * 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
  22185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22186. * * 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)
  22187. * * 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)
  22188. * @returns the VertexData of the box
  22189. */
  22190. static CreateDisc(options: {
  22191. radius?: number;
  22192. tessellation?: number;
  22193. arc?: number;
  22194. sideOrientation?: number;
  22195. frontUVs?: Vector4;
  22196. backUVs?: Vector4;
  22197. }): VertexData;
  22198. /**
  22199. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22200. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22201. * @param polygon a mesh built from polygonTriangulation.build()
  22202. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22203. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22204. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22205. * @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)
  22206. * @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)
  22207. * @returns the VertexData of the Polygon
  22208. */
  22209. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22210. /**
  22211. * Creates the VertexData of the IcoSphere
  22212. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22213. * * radius the radius of the IcoSphere, optional default 1
  22214. * * radiusX allows stretching in the x direction, optional, default radius
  22215. * * radiusY allows stretching in the y direction, optional, default radius
  22216. * * radiusZ allows stretching in the z direction, optional, default radius
  22217. * * flat when true creates a flat shaded mesh, optional, default true
  22218. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22219. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22220. * * 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)
  22221. * * 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)
  22222. * @returns the VertexData of the IcoSphere
  22223. */
  22224. static CreateIcoSphere(options: {
  22225. radius?: number;
  22226. radiusX?: number;
  22227. radiusY?: number;
  22228. radiusZ?: number;
  22229. flat?: boolean;
  22230. subdivisions?: number;
  22231. sideOrientation?: number;
  22232. frontUVs?: Vector4;
  22233. backUVs?: Vector4;
  22234. }): VertexData;
  22235. /**
  22236. * Creates the VertexData for a Polyhedron
  22237. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22238. * * type provided types are:
  22239. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22240. * * 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)
  22241. * * size the size of the IcoSphere, optional default 1
  22242. * * sizeX allows stretching in the x direction, optional, default size
  22243. * * sizeY allows stretching in the y direction, optional, default size
  22244. * * sizeZ allows stretching in the z direction, optional, default size
  22245. * * 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
  22246. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22247. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22248. * * flat when true creates a flat shaded mesh, optional, default true
  22249. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22250. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22251. * * 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)
  22252. * * 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)
  22253. * @returns the VertexData of the Polyhedron
  22254. */
  22255. static CreatePolyhedron(options: {
  22256. type?: number;
  22257. size?: number;
  22258. sizeX?: number;
  22259. sizeY?: number;
  22260. sizeZ?: number;
  22261. custom?: any;
  22262. faceUV?: Vector4[];
  22263. faceColors?: Color4[];
  22264. flat?: boolean;
  22265. sideOrientation?: number;
  22266. frontUVs?: Vector4;
  22267. backUVs?: Vector4;
  22268. }): VertexData;
  22269. /**
  22270. * Creates the VertexData for a TorusKnot
  22271. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22272. * * radius the radius of the torus knot, optional, default 2
  22273. * * tube the thickness of the tube, optional, default 0.5
  22274. * * radialSegments the number of sides on each tube segments, optional, default 32
  22275. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22276. * * p the number of windings around the z axis, optional, default 2
  22277. * * q the number of windings around the x axis, optional, default 3
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * @returns the VertexData of the Torus Knot
  22282. */
  22283. static CreateTorusKnot(options: {
  22284. radius?: number;
  22285. tube?: number;
  22286. radialSegments?: number;
  22287. tubularSegments?: number;
  22288. p?: number;
  22289. q?: number;
  22290. sideOrientation?: number;
  22291. frontUVs?: Vector4;
  22292. backUVs?: Vector4;
  22293. }): VertexData;
  22294. /**
  22295. * Compute normals for given positions and indices
  22296. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22297. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22298. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22299. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22300. * * facetNormals : optional array of facet normals (vector3)
  22301. * * facetPositions : optional array of facet positions (vector3)
  22302. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22303. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22304. * * bInfo : optional bounding info, required for facetPartitioning computation
  22305. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22306. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22307. * * useRightHandedSystem: optional boolean to for right handed system computation
  22308. * * depthSort : optional boolean to enable the facet depth sort computation
  22309. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22310. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22311. */
  22312. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22313. facetNormals?: any;
  22314. facetPositions?: any;
  22315. facetPartitioning?: any;
  22316. ratio?: number;
  22317. bInfo?: any;
  22318. bbSize?: Vector3;
  22319. subDiv?: any;
  22320. useRightHandedSystem?: boolean;
  22321. depthSort?: boolean;
  22322. distanceTo?: Vector3;
  22323. depthSortedFacets?: any;
  22324. }): void;
  22325. /** @hidden */
  22326. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22327. /**
  22328. * Applies VertexData created from the imported parameters to the geometry
  22329. * @param parsedVertexData the parsed data from an imported file
  22330. * @param geometry the geometry to apply the VertexData to
  22331. */
  22332. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22333. }
  22334. }
  22335. declare module "babylonjs/Morph/morphTarget" {
  22336. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22337. import { Observable } from "babylonjs/Misc/observable";
  22338. import { Nullable, FloatArray } from "babylonjs/types";
  22339. import { Scene } from "babylonjs/scene";
  22340. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22341. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22342. /**
  22343. * Defines a target to use with MorphTargetManager
  22344. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22345. */
  22346. export class MorphTarget implements IAnimatable {
  22347. /** defines the name of the target */
  22348. name: string;
  22349. /**
  22350. * Gets or sets the list of animations
  22351. */
  22352. animations: import("babylonjs/Animations/animation").Animation[];
  22353. private _scene;
  22354. private _positions;
  22355. private _normals;
  22356. private _tangents;
  22357. private _uvs;
  22358. private _influence;
  22359. /**
  22360. * Observable raised when the influence changes
  22361. */
  22362. onInfluenceChanged: Observable<boolean>;
  22363. /** @hidden */
  22364. _onDataLayoutChanged: Observable<void>;
  22365. /**
  22366. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22367. */
  22368. influence: number;
  22369. /**
  22370. * Gets or sets the id of the morph Target
  22371. */
  22372. id: string;
  22373. private _animationPropertiesOverride;
  22374. /**
  22375. * Gets or sets the animation properties override
  22376. */
  22377. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22378. /**
  22379. * Creates a new MorphTarget
  22380. * @param name defines the name of the target
  22381. * @param influence defines the influence to use
  22382. * @param scene defines the scene the morphtarget belongs to
  22383. */
  22384. constructor(
  22385. /** defines the name of the target */
  22386. name: string, influence?: number, scene?: Nullable<Scene>);
  22387. /**
  22388. * Gets a boolean defining if the target contains position data
  22389. */
  22390. readonly hasPositions: boolean;
  22391. /**
  22392. * Gets a boolean defining if the target contains normal data
  22393. */
  22394. readonly hasNormals: boolean;
  22395. /**
  22396. * Gets a boolean defining if the target contains tangent data
  22397. */
  22398. readonly hasTangents: boolean;
  22399. /**
  22400. * Gets a boolean defining if the target contains texture coordinates data
  22401. */
  22402. readonly hasUVs: boolean;
  22403. /**
  22404. * Affects position data to this target
  22405. * @param data defines the position data to use
  22406. */
  22407. setPositions(data: Nullable<FloatArray>): void;
  22408. /**
  22409. * Gets the position data stored in this target
  22410. * @returns a FloatArray containing the position data (or null if not present)
  22411. */
  22412. getPositions(): Nullable<FloatArray>;
  22413. /**
  22414. * Affects normal data to this target
  22415. * @param data defines the normal data to use
  22416. */
  22417. setNormals(data: Nullable<FloatArray>): void;
  22418. /**
  22419. * Gets the normal data stored in this target
  22420. * @returns a FloatArray containing the normal data (or null if not present)
  22421. */
  22422. getNormals(): Nullable<FloatArray>;
  22423. /**
  22424. * Affects tangent data to this target
  22425. * @param data defines the tangent data to use
  22426. */
  22427. setTangents(data: Nullable<FloatArray>): void;
  22428. /**
  22429. * Gets the tangent data stored in this target
  22430. * @returns a FloatArray containing the tangent data (or null if not present)
  22431. */
  22432. getTangents(): Nullable<FloatArray>;
  22433. /**
  22434. * Affects texture coordinates data to this target
  22435. * @param data defines the texture coordinates data to use
  22436. */
  22437. setUVs(data: Nullable<FloatArray>): void;
  22438. /**
  22439. * Gets the texture coordinates data stored in this target
  22440. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22441. */
  22442. getUVs(): Nullable<FloatArray>;
  22443. /**
  22444. * Serializes the current target into a Serialization object
  22445. * @returns the serialized object
  22446. */
  22447. serialize(): any;
  22448. /**
  22449. * Returns the string "MorphTarget"
  22450. * @returns "MorphTarget"
  22451. */
  22452. getClassName(): string;
  22453. /**
  22454. * Creates a new target from serialized data
  22455. * @param serializationObject defines the serialized data to use
  22456. * @returns a new MorphTarget
  22457. */
  22458. static Parse(serializationObject: any): MorphTarget;
  22459. /**
  22460. * Creates a MorphTarget from mesh data
  22461. * @param mesh defines the source mesh
  22462. * @param name defines the name to use for the new target
  22463. * @param influence defines the influence to attach to the target
  22464. * @returns a new MorphTarget
  22465. */
  22466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22467. }
  22468. }
  22469. declare module "babylonjs/Morph/morphTargetManager" {
  22470. import { Nullable } from "babylonjs/types";
  22471. import { Scene } from "babylonjs/scene";
  22472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22473. /**
  22474. * This class is used to deform meshes using morphing between different targets
  22475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22476. */
  22477. export class MorphTargetManager {
  22478. private _targets;
  22479. private _targetInfluenceChangedObservers;
  22480. private _targetDataLayoutChangedObservers;
  22481. private _activeTargets;
  22482. private _scene;
  22483. private _influences;
  22484. private _supportsNormals;
  22485. private _supportsTangents;
  22486. private _supportsUVs;
  22487. private _vertexCount;
  22488. private _uniqueId;
  22489. private _tempInfluences;
  22490. /**
  22491. * Gets or sets a boolean indicating if normals must be morphed
  22492. */
  22493. enableNormalMorphing: boolean;
  22494. /**
  22495. * Gets or sets a boolean indicating if tangents must be morphed
  22496. */
  22497. enableTangentMorphing: boolean;
  22498. /**
  22499. * Gets or sets a boolean indicating if UV must be morphed
  22500. */
  22501. enableUVMorphing: boolean;
  22502. /**
  22503. * Creates a new MorphTargetManager
  22504. * @param scene defines the current scene
  22505. */
  22506. constructor(scene?: Nullable<Scene>);
  22507. /**
  22508. * Gets the unique ID of this manager
  22509. */
  22510. readonly uniqueId: number;
  22511. /**
  22512. * Gets the number of vertices handled by this manager
  22513. */
  22514. readonly vertexCount: number;
  22515. /**
  22516. * Gets a boolean indicating if this manager supports morphing of normals
  22517. */
  22518. readonly supportsNormals: boolean;
  22519. /**
  22520. * Gets a boolean indicating if this manager supports morphing of tangents
  22521. */
  22522. readonly supportsTangents: boolean;
  22523. /**
  22524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22525. */
  22526. readonly supportsUVs: boolean;
  22527. /**
  22528. * Gets the number of targets stored in this manager
  22529. */
  22530. readonly numTargets: number;
  22531. /**
  22532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22533. */
  22534. readonly numInfluencers: number;
  22535. /**
  22536. * Gets the list of influences (one per target)
  22537. */
  22538. readonly influences: Float32Array;
  22539. /**
  22540. * Gets the active target at specified index. An active target is a target with an influence > 0
  22541. * @param index defines the index to check
  22542. * @returns the requested target
  22543. */
  22544. getActiveTarget(index: number): MorphTarget;
  22545. /**
  22546. * Gets the target at specified index
  22547. * @param index defines the index to check
  22548. * @returns the requested target
  22549. */
  22550. getTarget(index: number): MorphTarget;
  22551. /**
  22552. * Add a new target to this manager
  22553. * @param target defines the target to add
  22554. */
  22555. addTarget(target: MorphTarget): void;
  22556. /**
  22557. * Removes a target from the manager
  22558. * @param target defines the target to remove
  22559. */
  22560. removeTarget(target: MorphTarget): void;
  22561. /**
  22562. * Serializes the current manager into a Serialization object
  22563. * @returns the serialized object
  22564. */
  22565. serialize(): any;
  22566. private _syncActiveTargets;
  22567. /**
  22568. * Syncrhonize the targets with all the meshes using this morph target manager
  22569. */
  22570. synchronize(): void;
  22571. /**
  22572. * Creates a new MorphTargetManager from serialized data
  22573. * @param serializationObject defines the serialized data
  22574. * @param scene defines the hosting scene
  22575. * @returns the new MorphTargetManager
  22576. */
  22577. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22578. }
  22579. }
  22580. declare module "babylonjs/Meshes/meshLODLevel" {
  22581. import { Mesh } from "babylonjs/Meshes/mesh";
  22582. import { Nullable } from "babylonjs/types";
  22583. /**
  22584. * Class used to represent a specific level of detail of a mesh
  22585. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22586. */
  22587. export class MeshLODLevel {
  22588. /** Defines the distance where this level should star being displayed */
  22589. distance: number;
  22590. /** Defines the mesh to use to render this level */
  22591. mesh: Nullable<Mesh>;
  22592. /**
  22593. * Creates a new LOD level
  22594. * @param distance defines the distance where this level should star being displayed
  22595. * @param mesh defines the mesh to use to render this level
  22596. */
  22597. constructor(
  22598. /** Defines the distance where this level should star being displayed */
  22599. distance: number,
  22600. /** Defines the mesh to use to render this level */
  22601. mesh: Nullable<Mesh>);
  22602. }
  22603. }
  22604. declare module "babylonjs/Meshes/groundMesh" {
  22605. import { Scene } from "babylonjs/scene";
  22606. import { Vector3 } from "babylonjs/Maths/math.vector";
  22607. import { Mesh } from "babylonjs/Meshes/mesh";
  22608. /**
  22609. * Mesh representing the gorund
  22610. */
  22611. export class GroundMesh extends Mesh {
  22612. /** If octree should be generated */
  22613. generateOctree: boolean;
  22614. private _heightQuads;
  22615. /** @hidden */
  22616. _subdivisionsX: number;
  22617. /** @hidden */
  22618. _subdivisionsY: number;
  22619. /** @hidden */
  22620. _width: number;
  22621. /** @hidden */
  22622. _height: number;
  22623. /** @hidden */
  22624. _minX: number;
  22625. /** @hidden */
  22626. _maxX: number;
  22627. /** @hidden */
  22628. _minZ: number;
  22629. /** @hidden */
  22630. _maxZ: number;
  22631. constructor(name: string, scene: Scene);
  22632. /**
  22633. * "GroundMesh"
  22634. * @returns "GroundMesh"
  22635. */
  22636. getClassName(): string;
  22637. /**
  22638. * The minimum of x and y subdivisions
  22639. */
  22640. readonly subdivisions: number;
  22641. /**
  22642. * X subdivisions
  22643. */
  22644. readonly subdivisionsX: number;
  22645. /**
  22646. * Y subdivisions
  22647. */
  22648. readonly subdivisionsY: number;
  22649. /**
  22650. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22651. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22652. * @param chunksCount the number of subdivisions for x and y
  22653. * @param octreeBlocksSize (Default: 32)
  22654. */
  22655. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22656. /**
  22657. * Returns a height (y) value in the Worl system :
  22658. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22659. * @param x x coordinate
  22660. * @param z z coordinate
  22661. * @returns the ground y position if (x, z) are outside the ground surface.
  22662. */
  22663. getHeightAtCoordinates(x: number, z: number): number;
  22664. /**
  22665. * Returns a normalized vector (Vector3) orthogonal to the ground
  22666. * at the ground coordinates (x, z) expressed in the World system.
  22667. * @param x x coordinate
  22668. * @param z z coordinate
  22669. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22670. */
  22671. getNormalAtCoordinates(x: number, z: number): Vector3;
  22672. /**
  22673. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22674. * at the ground coordinates (x, z) expressed in the World system.
  22675. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22676. * @param x x coordinate
  22677. * @param z z coordinate
  22678. * @param ref vector to store the result
  22679. * @returns the GroundMesh.
  22680. */
  22681. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22682. /**
  22683. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22684. * if the ground has been updated.
  22685. * This can be used in the render loop.
  22686. * @returns the GroundMesh.
  22687. */
  22688. updateCoordinateHeights(): GroundMesh;
  22689. private _getFacetAt;
  22690. private _initHeightQuads;
  22691. private _computeHeightQuads;
  22692. /**
  22693. * Serializes this ground mesh
  22694. * @param serializationObject object to write serialization to
  22695. */
  22696. serialize(serializationObject: any): void;
  22697. /**
  22698. * Parses a serialized ground mesh
  22699. * @param parsedMesh the serialized mesh
  22700. * @param scene the scene to create the ground mesh in
  22701. * @returns the created ground mesh
  22702. */
  22703. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22704. }
  22705. }
  22706. declare module "babylonjs/Physics/physicsJoint" {
  22707. import { Vector3 } from "babylonjs/Maths/math.vector";
  22708. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22709. /**
  22710. * Interface for Physics-Joint data
  22711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22712. */
  22713. export interface PhysicsJointData {
  22714. /**
  22715. * The main pivot of the joint
  22716. */
  22717. mainPivot?: Vector3;
  22718. /**
  22719. * The connected pivot of the joint
  22720. */
  22721. connectedPivot?: Vector3;
  22722. /**
  22723. * The main axis of the joint
  22724. */
  22725. mainAxis?: Vector3;
  22726. /**
  22727. * The connected axis of the joint
  22728. */
  22729. connectedAxis?: Vector3;
  22730. /**
  22731. * The collision of the joint
  22732. */
  22733. collision?: boolean;
  22734. /**
  22735. * Native Oimo/Cannon/Energy data
  22736. */
  22737. nativeParams?: any;
  22738. }
  22739. /**
  22740. * This is a holder class for the physics joint created by the physics plugin
  22741. * It holds a set of functions to control the underlying joint
  22742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22743. */
  22744. export class PhysicsJoint {
  22745. /**
  22746. * The type of the physics joint
  22747. */
  22748. type: number;
  22749. /**
  22750. * The data for the physics joint
  22751. */
  22752. jointData: PhysicsJointData;
  22753. private _physicsJoint;
  22754. protected _physicsPlugin: IPhysicsEnginePlugin;
  22755. /**
  22756. * Initializes the physics joint
  22757. * @param type The type of the physics joint
  22758. * @param jointData The data for the physics joint
  22759. */
  22760. constructor(
  22761. /**
  22762. * The type of the physics joint
  22763. */
  22764. type: number,
  22765. /**
  22766. * The data for the physics joint
  22767. */
  22768. jointData: PhysicsJointData);
  22769. /**
  22770. * Gets the physics joint
  22771. */
  22772. /**
  22773. * Sets the physics joint
  22774. */
  22775. physicsJoint: any;
  22776. /**
  22777. * Sets the physics plugin
  22778. */
  22779. physicsPlugin: IPhysicsEnginePlugin;
  22780. /**
  22781. * Execute a function that is physics-plugin specific.
  22782. * @param {Function} func the function that will be executed.
  22783. * It accepts two parameters: the physics world and the physics joint
  22784. */
  22785. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22786. /**
  22787. * Distance-Joint type
  22788. */
  22789. static DistanceJoint: number;
  22790. /**
  22791. * Hinge-Joint type
  22792. */
  22793. static HingeJoint: number;
  22794. /**
  22795. * Ball-and-Socket joint type
  22796. */
  22797. static BallAndSocketJoint: number;
  22798. /**
  22799. * Wheel-Joint type
  22800. */
  22801. static WheelJoint: number;
  22802. /**
  22803. * Slider-Joint type
  22804. */
  22805. static SliderJoint: number;
  22806. /**
  22807. * Prismatic-Joint type
  22808. */
  22809. static PrismaticJoint: number;
  22810. /**
  22811. * Universal-Joint type
  22812. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22813. */
  22814. static UniversalJoint: number;
  22815. /**
  22816. * Hinge-Joint 2 type
  22817. */
  22818. static Hinge2Joint: number;
  22819. /**
  22820. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22821. */
  22822. static PointToPointJoint: number;
  22823. /**
  22824. * Spring-Joint type
  22825. */
  22826. static SpringJoint: number;
  22827. /**
  22828. * Lock-Joint type
  22829. */
  22830. static LockJoint: number;
  22831. }
  22832. /**
  22833. * A class representing a physics distance joint
  22834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22835. */
  22836. export class DistanceJoint extends PhysicsJoint {
  22837. /**
  22838. *
  22839. * @param jointData The data for the Distance-Joint
  22840. */
  22841. constructor(jointData: DistanceJointData);
  22842. /**
  22843. * Update the predefined distance.
  22844. * @param maxDistance The maximum preferred distance
  22845. * @param minDistance The minimum preferred distance
  22846. */
  22847. updateDistance(maxDistance: number, minDistance?: number): void;
  22848. }
  22849. /**
  22850. * Represents a Motor-Enabled Joint
  22851. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22852. */
  22853. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22854. /**
  22855. * Initializes the Motor-Enabled Joint
  22856. * @param type The type of the joint
  22857. * @param jointData The physica joint data for the joint
  22858. */
  22859. constructor(type: number, jointData: PhysicsJointData);
  22860. /**
  22861. * Set the motor values.
  22862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22863. * @param force the force to apply
  22864. * @param maxForce max force for this motor.
  22865. */
  22866. setMotor(force?: number, maxForce?: number): void;
  22867. /**
  22868. * Set the motor's limits.
  22869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22870. * @param upperLimit The upper limit of the motor
  22871. * @param lowerLimit The lower limit of the motor
  22872. */
  22873. setLimit(upperLimit: number, lowerLimit?: number): void;
  22874. }
  22875. /**
  22876. * This class represents a single physics Hinge-Joint
  22877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22878. */
  22879. export class HingeJoint extends MotorEnabledJoint {
  22880. /**
  22881. * Initializes the Hinge-Joint
  22882. * @param jointData The joint data for the Hinge-Joint
  22883. */
  22884. constructor(jointData: PhysicsJointData);
  22885. /**
  22886. * Set the motor values.
  22887. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22888. * @param {number} force the force to apply
  22889. * @param {number} maxForce max force for this motor.
  22890. */
  22891. setMotor(force?: number, maxForce?: number): void;
  22892. /**
  22893. * Set the motor's limits.
  22894. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22895. * @param upperLimit The upper limit of the motor
  22896. * @param lowerLimit The lower limit of the motor
  22897. */
  22898. setLimit(upperLimit: number, lowerLimit?: number): void;
  22899. }
  22900. /**
  22901. * This class represents a dual hinge physics joint (same as wheel joint)
  22902. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22903. */
  22904. export class Hinge2Joint extends MotorEnabledJoint {
  22905. /**
  22906. * Initializes the Hinge2-Joint
  22907. * @param jointData The joint data for the Hinge2-Joint
  22908. */
  22909. constructor(jointData: PhysicsJointData);
  22910. /**
  22911. * Set the motor values.
  22912. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22913. * @param {number} targetSpeed the speed the motor is to reach
  22914. * @param {number} maxForce max force for this motor.
  22915. * @param {motorIndex} the motor's index, 0 or 1.
  22916. */
  22917. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22918. /**
  22919. * Set the motor limits.
  22920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22921. * @param {number} upperLimit the upper limit
  22922. * @param {number} lowerLimit lower limit
  22923. * @param {motorIndex} the motor's index, 0 or 1.
  22924. */
  22925. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22926. }
  22927. /**
  22928. * Interface for a motor enabled joint
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export interface IMotorEnabledJoint {
  22932. /**
  22933. * Physics joint
  22934. */
  22935. physicsJoint: any;
  22936. /**
  22937. * Sets the motor of the motor-enabled joint
  22938. * @param force The force of the motor
  22939. * @param maxForce The maximum force of the motor
  22940. * @param motorIndex The index of the motor
  22941. */
  22942. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22943. /**
  22944. * Sets the limit of the motor
  22945. * @param upperLimit The upper limit of the motor
  22946. * @param lowerLimit The lower limit of the motor
  22947. * @param motorIndex The index of the motor
  22948. */
  22949. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22950. }
  22951. /**
  22952. * Joint data for a Distance-Joint
  22953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22954. */
  22955. export interface DistanceJointData extends PhysicsJointData {
  22956. /**
  22957. * Max distance the 2 joint objects can be apart
  22958. */
  22959. maxDistance: number;
  22960. }
  22961. /**
  22962. * Joint data from a spring joint
  22963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22964. */
  22965. export interface SpringJointData extends PhysicsJointData {
  22966. /**
  22967. * Length of the spring
  22968. */
  22969. length: number;
  22970. /**
  22971. * Stiffness of the spring
  22972. */
  22973. stiffness: number;
  22974. /**
  22975. * Damping of the spring
  22976. */
  22977. damping: number;
  22978. /** this callback will be called when applying the force to the impostors. */
  22979. forceApplicationCallback: () => void;
  22980. }
  22981. }
  22982. declare module "babylonjs/Physics/physicsRaycastResult" {
  22983. import { Vector3 } from "babylonjs/Maths/math.vector";
  22984. /**
  22985. * Holds the data for the raycast result
  22986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22987. */
  22988. export class PhysicsRaycastResult {
  22989. private _hasHit;
  22990. private _hitDistance;
  22991. private _hitNormalWorld;
  22992. private _hitPointWorld;
  22993. private _rayFromWorld;
  22994. private _rayToWorld;
  22995. /**
  22996. * Gets if there was a hit
  22997. */
  22998. readonly hasHit: boolean;
  22999. /**
  23000. * Gets the distance from the hit
  23001. */
  23002. readonly hitDistance: number;
  23003. /**
  23004. * Gets the hit normal/direction in the world
  23005. */
  23006. readonly hitNormalWorld: Vector3;
  23007. /**
  23008. * Gets the hit point in the world
  23009. */
  23010. readonly hitPointWorld: Vector3;
  23011. /**
  23012. * Gets the ray "start point" of the ray in the world
  23013. */
  23014. readonly rayFromWorld: Vector3;
  23015. /**
  23016. * Gets the ray "end point" of the ray in the world
  23017. */
  23018. readonly rayToWorld: Vector3;
  23019. /**
  23020. * Sets the hit data (normal & point in world space)
  23021. * @param hitNormalWorld defines the normal in world space
  23022. * @param hitPointWorld defines the point in world space
  23023. */
  23024. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23025. /**
  23026. * Sets the distance from the start point to the hit point
  23027. * @param distance
  23028. */
  23029. setHitDistance(distance: number): void;
  23030. /**
  23031. * Calculates the distance manually
  23032. */
  23033. calculateHitDistance(): void;
  23034. /**
  23035. * Resets all the values to default
  23036. * @param from The from point on world space
  23037. * @param to The to point on world space
  23038. */
  23039. reset(from?: Vector3, to?: Vector3): void;
  23040. }
  23041. /**
  23042. * Interface for the size containing width and height
  23043. */
  23044. interface IXYZ {
  23045. /**
  23046. * X
  23047. */
  23048. x: number;
  23049. /**
  23050. * Y
  23051. */
  23052. y: number;
  23053. /**
  23054. * Z
  23055. */
  23056. z: number;
  23057. }
  23058. }
  23059. declare module "babylonjs/Physics/IPhysicsEngine" {
  23060. import { Nullable } from "babylonjs/types";
  23061. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23063. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23064. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23065. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23066. /**
  23067. * Interface used to describe a physics joint
  23068. */
  23069. export interface PhysicsImpostorJoint {
  23070. /** Defines the main impostor to which the joint is linked */
  23071. mainImpostor: PhysicsImpostor;
  23072. /** Defines the impostor that is connected to the main impostor using this joint */
  23073. connectedImpostor: PhysicsImpostor;
  23074. /** Defines the joint itself */
  23075. joint: PhysicsJoint;
  23076. }
  23077. /** @hidden */
  23078. export interface IPhysicsEnginePlugin {
  23079. world: any;
  23080. name: string;
  23081. setGravity(gravity: Vector3): void;
  23082. setTimeStep(timeStep: number): void;
  23083. getTimeStep(): number;
  23084. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23085. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23086. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23087. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23088. removePhysicsBody(impostor: PhysicsImpostor): void;
  23089. generateJoint(joint: PhysicsImpostorJoint): void;
  23090. removeJoint(joint: PhysicsImpostorJoint): void;
  23091. isSupported(): boolean;
  23092. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23093. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23094. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23095. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23096. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23097. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23098. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23099. getBodyMass(impostor: PhysicsImpostor): number;
  23100. getBodyFriction(impostor: PhysicsImpostor): number;
  23101. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23102. getBodyRestitution(impostor: PhysicsImpostor): number;
  23103. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23104. getBodyPressure?(impostor: PhysicsImpostor): number;
  23105. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23106. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23107. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23108. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23109. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23110. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23111. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23112. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23113. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23114. sleepBody(impostor: PhysicsImpostor): void;
  23115. wakeUpBody(impostor: PhysicsImpostor): void;
  23116. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23117. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23118. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23119. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23120. getRadius(impostor: PhysicsImpostor): number;
  23121. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23122. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23123. dispose(): void;
  23124. }
  23125. /**
  23126. * Interface used to define a physics engine
  23127. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23128. */
  23129. export interface IPhysicsEngine {
  23130. /**
  23131. * Gets the gravity vector used by the simulation
  23132. */
  23133. gravity: Vector3;
  23134. /**
  23135. * Sets the gravity vector used by the simulation
  23136. * @param gravity defines the gravity vector to use
  23137. */
  23138. setGravity(gravity: Vector3): void;
  23139. /**
  23140. * Set the time step of the physics engine.
  23141. * Default is 1/60.
  23142. * To slow it down, enter 1/600 for example.
  23143. * To speed it up, 1/30
  23144. * @param newTimeStep the new timestep to apply to this world.
  23145. */
  23146. setTimeStep(newTimeStep: number): void;
  23147. /**
  23148. * Get the time step of the physics engine.
  23149. * @returns the current time step
  23150. */
  23151. getTimeStep(): number;
  23152. /**
  23153. * Release all resources
  23154. */
  23155. dispose(): void;
  23156. /**
  23157. * Gets the name of the current physics plugin
  23158. * @returns the name of the plugin
  23159. */
  23160. getPhysicsPluginName(): string;
  23161. /**
  23162. * Adding a new impostor for the impostor tracking.
  23163. * This will be done by the impostor itself.
  23164. * @param impostor the impostor to add
  23165. */
  23166. addImpostor(impostor: PhysicsImpostor): void;
  23167. /**
  23168. * Remove an impostor from the engine.
  23169. * This impostor and its mesh will not longer be updated by the physics engine.
  23170. * @param impostor the impostor to remove
  23171. */
  23172. removeImpostor(impostor: PhysicsImpostor): void;
  23173. /**
  23174. * Add a joint to the physics engine
  23175. * @param mainImpostor defines the main impostor to which the joint is added.
  23176. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23177. * @param joint defines the joint that will connect both impostors.
  23178. */
  23179. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23180. /**
  23181. * Removes a joint from the simulation
  23182. * @param mainImpostor defines the impostor used with the joint
  23183. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23184. * @param joint defines the joint to remove
  23185. */
  23186. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23187. /**
  23188. * Gets the current plugin used to run the simulation
  23189. * @returns current plugin
  23190. */
  23191. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23192. /**
  23193. * Gets the list of physic impostors
  23194. * @returns an array of PhysicsImpostor
  23195. */
  23196. getImpostors(): Array<PhysicsImpostor>;
  23197. /**
  23198. * Gets the impostor for a physics enabled object
  23199. * @param object defines the object impersonated by the impostor
  23200. * @returns the PhysicsImpostor or null if not found
  23201. */
  23202. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23203. /**
  23204. * Gets the impostor for a physics body object
  23205. * @param body defines physics body used by the impostor
  23206. * @returns the PhysicsImpostor or null if not found
  23207. */
  23208. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23209. /**
  23210. * Does a raycast in the physics world
  23211. * @param from when should the ray start?
  23212. * @param to when should the ray end?
  23213. * @returns PhysicsRaycastResult
  23214. */
  23215. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23216. /**
  23217. * Called by the scene. No need to call it.
  23218. * @param delta defines the timespam between frames
  23219. */
  23220. _step(delta: number): void;
  23221. }
  23222. }
  23223. declare module "babylonjs/Physics/physicsImpostor" {
  23224. import { Nullable, IndicesArray } from "babylonjs/types";
  23225. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23228. import { Scene } from "babylonjs/scene";
  23229. import { Bone } from "babylonjs/Bones/bone";
  23230. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23231. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23232. import { Space } from "babylonjs/Maths/math.axis";
  23233. /**
  23234. * The interface for the physics imposter parameters
  23235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23236. */
  23237. export interface PhysicsImpostorParameters {
  23238. /**
  23239. * The mass of the physics imposter
  23240. */
  23241. mass: number;
  23242. /**
  23243. * The friction of the physics imposter
  23244. */
  23245. friction?: number;
  23246. /**
  23247. * The coefficient of restitution of the physics imposter
  23248. */
  23249. restitution?: number;
  23250. /**
  23251. * The native options of the physics imposter
  23252. */
  23253. nativeOptions?: any;
  23254. /**
  23255. * Specifies if the parent should be ignored
  23256. */
  23257. ignoreParent?: boolean;
  23258. /**
  23259. * Specifies if bi-directional transformations should be disabled
  23260. */
  23261. disableBidirectionalTransformation?: boolean;
  23262. /**
  23263. * The pressure inside the physics imposter, soft object only
  23264. */
  23265. pressure?: number;
  23266. /**
  23267. * The stiffness the physics imposter, soft object only
  23268. */
  23269. stiffness?: number;
  23270. /**
  23271. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23272. */
  23273. velocityIterations?: number;
  23274. /**
  23275. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23276. */
  23277. positionIterations?: number;
  23278. /**
  23279. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23280. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23281. * Add to fix multiple points
  23282. */
  23283. fixedPoints?: number;
  23284. /**
  23285. * The collision margin around a soft object
  23286. */
  23287. margin?: number;
  23288. /**
  23289. * The collision margin around a soft object
  23290. */
  23291. damping?: number;
  23292. /**
  23293. * The path for a rope based on an extrusion
  23294. */
  23295. path?: any;
  23296. /**
  23297. * The shape of an extrusion used for a rope based on an extrusion
  23298. */
  23299. shape?: any;
  23300. }
  23301. /**
  23302. * Interface for a physics-enabled object
  23303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23304. */
  23305. export interface IPhysicsEnabledObject {
  23306. /**
  23307. * The position of the physics-enabled object
  23308. */
  23309. position: Vector3;
  23310. /**
  23311. * The rotation of the physics-enabled object
  23312. */
  23313. rotationQuaternion: Nullable<Quaternion>;
  23314. /**
  23315. * The scale of the physics-enabled object
  23316. */
  23317. scaling: Vector3;
  23318. /**
  23319. * The rotation of the physics-enabled object
  23320. */
  23321. rotation?: Vector3;
  23322. /**
  23323. * The parent of the physics-enabled object
  23324. */
  23325. parent?: any;
  23326. /**
  23327. * The bounding info of the physics-enabled object
  23328. * @returns The bounding info of the physics-enabled object
  23329. */
  23330. getBoundingInfo(): BoundingInfo;
  23331. /**
  23332. * Computes the world matrix
  23333. * @param force Specifies if the world matrix should be computed by force
  23334. * @returns A world matrix
  23335. */
  23336. computeWorldMatrix(force: boolean): Matrix;
  23337. /**
  23338. * Gets the world matrix
  23339. * @returns A world matrix
  23340. */
  23341. getWorldMatrix?(): Matrix;
  23342. /**
  23343. * Gets the child meshes
  23344. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23345. * @returns An array of abstract meshes
  23346. */
  23347. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23348. /**
  23349. * Gets the vertex data
  23350. * @param kind The type of vertex data
  23351. * @returns A nullable array of numbers, or a float32 array
  23352. */
  23353. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23354. /**
  23355. * Gets the indices from the mesh
  23356. * @returns A nullable array of index arrays
  23357. */
  23358. getIndices?(): Nullable<IndicesArray>;
  23359. /**
  23360. * Gets the scene from the mesh
  23361. * @returns the indices array or null
  23362. */
  23363. getScene?(): Scene;
  23364. /**
  23365. * Gets the absolute position from the mesh
  23366. * @returns the absolute position
  23367. */
  23368. getAbsolutePosition(): Vector3;
  23369. /**
  23370. * Gets the absolute pivot point from the mesh
  23371. * @returns the absolute pivot point
  23372. */
  23373. getAbsolutePivotPoint(): Vector3;
  23374. /**
  23375. * Rotates the mesh
  23376. * @param axis The axis of rotation
  23377. * @param amount The amount of rotation
  23378. * @param space The space of the rotation
  23379. * @returns The rotation transform node
  23380. */
  23381. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23382. /**
  23383. * Translates the mesh
  23384. * @param axis The axis of translation
  23385. * @param distance The distance of translation
  23386. * @param space The space of the translation
  23387. * @returns The transform node
  23388. */
  23389. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23390. /**
  23391. * Sets the absolute position of the mesh
  23392. * @param absolutePosition The absolute position of the mesh
  23393. * @returns The transform node
  23394. */
  23395. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23396. /**
  23397. * Gets the class name of the mesh
  23398. * @returns The class name
  23399. */
  23400. getClassName(): string;
  23401. }
  23402. /**
  23403. * Represents a physics imposter
  23404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23405. */
  23406. export class PhysicsImpostor {
  23407. /**
  23408. * The physics-enabled object used as the physics imposter
  23409. */
  23410. object: IPhysicsEnabledObject;
  23411. /**
  23412. * The type of the physics imposter
  23413. */
  23414. type: number;
  23415. private _options;
  23416. private _scene?;
  23417. /**
  23418. * The default object size of the imposter
  23419. */
  23420. static DEFAULT_OBJECT_SIZE: Vector3;
  23421. /**
  23422. * The identity quaternion of the imposter
  23423. */
  23424. static IDENTITY_QUATERNION: Quaternion;
  23425. /** @hidden */
  23426. _pluginData: any;
  23427. private _physicsEngine;
  23428. private _physicsBody;
  23429. private _bodyUpdateRequired;
  23430. private _onBeforePhysicsStepCallbacks;
  23431. private _onAfterPhysicsStepCallbacks;
  23432. /** @hidden */
  23433. _onPhysicsCollideCallbacks: Array<{
  23434. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23435. otherImpostors: Array<PhysicsImpostor>;
  23436. }>;
  23437. private _deltaPosition;
  23438. private _deltaRotation;
  23439. private _deltaRotationConjugated;
  23440. /** @hidden */
  23441. _isFromLine: boolean;
  23442. private _parent;
  23443. private _isDisposed;
  23444. private static _tmpVecs;
  23445. private static _tmpQuat;
  23446. /**
  23447. * Specifies if the physics imposter is disposed
  23448. */
  23449. readonly isDisposed: boolean;
  23450. /**
  23451. * Gets the mass of the physics imposter
  23452. */
  23453. mass: number;
  23454. /**
  23455. * Gets the coefficient of friction
  23456. */
  23457. /**
  23458. * Sets the coefficient of friction
  23459. */
  23460. friction: number;
  23461. /**
  23462. * Gets the coefficient of restitution
  23463. */
  23464. /**
  23465. * Sets the coefficient of restitution
  23466. */
  23467. restitution: number;
  23468. /**
  23469. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23470. */
  23471. /**
  23472. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23473. */
  23474. pressure: number;
  23475. /**
  23476. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23477. */
  23478. /**
  23479. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23480. */
  23481. stiffness: number;
  23482. /**
  23483. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23484. */
  23485. /**
  23486. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23487. */
  23488. velocityIterations: number;
  23489. /**
  23490. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23491. */
  23492. /**
  23493. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23494. */
  23495. positionIterations: number;
  23496. /**
  23497. * The unique id of the physics imposter
  23498. * set by the physics engine when adding this impostor to the array
  23499. */
  23500. uniqueId: number;
  23501. /**
  23502. * @hidden
  23503. */
  23504. soft: boolean;
  23505. /**
  23506. * @hidden
  23507. */
  23508. segments: number;
  23509. private _joints;
  23510. /**
  23511. * Initializes the physics imposter
  23512. * @param object The physics-enabled object used as the physics imposter
  23513. * @param type The type of the physics imposter
  23514. * @param _options The options for the physics imposter
  23515. * @param _scene The Babylon scene
  23516. */
  23517. constructor(
  23518. /**
  23519. * The physics-enabled object used as the physics imposter
  23520. */
  23521. object: IPhysicsEnabledObject,
  23522. /**
  23523. * The type of the physics imposter
  23524. */
  23525. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23526. /**
  23527. * This function will completly initialize this impostor.
  23528. * It will create a new body - but only if this mesh has no parent.
  23529. * If it has, this impostor will not be used other than to define the impostor
  23530. * of the child mesh.
  23531. * @hidden
  23532. */
  23533. _init(): void;
  23534. private _getPhysicsParent;
  23535. /**
  23536. * Should a new body be generated.
  23537. * @returns boolean specifying if body initialization is required
  23538. */
  23539. isBodyInitRequired(): boolean;
  23540. /**
  23541. * Sets the updated scaling
  23542. * @param updated Specifies if the scaling is updated
  23543. */
  23544. setScalingUpdated(): void;
  23545. /**
  23546. * Force a regeneration of this or the parent's impostor's body.
  23547. * Use under cautious - This will remove all joints already implemented.
  23548. */
  23549. forceUpdate(): void;
  23550. /**
  23551. * Gets the body that holds this impostor. Either its own, or its parent.
  23552. */
  23553. /**
  23554. * Set the physics body. Used mainly by the physics engine/plugin
  23555. */
  23556. physicsBody: any;
  23557. /**
  23558. * Get the parent of the physics imposter
  23559. * @returns Physics imposter or null
  23560. */
  23561. /**
  23562. * Sets the parent of the physics imposter
  23563. */
  23564. parent: Nullable<PhysicsImpostor>;
  23565. /**
  23566. * Resets the update flags
  23567. */
  23568. resetUpdateFlags(): void;
  23569. /**
  23570. * Gets the object extend size
  23571. * @returns the object extend size
  23572. */
  23573. getObjectExtendSize(): Vector3;
  23574. /**
  23575. * Gets the object center
  23576. * @returns The object center
  23577. */
  23578. getObjectCenter(): Vector3;
  23579. /**
  23580. * Get a specific parametes from the options parameter
  23581. * @param paramName The object parameter name
  23582. * @returns The object parameter
  23583. */
  23584. getParam(paramName: string): any;
  23585. /**
  23586. * Sets a specific parameter in the options given to the physics plugin
  23587. * @param paramName The parameter name
  23588. * @param value The value of the parameter
  23589. */
  23590. setParam(paramName: string, value: number): void;
  23591. /**
  23592. * Specifically change the body's mass option. Won't recreate the physics body object
  23593. * @param mass The mass of the physics imposter
  23594. */
  23595. setMass(mass: number): void;
  23596. /**
  23597. * Gets the linear velocity
  23598. * @returns linear velocity or null
  23599. */
  23600. getLinearVelocity(): Nullable<Vector3>;
  23601. /**
  23602. * Sets the linear velocity
  23603. * @param velocity linear velocity or null
  23604. */
  23605. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23606. /**
  23607. * Gets the angular velocity
  23608. * @returns angular velocity or null
  23609. */
  23610. getAngularVelocity(): Nullable<Vector3>;
  23611. /**
  23612. * Sets the angular velocity
  23613. * @param velocity The velocity or null
  23614. */
  23615. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23616. /**
  23617. * Execute a function with the physics plugin native code
  23618. * Provide a function the will have two variables - the world object and the physics body object
  23619. * @param func The function to execute with the physics plugin native code
  23620. */
  23621. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23622. /**
  23623. * Register a function that will be executed before the physics world is stepping forward
  23624. * @param func The function to execute before the physics world is stepped forward
  23625. */
  23626. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23627. /**
  23628. * Unregister a function that will be executed before the physics world is stepping forward
  23629. * @param func The function to execute before the physics world is stepped forward
  23630. */
  23631. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23632. /**
  23633. * Register a function that will be executed after the physics step
  23634. * @param func The function to execute after physics step
  23635. */
  23636. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23637. /**
  23638. * Unregisters a function that will be executed after the physics step
  23639. * @param func The function to execute after physics step
  23640. */
  23641. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23642. /**
  23643. * register a function that will be executed when this impostor collides against a different body
  23644. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23645. * @param func Callback that is executed on collision
  23646. */
  23647. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23648. /**
  23649. * Unregisters the physics imposter on contact
  23650. * @param collideAgainst The physics object to collide against
  23651. * @param func Callback to execute on collision
  23652. */
  23653. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23654. private _tmpQuat;
  23655. private _tmpQuat2;
  23656. /**
  23657. * Get the parent rotation
  23658. * @returns The parent rotation
  23659. */
  23660. getParentsRotation(): Quaternion;
  23661. /**
  23662. * this function is executed by the physics engine.
  23663. */
  23664. beforeStep: () => void;
  23665. /**
  23666. * this function is executed by the physics engine
  23667. */
  23668. afterStep: () => void;
  23669. /**
  23670. * Legacy collision detection event support
  23671. */
  23672. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23673. /**
  23674. * event and body object due to cannon's event-based architecture.
  23675. */
  23676. onCollide: (e: {
  23677. body: any;
  23678. }) => void;
  23679. /**
  23680. * Apply a force
  23681. * @param force The force to apply
  23682. * @param contactPoint The contact point for the force
  23683. * @returns The physics imposter
  23684. */
  23685. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23686. /**
  23687. * Apply an impulse
  23688. * @param force The impulse force
  23689. * @param contactPoint The contact point for the impulse force
  23690. * @returns The physics imposter
  23691. */
  23692. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23693. /**
  23694. * A help function to create a joint
  23695. * @param otherImpostor A physics imposter used to create a joint
  23696. * @param jointType The type of joint
  23697. * @param jointData The data for the joint
  23698. * @returns The physics imposter
  23699. */
  23700. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23701. /**
  23702. * Add a joint to this impostor with a different impostor
  23703. * @param otherImpostor A physics imposter used to add a joint
  23704. * @param joint The joint to add
  23705. * @returns The physics imposter
  23706. */
  23707. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23708. /**
  23709. * Add an anchor to a cloth impostor
  23710. * @param otherImpostor rigid impostor to anchor to
  23711. * @param width ratio across width from 0 to 1
  23712. * @param height ratio up height from 0 to 1
  23713. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23714. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23715. * @returns impostor the soft imposter
  23716. */
  23717. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23718. /**
  23719. * Add a hook to a rope impostor
  23720. * @param otherImpostor rigid impostor to anchor to
  23721. * @param length ratio across rope from 0 to 1
  23722. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23723. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23724. * @returns impostor the rope imposter
  23725. */
  23726. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23727. /**
  23728. * Will keep this body still, in a sleep mode.
  23729. * @returns the physics imposter
  23730. */
  23731. sleep(): PhysicsImpostor;
  23732. /**
  23733. * Wake the body up.
  23734. * @returns The physics imposter
  23735. */
  23736. wakeUp(): PhysicsImpostor;
  23737. /**
  23738. * Clones the physics imposter
  23739. * @param newObject The physics imposter clones to this physics-enabled object
  23740. * @returns A nullable physics imposter
  23741. */
  23742. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23743. /**
  23744. * Disposes the physics imposter
  23745. */
  23746. dispose(): void;
  23747. /**
  23748. * Sets the delta position
  23749. * @param position The delta position amount
  23750. */
  23751. setDeltaPosition(position: Vector3): void;
  23752. /**
  23753. * Sets the delta rotation
  23754. * @param rotation The delta rotation amount
  23755. */
  23756. setDeltaRotation(rotation: Quaternion): void;
  23757. /**
  23758. * Gets the box size of the physics imposter and stores the result in the input parameter
  23759. * @param result Stores the box size
  23760. * @returns The physics imposter
  23761. */
  23762. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23763. /**
  23764. * Gets the radius of the physics imposter
  23765. * @returns Radius of the physics imposter
  23766. */
  23767. getRadius(): number;
  23768. /**
  23769. * Sync a bone with this impostor
  23770. * @param bone The bone to sync to the impostor.
  23771. * @param boneMesh The mesh that the bone is influencing.
  23772. * @param jointPivot The pivot of the joint / bone in local space.
  23773. * @param distToJoint Optional distance from the impostor to the joint.
  23774. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23775. */
  23776. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23777. /**
  23778. * Sync impostor to a bone
  23779. * @param bone The bone that the impostor will be synced to.
  23780. * @param boneMesh The mesh that the bone is influencing.
  23781. * @param jointPivot The pivot of the joint / bone in local space.
  23782. * @param distToJoint Optional distance from the impostor to the joint.
  23783. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23784. * @param boneAxis Optional vector3 axis the bone is aligned with
  23785. */
  23786. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23787. /**
  23788. * No-Imposter type
  23789. */
  23790. static NoImpostor: number;
  23791. /**
  23792. * Sphere-Imposter type
  23793. */
  23794. static SphereImpostor: number;
  23795. /**
  23796. * Box-Imposter type
  23797. */
  23798. static BoxImpostor: number;
  23799. /**
  23800. * Plane-Imposter type
  23801. */
  23802. static PlaneImpostor: number;
  23803. /**
  23804. * Mesh-imposter type
  23805. */
  23806. static MeshImpostor: number;
  23807. /**
  23808. * Capsule-Impostor type (Ammo.js plugin only)
  23809. */
  23810. static CapsuleImpostor: number;
  23811. /**
  23812. * Cylinder-Imposter type
  23813. */
  23814. static CylinderImpostor: number;
  23815. /**
  23816. * Particle-Imposter type
  23817. */
  23818. static ParticleImpostor: number;
  23819. /**
  23820. * Heightmap-Imposter type
  23821. */
  23822. static HeightmapImpostor: number;
  23823. /**
  23824. * ConvexHull-Impostor type (Ammo.js plugin only)
  23825. */
  23826. static ConvexHullImpostor: number;
  23827. /**
  23828. * Rope-Imposter type
  23829. */
  23830. static RopeImpostor: number;
  23831. /**
  23832. * Cloth-Imposter type
  23833. */
  23834. static ClothImpostor: number;
  23835. /**
  23836. * Softbody-Imposter type
  23837. */
  23838. static SoftbodyImpostor: number;
  23839. }
  23840. }
  23841. declare module "babylonjs/Meshes/mesh" {
  23842. import { Observable } from "babylonjs/Misc/observable";
  23843. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23844. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23845. import { Camera } from "babylonjs/Cameras/camera";
  23846. import { Scene } from "babylonjs/scene";
  23847. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23848. import { Color4 } from "babylonjs/Maths/math.color";
  23849. import { Engine } from "babylonjs/Engines/engine";
  23850. import { Node } from "babylonjs/node";
  23851. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23852. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23853. import { Buffer } from "babylonjs/Meshes/buffer";
  23854. import { Geometry } from "babylonjs/Meshes/geometry";
  23855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23856. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23857. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23858. import { Effect } from "babylonjs/Materials/effect";
  23859. import { Material } from "babylonjs/Materials/material";
  23860. import { Skeleton } from "babylonjs/Bones/skeleton";
  23861. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23862. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23863. import { Path3D } from "babylonjs/Maths/math.path";
  23864. import { Plane } from "babylonjs/Maths/math.plane";
  23865. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23866. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23867. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23868. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23869. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23870. /**
  23871. * @hidden
  23872. **/
  23873. export class _CreationDataStorage {
  23874. closePath?: boolean;
  23875. closeArray?: boolean;
  23876. idx: number[];
  23877. dashSize: number;
  23878. gapSize: number;
  23879. path3D: Path3D;
  23880. pathArray: Vector3[][];
  23881. arc: number;
  23882. radius: number;
  23883. cap: number;
  23884. tessellation: number;
  23885. }
  23886. /**
  23887. * @hidden
  23888. **/
  23889. class _InstanceDataStorage {
  23890. visibleInstances: any;
  23891. batchCache: _InstancesBatch;
  23892. instancesBufferSize: number;
  23893. instancesBuffer: Nullable<Buffer>;
  23894. instancesData: Float32Array;
  23895. overridenInstanceCount: number;
  23896. isFrozen: boolean;
  23897. previousBatch: Nullable<_InstancesBatch>;
  23898. hardwareInstancedRendering: boolean;
  23899. sideOrientation: number;
  23900. }
  23901. /**
  23902. * @hidden
  23903. **/
  23904. export class _InstancesBatch {
  23905. mustReturn: boolean;
  23906. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23907. renderSelf: boolean[];
  23908. hardwareInstancedRendering: boolean[];
  23909. }
  23910. /**
  23911. * Class used to represent renderable models
  23912. */
  23913. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23914. /**
  23915. * Mesh side orientation : usually the external or front surface
  23916. */
  23917. static readonly FRONTSIDE: number;
  23918. /**
  23919. * Mesh side orientation : usually the internal or back surface
  23920. */
  23921. static readonly BACKSIDE: number;
  23922. /**
  23923. * Mesh side orientation : both internal and external or front and back surfaces
  23924. */
  23925. static readonly DOUBLESIDE: number;
  23926. /**
  23927. * Mesh side orientation : by default, `FRONTSIDE`
  23928. */
  23929. static readonly DEFAULTSIDE: number;
  23930. /**
  23931. * Mesh cap setting : no cap
  23932. */
  23933. static readonly NO_CAP: number;
  23934. /**
  23935. * Mesh cap setting : one cap at the beginning of the mesh
  23936. */
  23937. static readonly CAP_START: number;
  23938. /**
  23939. * Mesh cap setting : one cap at the end of the mesh
  23940. */
  23941. static readonly CAP_END: number;
  23942. /**
  23943. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23944. */
  23945. static readonly CAP_ALL: number;
  23946. /**
  23947. * Mesh pattern setting : no flip or rotate
  23948. */
  23949. static readonly NO_FLIP: number;
  23950. /**
  23951. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23952. */
  23953. static readonly FLIP_TILE: number;
  23954. /**
  23955. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23956. */
  23957. static readonly ROTATE_TILE: number;
  23958. /**
  23959. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23960. */
  23961. static readonly FLIP_ROW: number;
  23962. /**
  23963. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23964. */
  23965. static readonly ROTATE_ROW: number;
  23966. /**
  23967. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23968. */
  23969. static readonly FLIP_N_ROTATE_TILE: number;
  23970. /**
  23971. * Mesh pattern setting : rotate pattern and rotate
  23972. */
  23973. static readonly FLIP_N_ROTATE_ROW: number;
  23974. /**
  23975. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23976. */
  23977. static readonly CENTER: number;
  23978. /**
  23979. * Mesh tile positioning : part tiles on left
  23980. */
  23981. static readonly LEFT: number;
  23982. /**
  23983. * Mesh tile positioning : part tiles on right
  23984. */
  23985. static readonly RIGHT: number;
  23986. /**
  23987. * Mesh tile positioning : part tiles on top
  23988. */
  23989. static readonly TOP: number;
  23990. /**
  23991. * Mesh tile positioning : part tiles on bottom
  23992. */
  23993. static readonly BOTTOM: number;
  23994. /**
  23995. * Gets the default side orientation.
  23996. * @param orientation the orientation to value to attempt to get
  23997. * @returns the default orientation
  23998. * @hidden
  23999. */
  24000. static _GetDefaultSideOrientation(orientation?: number): number;
  24001. private _internalMeshDataInfo;
  24002. /**
  24003. * An event triggered before rendering the mesh
  24004. */
  24005. readonly onBeforeRenderObservable: Observable<Mesh>;
  24006. /**
  24007. * An event triggered before binding the mesh
  24008. */
  24009. readonly onBeforeBindObservable: Observable<Mesh>;
  24010. /**
  24011. * An event triggered after rendering the mesh
  24012. */
  24013. readonly onAfterRenderObservable: Observable<Mesh>;
  24014. /**
  24015. * An event triggered before drawing the mesh
  24016. */
  24017. readonly onBeforeDrawObservable: Observable<Mesh>;
  24018. private _onBeforeDrawObserver;
  24019. /**
  24020. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24021. */
  24022. onBeforeDraw: () => void;
  24023. /**
  24024. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24025. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24026. */
  24027. delayLoadState: number;
  24028. /**
  24029. * Gets the list of instances created from this mesh
  24030. * it is not supposed to be modified manually.
  24031. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24032. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24033. */
  24034. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24035. /**
  24036. * Gets the file containing delay loading data for this mesh
  24037. */
  24038. delayLoadingFile: string;
  24039. /** @hidden */
  24040. _binaryInfo: any;
  24041. /**
  24042. * User defined function used to change how LOD level selection is done
  24043. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24044. */
  24045. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24046. /**
  24047. * Gets or sets the morph target manager
  24048. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24049. */
  24050. morphTargetManager: Nullable<MorphTargetManager>;
  24051. /** @hidden */
  24052. _creationDataStorage: Nullable<_CreationDataStorage>;
  24053. /** @hidden */
  24054. _geometry: Nullable<Geometry>;
  24055. /** @hidden */
  24056. _delayInfo: Array<string>;
  24057. /** @hidden */
  24058. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24059. /** @hidden */
  24060. _instanceDataStorage: _InstanceDataStorage;
  24061. private _effectiveMaterial;
  24062. /** @hidden */
  24063. _shouldGenerateFlatShading: boolean;
  24064. /** @hidden */
  24065. _originalBuilderSideOrientation: number;
  24066. /**
  24067. * Use this property to change the original side orientation defined at construction time
  24068. */
  24069. overrideMaterialSideOrientation: Nullable<number>;
  24070. /**
  24071. * Gets the source mesh (the one used to clone this one from)
  24072. */
  24073. readonly source: Nullable<Mesh>;
  24074. /**
  24075. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24076. */
  24077. isUnIndexed: boolean;
  24078. /**
  24079. * @constructor
  24080. * @param name The value used by scene.getMeshByName() to do a lookup.
  24081. * @param scene The scene to add this mesh to.
  24082. * @param parent The parent of this mesh, if it has one
  24083. * @param source An optional Mesh from which geometry is shared, cloned.
  24084. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24085. * When false, achieved by calling a clone(), also passing False.
  24086. * This will make creation of children, recursive.
  24087. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24088. */
  24089. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24090. /**
  24091. * Gets the class name
  24092. * @returns the string "Mesh".
  24093. */
  24094. getClassName(): string;
  24095. /** @hidden */
  24096. readonly _isMesh: boolean;
  24097. /**
  24098. * Returns a description of this mesh
  24099. * @param fullDetails define if full details about this mesh must be used
  24100. * @returns a descriptive string representing this mesh
  24101. */
  24102. toString(fullDetails?: boolean): string;
  24103. /** @hidden */
  24104. _unBindEffect(): void;
  24105. /**
  24106. * Gets a boolean indicating if this mesh has LOD
  24107. */
  24108. readonly hasLODLevels: boolean;
  24109. /**
  24110. * Gets the list of MeshLODLevel associated with the current mesh
  24111. * @returns an array of MeshLODLevel
  24112. */
  24113. getLODLevels(): MeshLODLevel[];
  24114. private _sortLODLevels;
  24115. /**
  24116. * Add a mesh as LOD level triggered at the given distance.
  24117. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24118. * @param distance The distance from the center of the object to show this level
  24119. * @param mesh The mesh to be added as LOD level (can be null)
  24120. * @return This mesh (for chaining)
  24121. */
  24122. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24123. /**
  24124. * Returns the LOD level mesh at the passed distance or null if not found.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24126. * @param distance The distance from the center of the object to show this level
  24127. * @returns a Mesh or `null`
  24128. */
  24129. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24130. /**
  24131. * Remove a mesh from the LOD array
  24132. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24133. * @param mesh defines the mesh to be removed
  24134. * @return This mesh (for chaining)
  24135. */
  24136. removeLODLevel(mesh: Mesh): Mesh;
  24137. /**
  24138. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24139. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24140. * @param camera defines the camera to use to compute distance
  24141. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24142. * @return This mesh (for chaining)
  24143. */
  24144. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24145. /**
  24146. * Gets the mesh internal Geometry object
  24147. */
  24148. readonly geometry: Nullable<Geometry>;
  24149. /**
  24150. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24151. * @returns the total number of vertices
  24152. */
  24153. getTotalVertices(): number;
  24154. /**
  24155. * Returns the content of an associated vertex buffer
  24156. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24157. * - VertexBuffer.PositionKind
  24158. * - VertexBuffer.UVKind
  24159. * - VertexBuffer.UV2Kind
  24160. * - VertexBuffer.UV3Kind
  24161. * - VertexBuffer.UV4Kind
  24162. * - VertexBuffer.UV5Kind
  24163. * - VertexBuffer.UV6Kind
  24164. * - VertexBuffer.ColorKind
  24165. * - VertexBuffer.MatricesIndicesKind
  24166. * - VertexBuffer.MatricesIndicesExtraKind
  24167. * - VertexBuffer.MatricesWeightsKind
  24168. * - VertexBuffer.MatricesWeightsExtraKind
  24169. * @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
  24170. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24171. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24172. */
  24173. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24174. /**
  24175. * Returns the mesh VertexBuffer object from the requested `kind`
  24176. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24177. * - VertexBuffer.PositionKind
  24178. * - VertexBuffer.NormalKind
  24179. * - VertexBuffer.UVKind
  24180. * - VertexBuffer.UV2Kind
  24181. * - VertexBuffer.UV3Kind
  24182. * - VertexBuffer.UV4Kind
  24183. * - VertexBuffer.UV5Kind
  24184. * - VertexBuffer.UV6Kind
  24185. * - VertexBuffer.ColorKind
  24186. * - VertexBuffer.MatricesIndicesKind
  24187. * - VertexBuffer.MatricesIndicesExtraKind
  24188. * - VertexBuffer.MatricesWeightsKind
  24189. * - VertexBuffer.MatricesWeightsExtraKind
  24190. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24191. */
  24192. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24193. /**
  24194. * Tests if a specific vertex buffer is associated with this mesh
  24195. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24196. * - VertexBuffer.PositionKind
  24197. * - VertexBuffer.NormalKind
  24198. * - VertexBuffer.UVKind
  24199. * - VertexBuffer.UV2Kind
  24200. * - VertexBuffer.UV3Kind
  24201. * - VertexBuffer.UV4Kind
  24202. * - VertexBuffer.UV5Kind
  24203. * - VertexBuffer.UV6Kind
  24204. * - VertexBuffer.ColorKind
  24205. * - VertexBuffer.MatricesIndicesKind
  24206. * - VertexBuffer.MatricesIndicesExtraKind
  24207. * - VertexBuffer.MatricesWeightsKind
  24208. * - VertexBuffer.MatricesWeightsExtraKind
  24209. * @returns a boolean
  24210. */
  24211. isVerticesDataPresent(kind: string): boolean;
  24212. /**
  24213. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24214. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24215. * - VertexBuffer.PositionKind
  24216. * - VertexBuffer.UVKind
  24217. * - VertexBuffer.UV2Kind
  24218. * - VertexBuffer.UV3Kind
  24219. * - VertexBuffer.UV4Kind
  24220. * - VertexBuffer.UV5Kind
  24221. * - VertexBuffer.UV6Kind
  24222. * - VertexBuffer.ColorKind
  24223. * - VertexBuffer.MatricesIndicesKind
  24224. * - VertexBuffer.MatricesIndicesExtraKind
  24225. * - VertexBuffer.MatricesWeightsKind
  24226. * - VertexBuffer.MatricesWeightsExtraKind
  24227. * @returns a boolean
  24228. */
  24229. isVertexBufferUpdatable(kind: string): boolean;
  24230. /**
  24231. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24232. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24233. * - VertexBuffer.PositionKind
  24234. * - VertexBuffer.NormalKind
  24235. * - VertexBuffer.UVKind
  24236. * - VertexBuffer.UV2Kind
  24237. * - VertexBuffer.UV3Kind
  24238. * - VertexBuffer.UV4Kind
  24239. * - VertexBuffer.UV5Kind
  24240. * - VertexBuffer.UV6Kind
  24241. * - VertexBuffer.ColorKind
  24242. * - VertexBuffer.MatricesIndicesKind
  24243. * - VertexBuffer.MatricesIndicesExtraKind
  24244. * - VertexBuffer.MatricesWeightsKind
  24245. * - VertexBuffer.MatricesWeightsExtraKind
  24246. * @returns an array of strings
  24247. */
  24248. getVerticesDataKinds(): string[];
  24249. /**
  24250. * Returns a positive integer : the total number of indices in this mesh geometry.
  24251. * @returns the numner of indices or zero if the mesh has no geometry.
  24252. */
  24253. getTotalIndices(): number;
  24254. /**
  24255. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24256. * @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.
  24257. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24258. * @returns the indices array or an empty array if the mesh has no geometry
  24259. */
  24260. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24261. readonly isBlocked: boolean;
  24262. /**
  24263. * Determine if the current mesh is ready to be rendered
  24264. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24265. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24266. * @returns true if all associated assets are ready (material, textures, shaders)
  24267. */
  24268. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24269. /**
  24270. * 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.
  24271. */
  24272. readonly areNormalsFrozen: boolean;
  24273. /**
  24274. * 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.
  24275. * @returns the current mesh
  24276. */
  24277. freezeNormals(): Mesh;
  24278. /**
  24279. * 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
  24280. * @returns the current mesh
  24281. */
  24282. unfreezeNormals(): Mesh;
  24283. /**
  24284. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24285. */
  24286. overridenInstanceCount: number;
  24287. /** @hidden */
  24288. _preActivate(): Mesh;
  24289. /** @hidden */
  24290. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24291. /** @hidden */
  24292. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24293. /**
  24294. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24295. * This means the mesh underlying bounding box and sphere are recomputed.
  24296. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24297. * @returns the current mesh
  24298. */
  24299. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24300. /** @hidden */
  24301. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24302. /**
  24303. * This function will subdivide the mesh into multiple submeshes
  24304. * @param count defines the expected number of submeshes
  24305. */
  24306. subdivide(count: number): void;
  24307. /**
  24308. * Copy a FloatArray into a specific associated vertex buffer
  24309. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24310. * - VertexBuffer.PositionKind
  24311. * - VertexBuffer.UVKind
  24312. * - VertexBuffer.UV2Kind
  24313. * - VertexBuffer.UV3Kind
  24314. * - VertexBuffer.UV4Kind
  24315. * - VertexBuffer.UV5Kind
  24316. * - VertexBuffer.UV6Kind
  24317. * - VertexBuffer.ColorKind
  24318. * - VertexBuffer.MatricesIndicesKind
  24319. * - VertexBuffer.MatricesIndicesExtraKind
  24320. * - VertexBuffer.MatricesWeightsKind
  24321. * - VertexBuffer.MatricesWeightsExtraKind
  24322. * @param data defines the data source
  24323. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24324. * @param stride defines the data stride size (can be null)
  24325. * @returns the current mesh
  24326. */
  24327. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24328. /**
  24329. * Flags an associated vertex buffer as updatable
  24330. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24331. * - VertexBuffer.PositionKind
  24332. * - VertexBuffer.UVKind
  24333. * - VertexBuffer.UV2Kind
  24334. * - VertexBuffer.UV3Kind
  24335. * - VertexBuffer.UV4Kind
  24336. * - VertexBuffer.UV5Kind
  24337. * - VertexBuffer.UV6Kind
  24338. * - VertexBuffer.ColorKind
  24339. * - VertexBuffer.MatricesIndicesKind
  24340. * - VertexBuffer.MatricesIndicesExtraKind
  24341. * - VertexBuffer.MatricesWeightsKind
  24342. * - VertexBuffer.MatricesWeightsExtraKind
  24343. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24344. */
  24345. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24346. /**
  24347. * Sets the mesh global Vertex Buffer
  24348. * @param buffer defines the buffer to use
  24349. * @returns the current mesh
  24350. */
  24351. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24352. /**
  24353. * Update a specific associated vertex buffer
  24354. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24355. * - VertexBuffer.PositionKind
  24356. * - VertexBuffer.UVKind
  24357. * - VertexBuffer.UV2Kind
  24358. * - VertexBuffer.UV3Kind
  24359. * - VertexBuffer.UV4Kind
  24360. * - VertexBuffer.UV5Kind
  24361. * - VertexBuffer.UV6Kind
  24362. * - VertexBuffer.ColorKind
  24363. * - VertexBuffer.MatricesIndicesKind
  24364. * - VertexBuffer.MatricesIndicesExtraKind
  24365. * - VertexBuffer.MatricesWeightsKind
  24366. * - VertexBuffer.MatricesWeightsExtraKind
  24367. * @param data defines the data source
  24368. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24369. * @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)
  24370. * @returns the current mesh
  24371. */
  24372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24373. /**
  24374. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24375. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24376. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24377. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24378. * @returns the current mesh
  24379. */
  24380. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24381. /**
  24382. * Creates a un-shared specific occurence of the geometry for the mesh.
  24383. * @returns the current mesh
  24384. */
  24385. makeGeometryUnique(): Mesh;
  24386. /**
  24387. * Set the index buffer of this mesh
  24388. * @param indices defines the source data
  24389. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24390. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24391. * @returns the current mesh
  24392. */
  24393. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24394. /**
  24395. * Update the current index buffer
  24396. * @param indices defines the source data
  24397. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24398. * @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)
  24399. * @returns the current mesh
  24400. */
  24401. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24402. /**
  24403. * Invert the geometry to move from a right handed system to a left handed one.
  24404. * @returns the current mesh
  24405. */
  24406. toLeftHanded(): Mesh;
  24407. /** @hidden */
  24408. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24409. /** @hidden */
  24410. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24411. /**
  24412. * Registers for this mesh a javascript function called just before the rendering process
  24413. * @param func defines the function to call before rendering this mesh
  24414. * @returns the current mesh
  24415. */
  24416. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24417. /**
  24418. * Disposes a previously registered javascript function called before the rendering
  24419. * @param func defines the function to remove
  24420. * @returns the current mesh
  24421. */
  24422. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24423. /**
  24424. * Registers for this mesh a javascript function called just after the rendering is complete
  24425. * @param func defines the function to call after rendering this mesh
  24426. * @returns the current mesh
  24427. */
  24428. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24429. /**
  24430. * Disposes a previously registered javascript function called after the rendering.
  24431. * @param func defines the function to remove
  24432. * @returns the current mesh
  24433. */
  24434. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24435. /** @hidden */
  24436. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24437. /** @hidden */
  24438. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24439. /** @hidden */
  24440. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24441. /** @hidden */
  24442. _rebuild(): void;
  24443. /** @hidden */
  24444. _freeze(): void;
  24445. /** @hidden */
  24446. _unFreeze(): void;
  24447. /**
  24448. * 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
  24449. * @param subMesh defines the subMesh to render
  24450. * @param enableAlphaMode defines if alpha mode can be changed
  24451. * @returns the current mesh
  24452. */
  24453. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24454. private _onBeforeDraw;
  24455. /**
  24456. * Renormalize the mesh and patch it up if there are no weights
  24457. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24458. * However in the case of zero weights then we set just a single influence to 1.
  24459. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24460. */
  24461. cleanMatrixWeights(): void;
  24462. private normalizeSkinFourWeights;
  24463. private normalizeSkinWeightsAndExtra;
  24464. /**
  24465. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24466. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24467. * the user know there was an issue with importing the mesh
  24468. * @returns a validation object with skinned, valid and report string
  24469. */
  24470. validateSkinning(): {
  24471. skinned: boolean;
  24472. valid: boolean;
  24473. report: string;
  24474. };
  24475. /** @hidden */
  24476. _checkDelayState(): Mesh;
  24477. private _queueLoad;
  24478. /**
  24479. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24480. * A mesh is in the frustum if its bounding box intersects the frustum
  24481. * @param frustumPlanes defines the frustum to test
  24482. * @returns true if the mesh is in the frustum planes
  24483. */
  24484. isInFrustum(frustumPlanes: Plane[]): boolean;
  24485. /**
  24486. * Sets the mesh material by the material or multiMaterial `id` property
  24487. * @param id is a string identifying the material or the multiMaterial
  24488. * @returns the current mesh
  24489. */
  24490. setMaterialByID(id: string): Mesh;
  24491. /**
  24492. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24493. * @returns an array of IAnimatable
  24494. */
  24495. getAnimatables(): IAnimatable[];
  24496. /**
  24497. * Modifies the mesh geometry according to the passed transformation matrix.
  24498. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24499. * The mesh normals are modified using the same transformation.
  24500. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24501. * @param transform defines the transform matrix to use
  24502. * @see http://doc.babylonjs.com/resources/baking_transformations
  24503. * @returns the current mesh
  24504. */
  24505. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24506. /**
  24507. * Modifies the mesh geometry according to its own current World Matrix.
  24508. * The mesh World Matrix is then reset.
  24509. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24510. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24511. * @see http://doc.babylonjs.com/resources/baking_transformations
  24512. * @returns the current mesh
  24513. */
  24514. bakeCurrentTransformIntoVertices(): Mesh;
  24515. /** @hidden */
  24516. readonly _positions: Nullable<Vector3[]>;
  24517. /** @hidden */
  24518. _resetPointsArrayCache(): Mesh;
  24519. /** @hidden */
  24520. _generatePointsArray(): boolean;
  24521. /**
  24522. * Returns a new Mesh object generated from the current mesh properties.
  24523. * This method must not get confused with createInstance()
  24524. * @param name is a string, the name given to the new mesh
  24525. * @param newParent can be any Node object (default `null`)
  24526. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24527. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24528. * @returns a new mesh
  24529. */
  24530. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24531. /**
  24532. * Releases resources associated with this mesh.
  24533. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24534. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24535. */
  24536. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24537. /**
  24538. * Modifies the mesh geometry according to a displacement map.
  24539. * 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.
  24540. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24541. * @param url is a string, the URL from the image file is to be downloaded.
  24542. * @param minHeight is the lower limit of the displacement.
  24543. * @param maxHeight is the upper limit of the displacement.
  24544. * @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.
  24545. * @param uvOffset is an optional vector2 used to offset UV.
  24546. * @param uvScale is an optional vector2 used to scale UV.
  24547. * @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.
  24548. * @returns the Mesh.
  24549. */
  24550. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24551. /**
  24552. * Modifies the mesh geometry according to a displacementMap buffer.
  24553. * 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.
  24554. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24555. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24556. * @param heightMapWidth is the width of the buffer image.
  24557. * @param heightMapHeight is the height of the buffer image.
  24558. * @param minHeight is the lower limit of the displacement.
  24559. * @param maxHeight is the upper limit of the displacement.
  24560. * @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.
  24561. * @param uvOffset is an optional vector2 used to offset UV.
  24562. * @param uvScale is an optional vector2 used to scale UV.
  24563. * @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.
  24564. * @returns the Mesh.
  24565. */
  24566. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24567. /**
  24568. * Modify the mesh to get a flat shading rendering.
  24569. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24570. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24571. * @returns current mesh
  24572. */
  24573. convertToFlatShadedMesh(): Mesh;
  24574. /**
  24575. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24576. * In other words, more vertices, no more indices and a single bigger VBO.
  24577. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24578. * @returns current mesh
  24579. */
  24580. convertToUnIndexedMesh(): Mesh;
  24581. /**
  24582. * Inverses facet orientations.
  24583. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24584. * @param flipNormals will also inverts the normals
  24585. * @returns current mesh
  24586. */
  24587. flipFaces(flipNormals?: boolean): Mesh;
  24588. /**
  24589. * Increase the number of facets and hence vertices in a mesh
  24590. * Vertex normals are interpolated from existing vertex normals
  24591. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24592. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24593. */
  24594. increaseVertices(numberPerEdge: number): void;
  24595. /**
  24596. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24597. * This will undo any application of covertToFlatShadedMesh
  24598. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24599. */
  24600. forceSharedVertices(): void;
  24601. /** @hidden */
  24602. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24603. /** @hidden */
  24604. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24605. /**
  24606. * Creates a new InstancedMesh object from the mesh model.
  24607. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24608. * @param name defines the name of the new instance
  24609. * @returns a new InstancedMesh
  24610. */
  24611. createInstance(name: string): InstancedMesh;
  24612. /**
  24613. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24614. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24615. * @returns the current mesh
  24616. */
  24617. synchronizeInstances(): Mesh;
  24618. /**
  24619. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24620. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24621. * This should be used together with the simplification to avoid disappearing triangles.
  24622. * @param successCallback an optional success callback to be called after the optimization finished.
  24623. * @returns the current mesh
  24624. */
  24625. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24626. /**
  24627. * Serialize current mesh
  24628. * @param serializationObject defines the object which will receive the serialization data
  24629. */
  24630. serialize(serializationObject: any): void;
  24631. /** @hidden */
  24632. _syncGeometryWithMorphTargetManager(): void;
  24633. /** @hidden */
  24634. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24635. /**
  24636. * Returns a new Mesh object parsed from the source provided.
  24637. * @param parsedMesh is the source
  24638. * @param scene defines the hosting scene
  24639. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24640. * @returns a new Mesh
  24641. */
  24642. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24643. /**
  24644. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24645. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24646. * @param name defines the name of the mesh to create
  24647. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24648. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24649. * @param closePath creates a seam between the first and the last points of each path of the path array
  24650. * @param offset is taken in account only if the `pathArray` is containing a single path
  24651. * @param scene defines the hosting scene
  24652. * @param updatable defines if the mesh must be flagged as updatable
  24653. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24654. * @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)
  24655. * @returns a new Mesh
  24656. */
  24657. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24658. /**
  24659. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24660. * @param name defines the name of the mesh to create
  24661. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24662. * @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
  24663. * @param scene defines the hosting scene
  24664. * @param updatable defines if the mesh must be flagged as updatable
  24665. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24666. * @returns a new Mesh
  24667. */
  24668. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24669. /**
  24670. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24671. * @param name defines the name of the mesh to create
  24672. * @param size sets the size (float) of each box side (default 1)
  24673. * @param scene defines the hosting scene
  24674. * @param updatable defines if the mesh must be flagged as updatable
  24675. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24676. * @returns a new Mesh
  24677. */
  24678. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24679. /**
  24680. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24681. * @param name defines the name of the mesh to create
  24682. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24683. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24684. * @param scene defines the hosting scene
  24685. * @param updatable defines if the mesh must be flagged as updatable
  24686. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24687. * @returns a new Mesh
  24688. */
  24689. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24690. /**
  24691. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24692. * @param name defines the name of the mesh to create
  24693. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24694. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24695. * @param scene defines the hosting scene
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24699. /**
  24700. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24703. * @param diameterTop set the top cap diameter (floats, default 1)
  24704. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24705. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24706. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24707. * @param scene defines the hosting scene
  24708. * @param updatable defines if the mesh must be flagged as updatable
  24709. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24710. * @returns a new Mesh
  24711. */
  24712. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24713. /**
  24714. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24715. * @param name defines the name of the mesh to create
  24716. * @param diameter sets the diameter size (float) of the torus (default 1)
  24717. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24718. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24719. * @param scene defines the hosting scene
  24720. * @param updatable defines if the mesh must be flagged as updatable
  24721. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24722. * @returns a new Mesh
  24723. */
  24724. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24725. /**
  24726. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24727. * @param name defines the name of the mesh to create
  24728. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24729. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24730. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24731. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24732. * @param p the number of windings on X axis (positive integers, default 2)
  24733. * @param q the number of windings on Y axis (positive integers, default 3)
  24734. * @param scene defines the hosting scene
  24735. * @param updatable defines if the mesh must be flagged as updatable
  24736. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24737. * @returns a new Mesh
  24738. */
  24739. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24740. /**
  24741. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24742. * @param name defines the name of the mesh to create
  24743. * @param points is an array successive Vector3
  24744. * @param scene defines the hosting scene
  24745. * @param updatable defines if the mesh must be flagged as updatable
  24746. * @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).
  24747. * @returns a new Mesh
  24748. */
  24749. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24750. /**
  24751. * Creates a dashed line 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 points is an array successive Vector3
  24754. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24755. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24756. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24757. * @param scene defines the hosting scene
  24758. * @param updatable defines if the mesh must be flagged as updatable
  24759. * @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)
  24760. * @returns a new Mesh
  24761. */
  24762. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24763. /**
  24764. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24765. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24766. * 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.
  24767. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24768. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24769. * Remember you can only change the shape positions, not their number when updating a polygon.
  24770. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24771. * @param name defines the name of the mesh to create
  24772. * @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
  24773. * @param scene defines the hosting scene
  24774. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24775. * @param updatable defines if the mesh must be flagged as updatable
  24776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24777. * @param earcutInjection can be used to inject your own earcut reference
  24778. * @returns a new Mesh
  24779. */
  24780. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24781. /**
  24782. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24783. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24784. * @param name defines the name of the mesh to create
  24785. * @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
  24786. * @param depth defines the height of extrusion
  24787. * @param scene defines the hosting scene
  24788. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  24792. * @returns a new Mesh
  24793. */
  24794. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24795. /**
  24796. * Creates an extruded shape mesh.
  24797. * 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
  24798. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24799. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24800. * @param name defines the name of the mesh to create
  24801. * @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
  24802. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24803. * @param scale is the value to scale the shape
  24804. * @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
  24805. * @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
  24806. * @param scene defines the hosting scene
  24807. * @param updatable defines if the mesh must be flagged as updatable
  24808. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24809. * @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)
  24810. * @returns a new Mesh
  24811. */
  24812. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24813. /**
  24814. * Creates an custom extruded shape mesh.
  24815. * The custom extrusion is a parametric shape.
  24816. * It has no predefined shape. Its final shape will depend on the input parameters.
  24817. * Please consider using the same method from the MeshBuilder class instead
  24818. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24819. * @param name defines the name of the mesh to create
  24820. * @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
  24821. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24822. * @param scaleFunction is a custom Javascript function called on each path point
  24823. * @param rotationFunction is a custom Javascript function called on each path point
  24824. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24825. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24826. * @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
  24827. * @param scene defines the hosting scene
  24828. * @param updatable defines if the mesh must be flagged as updatable
  24829. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24830. * @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)
  24831. * @returns a new Mesh
  24832. */
  24833. 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;
  24834. /**
  24835. * Creates lathe mesh.
  24836. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24837. * Please consider using the same method from the MeshBuilder class instead
  24838. * @param name defines the name of the mesh to create
  24839. * @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
  24840. * @param radius is the radius value of the lathe
  24841. * @param tessellation is the side number of the lathe.
  24842. * @param scene defines the hosting scene
  24843. * @param updatable defines if the mesh must be flagged as updatable
  24844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24845. * @returns a new Mesh
  24846. */
  24847. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24848. /**
  24849. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24850. * @param name defines the name of the mesh to create
  24851. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24852. * @param scene defines the hosting scene
  24853. * @param updatable defines if the mesh must be flagged as updatable
  24854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24855. * @returns a new Mesh
  24856. */
  24857. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24858. /**
  24859. * Creates a ground mesh.
  24860. * Please consider using the same method from the MeshBuilder class instead
  24861. * @param name defines the name of the mesh to create
  24862. * @param width set the width of the ground
  24863. * @param height set the height of the ground
  24864. * @param subdivisions sets the number of subdivisions per side
  24865. * @param scene defines the hosting scene
  24866. * @param updatable defines if the mesh must be flagged as updatable
  24867. * @returns a new Mesh
  24868. */
  24869. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24870. /**
  24871. * Creates a tiled ground mesh.
  24872. * Please consider using the same method from the MeshBuilder class instead
  24873. * @param name defines the name of the mesh to create
  24874. * @param xmin set the ground minimum X coordinate
  24875. * @param zmin set the ground minimum Y coordinate
  24876. * @param xmax set the ground maximum X coordinate
  24877. * @param zmax set the ground maximum Z coordinate
  24878. * @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
  24879. * @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
  24880. * @param scene defines the hosting scene
  24881. * @param updatable defines if the mesh must be flagged as updatable
  24882. * @returns a new Mesh
  24883. */
  24884. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24885. w: number;
  24886. h: number;
  24887. }, precision: {
  24888. w: number;
  24889. h: number;
  24890. }, scene: Scene, updatable?: boolean): Mesh;
  24891. /**
  24892. * Creates a ground mesh from a height map.
  24893. * Please consider using the same method from the MeshBuilder class instead
  24894. * @see http://doc.babylonjs.com/babylon101/height_map
  24895. * @param name defines the name of the mesh to create
  24896. * @param url sets the URL of the height map image resource
  24897. * @param width set the ground width size
  24898. * @param height set the ground height size
  24899. * @param subdivisions sets the number of subdivision per side
  24900. * @param minHeight is the minimum altitude on the ground
  24901. * @param maxHeight is the maximum altitude on the ground
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24905. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24906. * @returns a new Mesh
  24907. */
  24908. 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;
  24909. /**
  24910. * Creates a tube mesh.
  24911. * The tube is a parametric shape.
  24912. * It has no predefined shape. Its final shape will depend on the input parameters.
  24913. * Please consider using the same method from the MeshBuilder class instead
  24914. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24915. * @param name defines the name of the mesh to create
  24916. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24917. * @param radius sets the tube radius size
  24918. * @param tessellation is the number of sides on the tubular surface
  24919. * @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
  24920. * @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
  24921. * @param scene defines the hosting scene
  24922. * @param updatable defines if the mesh must be flagged as updatable
  24923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24924. * @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)
  24925. * @returns a new Mesh
  24926. */
  24927. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24928. (i: number, distance: number): number;
  24929. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24930. /**
  24931. * Creates a polyhedron mesh.
  24932. * Please consider using the same method from the MeshBuilder class instead.
  24933. * * 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
  24934. * * The parameter `size` (positive float, default 1) sets the polygon size
  24935. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24936. * * 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`
  24937. * * 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
  24938. * * 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)`)
  24939. * * 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
  24940. * * 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
  24941. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24942. * * If you create a double-sided mesh, you can choose what parts of 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
  24943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24944. * @param name defines the name of the mesh to create
  24945. * @param options defines the options used to create the mesh
  24946. * @param scene defines the hosting scene
  24947. * @returns a new Mesh
  24948. */
  24949. static CreatePolyhedron(name: string, options: {
  24950. type?: number;
  24951. size?: number;
  24952. sizeX?: number;
  24953. sizeY?: number;
  24954. sizeZ?: number;
  24955. custom?: any;
  24956. faceUV?: Vector4[];
  24957. faceColors?: Color4[];
  24958. updatable?: boolean;
  24959. sideOrientation?: number;
  24960. }, scene: Scene): Mesh;
  24961. /**
  24962. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24963. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24964. * * 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`)
  24965. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24966. * * 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
  24967. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24968. * * If you create a double-sided mesh, you can choose what parts of 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
  24969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24970. * @param name defines the name of the mesh
  24971. * @param options defines the options used to create the mesh
  24972. * @param scene defines the hosting scene
  24973. * @returns a new Mesh
  24974. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24975. */
  24976. static CreateIcoSphere(name: string, options: {
  24977. radius?: number;
  24978. flat?: boolean;
  24979. subdivisions?: number;
  24980. sideOrientation?: number;
  24981. updatable?: boolean;
  24982. }, scene: Scene): Mesh;
  24983. /**
  24984. * Creates a decal mesh.
  24985. * Please consider using the same method from the MeshBuilder class instead.
  24986. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24987. * @param name defines the name of the mesh
  24988. * @param sourceMesh defines the mesh receiving the decal
  24989. * @param position sets the position of the decal in world coordinates
  24990. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24991. * @param size sets the decal scaling
  24992. * @param angle sets the angle to rotate the decal
  24993. * @returns a new Mesh
  24994. */
  24995. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24996. /**
  24997. * Prepare internal position array for software CPU skinning
  24998. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24999. */
  25000. setPositionsForCPUSkinning(): Float32Array;
  25001. /**
  25002. * Prepare internal normal array for software CPU skinning
  25003. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25004. */
  25005. setNormalsForCPUSkinning(): Float32Array;
  25006. /**
  25007. * Updates the vertex buffer by applying transformation from the bones
  25008. * @param skeleton defines the skeleton to apply to current mesh
  25009. * @returns the current mesh
  25010. */
  25011. applySkeleton(skeleton: Skeleton): Mesh;
  25012. /**
  25013. * 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
  25014. * @param meshes defines the list of meshes to scan
  25015. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25016. */
  25017. static MinMax(meshes: AbstractMesh[]): {
  25018. min: Vector3;
  25019. max: Vector3;
  25020. };
  25021. /**
  25022. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25023. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25024. * @returns a vector3
  25025. */
  25026. static Center(meshesOrMinMaxVector: {
  25027. min: Vector3;
  25028. max: Vector3;
  25029. } | AbstractMesh[]): Vector3;
  25030. /**
  25031. * Merge the array of meshes into a single mesh for performance reasons.
  25032. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25033. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25034. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25035. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25036. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25037. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25038. * @returns a new mesh
  25039. */
  25040. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25041. /** @hidden */
  25042. addInstance(instance: InstancedMesh): void;
  25043. /** @hidden */
  25044. removeInstance(instance: InstancedMesh): void;
  25045. }
  25046. }
  25047. declare module "babylonjs/Cameras/camera" {
  25048. import { SmartArray } from "babylonjs/Misc/smartArray";
  25049. import { Observable } from "babylonjs/Misc/observable";
  25050. import { Nullable } from "babylonjs/types";
  25051. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25052. import { Scene } from "babylonjs/scene";
  25053. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25054. import { Node } from "babylonjs/node";
  25055. import { Mesh } from "babylonjs/Meshes/mesh";
  25056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25057. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25058. import { Viewport } from "babylonjs/Maths/math.viewport";
  25059. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25060. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25061. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25062. import { Ray } from "babylonjs/Culling/ray";
  25063. /**
  25064. * This is the base class of all the camera used in the application.
  25065. * @see http://doc.babylonjs.com/features/cameras
  25066. */
  25067. export class Camera extends Node {
  25068. /** @hidden */
  25069. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25070. /**
  25071. * This is the default projection mode used by the cameras.
  25072. * It helps recreating a feeling of perspective and better appreciate depth.
  25073. * This is the best way to simulate real life cameras.
  25074. */
  25075. static readonly PERSPECTIVE_CAMERA: number;
  25076. /**
  25077. * This helps creating camera with an orthographic mode.
  25078. * 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.
  25079. */
  25080. static readonly ORTHOGRAPHIC_CAMERA: number;
  25081. /**
  25082. * This is the default FOV mode for perspective cameras.
  25083. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25084. */
  25085. static readonly FOVMODE_VERTICAL_FIXED: number;
  25086. /**
  25087. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25088. */
  25089. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25090. /**
  25091. * This specifies ther is no need for a camera rig.
  25092. * Basically only one eye is rendered corresponding to the camera.
  25093. */
  25094. static readonly RIG_MODE_NONE: number;
  25095. /**
  25096. * Simulates a camera Rig with one blue eye and one red eye.
  25097. * This can be use with 3d blue and red glasses.
  25098. */
  25099. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25100. /**
  25101. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25102. */
  25103. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25104. /**
  25105. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25106. */
  25107. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25108. /**
  25109. * Defines that both eyes of the camera will be rendered over under each other.
  25110. */
  25111. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25112. /**
  25113. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25114. */
  25115. static readonly RIG_MODE_VR: number;
  25116. /**
  25117. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25118. */
  25119. static readonly RIG_MODE_WEBVR: number;
  25120. /**
  25121. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25122. */
  25123. static readonly RIG_MODE_CUSTOM: number;
  25124. /**
  25125. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25126. */
  25127. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25128. /**
  25129. * Define the input manager associated with the camera.
  25130. */
  25131. inputs: CameraInputsManager<Camera>;
  25132. /** @hidden */
  25133. _position: Vector3;
  25134. /**
  25135. * Define the current local position of the camera in the scene
  25136. */
  25137. position: Vector3;
  25138. /**
  25139. * The vector the camera should consider as up.
  25140. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25141. */
  25142. upVector: Vector3;
  25143. /**
  25144. * Define the current limit on the left side for an orthographic camera
  25145. * In scene unit
  25146. */
  25147. orthoLeft: Nullable<number>;
  25148. /**
  25149. * Define the current limit on the right side for an orthographic camera
  25150. * In scene unit
  25151. */
  25152. orthoRight: Nullable<number>;
  25153. /**
  25154. * Define the current limit on the bottom side for an orthographic camera
  25155. * In scene unit
  25156. */
  25157. orthoBottom: Nullable<number>;
  25158. /**
  25159. * Define the current limit on the top side for an orthographic camera
  25160. * In scene unit
  25161. */
  25162. orthoTop: Nullable<number>;
  25163. /**
  25164. * Field Of View is set in Radians. (default is 0.8)
  25165. */
  25166. fov: number;
  25167. /**
  25168. * Define the minimum distance the camera can see from.
  25169. * This is important to note that the depth buffer are not infinite and the closer it starts
  25170. * the more your scene might encounter depth fighting issue.
  25171. */
  25172. minZ: number;
  25173. /**
  25174. * Define the maximum distance the camera can see to.
  25175. * This is important to note that the depth buffer are not infinite and the further it end
  25176. * the more your scene might encounter depth fighting issue.
  25177. */
  25178. maxZ: number;
  25179. /**
  25180. * Define the default inertia of the camera.
  25181. * This helps giving a smooth feeling to the camera movement.
  25182. */
  25183. inertia: number;
  25184. /**
  25185. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25186. */
  25187. mode: number;
  25188. /**
  25189. * Define wether the camera is intermediate.
  25190. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25191. */
  25192. isIntermediate: boolean;
  25193. /**
  25194. * Define the viewport of the camera.
  25195. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25196. */
  25197. viewport: Viewport;
  25198. /**
  25199. * Restricts the camera to viewing objects with the same layerMask.
  25200. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25201. */
  25202. layerMask: number;
  25203. /**
  25204. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25205. */
  25206. fovMode: number;
  25207. /**
  25208. * Rig mode of the camera.
  25209. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25210. * This is normally controlled byt the camera themselves as internal use.
  25211. */
  25212. cameraRigMode: number;
  25213. /**
  25214. * Defines the distance between both "eyes" in case of a RIG
  25215. */
  25216. interaxialDistance: number;
  25217. /**
  25218. * Defines if stereoscopic rendering is done side by side or over under.
  25219. */
  25220. isStereoscopicSideBySide: boolean;
  25221. /**
  25222. * 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
  25223. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25224. * else in the scene. (Eg. security camera)
  25225. *
  25226. * 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)
  25227. */
  25228. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25229. /**
  25230. * When set, the camera will render to this render target instead of the default canvas
  25231. *
  25232. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25233. */
  25234. outputRenderTarget: Nullable<RenderTargetTexture>;
  25235. /**
  25236. * Observable triggered when the camera view matrix has changed.
  25237. */
  25238. onViewMatrixChangedObservable: Observable<Camera>;
  25239. /**
  25240. * Observable triggered when the camera Projection matrix has changed.
  25241. */
  25242. onProjectionMatrixChangedObservable: Observable<Camera>;
  25243. /**
  25244. * Observable triggered when the inputs have been processed.
  25245. */
  25246. onAfterCheckInputsObservable: Observable<Camera>;
  25247. /**
  25248. * Observable triggered when reset has been called and applied to the camera.
  25249. */
  25250. onRestoreStateObservable: Observable<Camera>;
  25251. /** @hidden */
  25252. _cameraRigParams: any;
  25253. /** @hidden */
  25254. _rigCameras: Camera[];
  25255. /** @hidden */
  25256. _rigPostProcess: Nullable<PostProcess>;
  25257. protected _webvrViewMatrix: Matrix;
  25258. /** @hidden */
  25259. _skipRendering: boolean;
  25260. /** @hidden */
  25261. _projectionMatrix: Matrix;
  25262. /** @hidden */
  25263. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25264. /** @hidden */
  25265. _activeMeshes: SmartArray<AbstractMesh>;
  25266. protected _globalPosition: Vector3;
  25267. /** @hidden */
  25268. _computedViewMatrix: Matrix;
  25269. private _doNotComputeProjectionMatrix;
  25270. private _transformMatrix;
  25271. private _frustumPlanes;
  25272. private _refreshFrustumPlanes;
  25273. private _storedFov;
  25274. private _stateStored;
  25275. /**
  25276. * Instantiates a new camera object.
  25277. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25278. * @see http://doc.babylonjs.com/features/cameras
  25279. * @param name Defines the name of the camera in the scene
  25280. * @param position Defines the position of the camera
  25281. * @param scene Defines the scene the camera belongs too
  25282. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25283. */
  25284. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25285. /**
  25286. * Store current camera state (fov, position, etc..)
  25287. * @returns the camera
  25288. */
  25289. storeState(): Camera;
  25290. /**
  25291. * Restores the camera state values if it has been stored. You must call storeState() first
  25292. */
  25293. protected _restoreStateValues(): boolean;
  25294. /**
  25295. * Restored camera state. You must call storeState() first.
  25296. * @returns true if restored and false otherwise
  25297. */
  25298. restoreState(): boolean;
  25299. /**
  25300. * Gets the class name of the camera.
  25301. * @returns the class name
  25302. */
  25303. getClassName(): string;
  25304. /** @hidden */
  25305. readonly _isCamera: boolean;
  25306. /**
  25307. * Gets a string representation of the camera useful for debug purpose.
  25308. * @param fullDetails Defines that a more verboe level of logging is required
  25309. * @returns the string representation
  25310. */
  25311. toString(fullDetails?: boolean): string;
  25312. /**
  25313. * Gets the current world space position of the camera.
  25314. */
  25315. readonly globalPosition: Vector3;
  25316. /**
  25317. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25318. * @returns the active meshe list
  25319. */
  25320. getActiveMeshes(): SmartArray<AbstractMesh>;
  25321. /**
  25322. * Check wether a mesh is part of the current active mesh list of the camera
  25323. * @param mesh Defines the mesh to check
  25324. * @returns true if active, false otherwise
  25325. */
  25326. isActiveMesh(mesh: Mesh): boolean;
  25327. /**
  25328. * Is this camera ready to be used/rendered
  25329. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25330. * @return true if the camera is ready
  25331. */
  25332. isReady(completeCheck?: boolean): boolean;
  25333. /** @hidden */
  25334. _initCache(): void;
  25335. /** @hidden */
  25336. _updateCache(ignoreParentClass?: boolean): void;
  25337. /** @hidden */
  25338. _isSynchronized(): boolean;
  25339. /** @hidden */
  25340. _isSynchronizedViewMatrix(): boolean;
  25341. /** @hidden */
  25342. _isSynchronizedProjectionMatrix(): boolean;
  25343. /**
  25344. * Attach the input controls to a specific dom element to get the input from.
  25345. * @param element Defines the element the controls should be listened from
  25346. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25347. */
  25348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25349. /**
  25350. * Detach the current controls from the specified dom element.
  25351. * @param element Defines the element to stop listening the inputs from
  25352. */
  25353. detachControl(element: HTMLElement): void;
  25354. /**
  25355. * Update the camera state according to the different inputs gathered during the frame.
  25356. */
  25357. update(): void;
  25358. /** @hidden */
  25359. _checkInputs(): void;
  25360. /** @hidden */
  25361. readonly rigCameras: Camera[];
  25362. /**
  25363. * Gets the post process used by the rig cameras
  25364. */
  25365. readonly rigPostProcess: Nullable<PostProcess>;
  25366. /**
  25367. * Internal, gets the first post proces.
  25368. * @returns the first post process to be run on this camera.
  25369. */
  25370. _getFirstPostProcess(): Nullable<PostProcess>;
  25371. private _cascadePostProcessesToRigCams;
  25372. /**
  25373. * Attach a post process to the camera.
  25374. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25375. * @param postProcess The post process to attach to the camera
  25376. * @param insertAt The position of the post process in case several of them are in use in the scene
  25377. * @returns the position the post process has been inserted at
  25378. */
  25379. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25380. /**
  25381. * Detach a post process to the camera.
  25382. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25383. * @param postProcess The post process to detach from the camera
  25384. */
  25385. detachPostProcess(postProcess: PostProcess): void;
  25386. /**
  25387. * Gets the current world matrix of the camera
  25388. */
  25389. getWorldMatrix(): Matrix;
  25390. /** @hidden */
  25391. _getViewMatrix(): Matrix;
  25392. /**
  25393. * Gets the current view matrix of the camera.
  25394. * @param force forces the camera to recompute the matrix without looking at the cached state
  25395. * @returns the view matrix
  25396. */
  25397. getViewMatrix(force?: boolean): Matrix;
  25398. /**
  25399. * Freeze the projection matrix.
  25400. * It will prevent the cache check of the camera projection compute and can speed up perf
  25401. * if no parameter of the camera are meant to change
  25402. * @param projection Defines manually a projection if necessary
  25403. */
  25404. freezeProjectionMatrix(projection?: Matrix): void;
  25405. /**
  25406. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25407. */
  25408. unfreezeProjectionMatrix(): void;
  25409. /**
  25410. * Gets the current projection matrix of the camera.
  25411. * @param force forces the camera to recompute the matrix without looking at the cached state
  25412. * @returns the projection matrix
  25413. */
  25414. getProjectionMatrix(force?: boolean): Matrix;
  25415. /**
  25416. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25417. * @returns a Matrix
  25418. */
  25419. getTransformationMatrix(): Matrix;
  25420. private _updateFrustumPlanes;
  25421. /**
  25422. * Checks if a cullable object (mesh...) is in the camera frustum
  25423. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25424. * @param target The object to check
  25425. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25426. * @returns true if the object is in frustum otherwise false
  25427. */
  25428. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25429. /**
  25430. * Checks if a cullable object (mesh...) is in the camera frustum
  25431. * Unlike isInFrustum this cheks the full bounding box
  25432. * @param target The object to check
  25433. * @returns true if the object is in frustum otherwise false
  25434. */
  25435. isCompletelyInFrustum(target: ICullable): boolean;
  25436. /**
  25437. * Gets a ray in the forward direction from the camera.
  25438. * @param length Defines the length of the ray to create
  25439. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25440. * @param origin Defines the start point of the ray which defaults to the camera position
  25441. * @returns the forward ray
  25442. */
  25443. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25444. /**
  25445. * Releases resources associated with this node.
  25446. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25447. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25448. */
  25449. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25450. /** @hidden */
  25451. _isLeftCamera: boolean;
  25452. /**
  25453. * Gets the left camera of a rig setup in case of Rigged Camera
  25454. */
  25455. readonly isLeftCamera: boolean;
  25456. /** @hidden */
  25457. _isRightCamera: boolean;
  25458. /**
  25459. * Gets the right camera of a rig setup in case of Rigged Camera
  25460. */
  25461. readonly isRightCamera: boolean;
  25462. /**
  25463. * Gets the left camera of a rig setup in case of Rigged Camera
  25464. */
  25465. readonly leftCamera: Nullable<FreeCamera>;
  25466. /**
  25467. * Gets the right camera of a rig setup in case of Rigged Camera
  25468. */
  25469. readonly rightCamera: Nullable<FreeCamera>;
  25470. /**
  25471. * Gets the left camera target of a rig setup in case of Rigged Camera
  25472. * @returns the target position
  25473. */
  25474. getLeftTarget(): Nullable<Vector3>;
  25475. /**
  25476. * Gets the right camera target of a rig setup in case of Rigged Camera
  25477. * @returns the target position
  25478. */
  25479. getRightTarget(): Nullable<Vector3>;
  25480. /**
  25481. * @hidden
  25482. */
  25483. setCameraRigMode(mode: number, rigParams: any): void;
  25484. /** @hidden */
  25485. static _setStereoscopicRigMode(camera: Camera): void;
  25486. /** @hidden */
  25487. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25488. /** @hidden */
  25489. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25490. /** @hidden */
  25491. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25492. /** @hidden */
  25493. _getVRProjectionMatrix(): Matrix;
  25494. protected _updateCameraRotationMatrix(): void;
  25495. protected _updateWebVRCameraRotationMatrix(): void;
  25496. /**
  25497. * This function MUST be overwritten by the different WebVR cameras available.
  25498. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25499. * @hidden
  25500. */
  25501. _getWebVRProjectionMatrix(): Matrix;
  25502. /**
  25503. * This function MUST be overwritten by the different WebVR cameras available.
  25504. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25505. * @hidden
  25506. */
  25507. _getWebVRViewMatrix(): Matrix;
  25508. /** @hidden */
  25509. setCameraRigParameter(name: string, value: any): void;
  25510. /**
  25511. * needs to be overridden by children so sub has required properties to be copied
  25512. * @hidden
  25513. */
  25514. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25515. /**
  25516. * May need to be overridden by children
  25517. * @hidden
  25518. */
  25519. _updateRigCameras(): void;
  25520. /** @hidden */
  25521. _setupInputs(): void;
  25522. /**
  25523. * Serialiaze the camera setup to a json represention
  25524. * @returns the JSON representation
  25525. */
  25526. serialize(): any;
  25527. /**
  25528. * Clones the current camera.
  25529. * @param name The cloned camera name
  25530. * @returns the cloned camera
  25531. */
  25532. clone(name: string): Camera;
  25533. /**
  25534. * Gets the direction of the camera relative to a given local axis.
  25535. * @param localAxis Defines the reference axis to provide a relative direction.
  25536. * @return the direction
  25537. */
  25538. getDirection(localAxis: Vector3): Vector3;
  25539. /**
  25540. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25541. * @param localAxis Defines the reference axis to provide a relative direction.
  25542. * @param result Defines the vector to store the result in
  25543. */
  25544. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25545. /**
  25546. * Gets a camera constructor for a given camera type
  25547. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25548. * @param name The name of the camera the result will be able to instantiate
  25549. * @param scene The scene the result will construct the camera in
  25550. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25551. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25552. * @returns a factory method to construc the camera
  25553. */
  25554. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25555. /**
  25556. * Compute the world matrix of the camera.
  25557. * @returns the camera workd matrix
  25558. */
  25559. computeWorldMatrix(): Matrix;
  25560. /**
  25561. * Parse a JSON and creates the camera from the parsed information
  25562. * @param parsedCamera The JSON to parse
  25563. * @param scene The scene to instantiate the camera in
  25564. * @returns the newly constructed camera
  25565. */
  25566. static Parse(parsedCamera: any, scene: Scene): Camera;
  25567. }
  25568. }
  25569. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25570. import { Nullable } from "babylonjs/types";
  25571. import { Scene } from "babylonjs/scene";
  25572. import { Vector4 } from "babylonjs/Maths/math.vector";
  25573. import { Mesh } from "babylonjs/Meshes/mesh";
  25574. /**
  25575. * Class containing static functions to help procedurally build meshes
  25576. */
  25577. export class DiscBuilder {
  25578. /**
  25579. * Creates a plane polygonal mesh. By default, this is a disc
  25580. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25581. * * 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
  25582. * * 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
  25583. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25584. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25586. * @param name defines the name of the mesh
  25587. * @param options defines the options used to create the mesh
  25588. * @param scene defines the hosting scene
  25589. * @returns the plane polygonal mesh
  25590. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25591. */
  25592. static CreateDisc(name: string, options: {
  25593. radius?: number;
  25594. tessellation?: number;
  25595. arc?: number;
  25596. updatable?: boolean;
  25597. sideOrientation?: number;
  25598. frontUVs?: Vector4;
  25599. backUVs?: Vector4;
  25600. }, scene?: Nullable<Scene>): Mesh;
  25601. }
  25602. }
  25603. declare module "babylonjs/Particles/solidParticleSystem" {
  25604. import { Vector3 } from "babylonjs/Maths/math.vector";
  25605. import { Mesh } from "babylonjs/Meshes/mesh";
  25606. import { Scene, IDisposable } from "babylonjs/scene";
  25607. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25608. /**
  25609. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25610. *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.
  25611. * The SPS is also a particle system. It provides some methods to manage the particles.
  25612. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25613. *
  25614. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25615. */
  25616. export class SolidParticleSystem implements IDisposable {
  25617. /**
  25618. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25619. * Example : var p = SPS.particles[i];
  25620. */
  25621. particles: SolidParticle[];
  25622. /**
  25623. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25624. */
  25625. nbParticles: number;
  25626. /**
  25627. * If the particles must ever face the camera (default false). Useful for planar particles.
  25628. */
  25629. billboard: boolean;
  25630. /**
  25631. * Recompute normals when adding a shape
  25632. */
  25633. recomputeNormals: boolean;
  25634. /**
  25635. * This a counter ofr your own usage. It's not set by any SPS functions.
  25636. */
  25637. counter: number;
  25638. /**
  25639. * The SPS name. This name is also given to the underlying mesh.
  25640. */
  25641. name: string;
  25642. /**
  25643. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25644. */
  25645. mesh: Mesh;
  25646. /**
  25647. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25648. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25649. */
  25650. vars: any;
  25651. /**
  25652. * This array is populated when the SPS is set as 'pickable'.
  25653. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25654. * Each element of this array is an object `{idx: int, faceId: int}`.
  25655. * `idx` is the picked particle index in the `SPS.particles` array
  25656. * `faceId` is the picked face index counted within this particle.
  25657. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25658. */
  25659. pickedParticles: {
  25660. idx: number;
  25661. faceId: number;
  25662. }[];
  25663. /**
  25664. * This array is populated when `enableDepthSort` is set to true.
  25665. * Each element of this array is an instance of the class DepthSortedParticle.
  25666. */
  25667. depthSortedParticles: DepthSortedParticle[];
  25668. /**
  25669. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25670. * @hidden
  25671. */
  25672. _bSphereOnly: boolean;
  25673. /**
  25674. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25675. * @hidden
  25676. */
  25677. _bSphereRadiusFactor: number;
  25678. private _scene;
  25679. private _positions;
  25680. private _indices;
  25681. private _normals;
  25682. private _colors;
  25683. private _uvs;
  25684. private _indices32;
  25685. private _positions32;
  25686. private _normals32;
  25687. private _fixedNormal32;
  25688. private _colors32;
  25689. private _uvs32;
  25690. private _index;
  25691. private _updatable;
  25692. private _pickable;
  25693. private _isVisibilityBoxLocked;
  25694. private _alwaysVisible;
  25695. private _depthSort;
  25696. private _shapeCounter;
  25697. private _copy;
  25698. private _color;
  25699. private _computeParticleColor;
  25700. private _computeParticleTexture;
  25701. private _computeParticleRotation;
  25702. private _computeParticleVertex;
  25703. private _computeBoundingBox;
  25704. private _depthSortParticles;
  25705. private _camera;
  25706. private _mustUnrotateFixedNormals;
  25707. private _particlesIntersect;
  25708. private _needs32Bits;
  25709. /**
  25710. * Creates a SPS (Solid Particle System) object.
  25711. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25712. * @param scene (Scene) is the scene in which the SPS is added.
  25713. * @param options defines the options of the sps e.g.
  25714. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25715. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25716. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25717. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25718. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25719. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25720. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25721. */
  25722. constructor(name: string, scene: Scene, options?: {
  25723. updatable?: boolean;
  25724. isPickable?: boolean;
  25725. enableDepthSort?: boolean;
  25726. particleIntersection?: boolean;
  25727. boundingSphereOnly?: boolean;
  25728. bSphereRadiusFactor?: number;
  25729. });
  25730. /**
  25731. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25732. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25733. * @returns the created mesh
  25734. */
  25735. buildMesh(): Mesh;
  25736. /**
  25737. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25738. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25739. * Thus the particles generated from `digest()` have their property `position` set yet.
  25740. * @param mesh ( Mesh ) is the mesh to be digested
  25741. * @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
  25742. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25743. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25744. * @returns the current SPS
  25745. */
  25746. digest(mesh: Mesh, options?: {
  25747. facetNb?: number;
  25748. number?: number;
  25749. delta?: number;
  25750. }): SolidParticleSystem;
  25751. private _unrotateFixedNormals;
  25752. private _resetCopy;
  25753. private _meshBuilder;
  25754. private _posToShape;
  25755. private _uvsToShapeUV;
  25756. private _addParticle;
  25757. /**
  25758. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25759. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25760. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25761. * @param nb (positive integer) the number of particles to be created from this model
  25762. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25763. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25764. * @returns the number of shapes in the system
  25765. */
  25766. addShape(mesh: Mesh, nb: number, options?: {
  25767. positionFunction?: any;
  25768. vertexFunction?: any;
  25769. }): number;
  25770. private _rebuildParticle;
  25771. /**
  25772. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25773. * @returns the SPS.
  25774. */
  25775. rebuildMesh(): SolidParticleSystem;
  25776. /**
  25777. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25778. * This method calls `updateParticle()` for each particle of the SPS.
  25779. * For an animated SPS, it is usually called within the render loop.
  25780. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25781. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25782. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25783. * @returns the SPS.
  25784. */
  25785. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25786. /**
  25787. * Disposes the SPS.
  25788. */
  25789. dispose(): void;
  25790. /**
  25791. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25792. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25793. * @returns the SPS.
  25794. */
  25795. refreshVisibleSize(): SolidParticleSystem;
  25796. /**
  25797. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25798. * @param size the size (float) of the visibility box
  25799. * note : this doesn't lock the SPS mesh bounding box.
  25800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25801. */
  25802. setVisibilityBox(size: number): void;
  25803. /**
  25804. * Gets whether the SPS as always visible or not
  25805. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25806. */
  25807. /**
  25808. * Sets the SPS as always visible or not
  25809. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25810. */
  25811. isAlwaysVisible: boolean;
  25812. /**
  25813. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25814. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25815. */
  25816. /**
  25817. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25819. */
  25820. isVisibilityBoxLocked: boolean;
  25821. /**
  25822. * Tells to `setParticles()` to compute the particle rotations or not.
  25823. * Default value : true. The SPS is faster when it's set to false.
  25824. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25825. */
  25826. /**
  25827. * Gets if `setParticles()` computes the particle rotations or not.
  25828. * Default value : true. The SPS is faster when it's set to false.
  25829. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25830. */
  25831. computeParticleRotation: boolean;
  25832. /**
  25833. * Tells to `setParticles()` to compute the particle colors or not.
  25834. * Default value : true. The SPS is faster when it's set to false.
  25835. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25836. */
  25837. /**
  25838. * Gets if `setParticles()` computes the particle colors or not.
  25839. * Default value : true. The SPS is faster when it's set to false.
  25840. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25841. */
  25842. computeParticleColor: boolean;
  25843. /**
  25844. * Gets if `setParticles()` computes the particle textures or not.
  25845. * Default value : true. The SPS is faster when it's set to false.
  25846. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25847. */
  25848. computeParticleTexture: boolean;
  25849. /**
  25850. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  25851. * Default value : false. The SPS is faster when it's set to false.
  25852. * Note : the particle custom vertex positions aren't stored values.
  25853. */
  25854. /**
  25855. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25856. * Default value : false. The SPS is faster when it's set to false.
  25857. * Note : the particle custom vertex positions aren't stored values.
  25858. */
  25859. computeParticleVertex: boolean;
  25860. /**
  25861. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25862. */
  25863. /**
  25864. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25865. */
  25866. computeBoundingBox: boolean;
  25867. /**
  25868. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  25869. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25870. * Default : `true`
  25871. */
  25872. /**
  25873. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25874. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25875. * Default : `true`
  25876. */
  25877. depthSortParticles: boolean;
  25878. /**
  25879. * This function does nothing. It may be overwritten to set all the particle first values.
  25880. * The SPS doesn't call this function, you may have to call it by your own.
  25881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25882. */
  25883. initParticles(): void;
  25884. /**
  25885. * This function does nothing. It may be overwritten to recycle a particle.
  25886. * The SPS doesn't call this function, you may have to call it by your own.
  25887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25888. * @param particle The particle to recycle
  25889. * @returns the recycled particle
  25890. */
  25891. recycleParticle(particle: SolidParticle): SolidParticle;
  25892. /**
  25893. * Updates a particle : this function should be overwritten by the user.
  25894. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25895. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25896. * @example : just set a particle position or velocity and recycle conditions
  25897. * @param particle The particle to update
  25898. * @returns the updated particle
  25899. */
  25900. updateParticle(particle: SolidParticle): SolidParticle;
  25901. /**
  25902. * Updates a vertex of a particle : it can be overwritten by the user.
  25903. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25904. * @param particle the current particle
  25905. * @param vertex the current index of the current particle
  25906. * @param pt the index of the current vertex in the particle shape
  25907. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25908. * @example : just set a vertex particle position
  25909. * @returns the updated vertex
  25910. */
  25911. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25912. /**
  25913. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25914. * This does nothing and may be overwritten by the user.
  25915. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25916. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25917. * @param update the boolean update value actually passed to setParticles()
  25918. */
  25919. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25920. /**
  25921. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25922. * This will be passed three parameters.
  25923. * This does nothing and may be overwritten by the user.
  25924. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25925. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25926. * @param update the boolean update value actually passed to setParticles()
  25927. */
  25928. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25929. }
  25930. }
  25931. declare module "babylonjs/Particles/solidParticle" {
  25932. import { Nullable } from "babylonjs/types";
  25933. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25934. import { Color4 } from "babylonjs/Maths/math.color";
  25935. import { Mesh } from "babylonjs/Meshes/mesh";
  25936. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25937. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25938. import { Plane } from "babylonjs/Maths/math.plane";
  25939. /**
  25940. * Represents one particle of a solid particle system.
  25941. */
  25942. export class SolidParticle {
  25943. /**
  25944. * particle global index
  25945. */
  25946. idx: number;
  25947. /**
  25948. * The color of the particle
  25949. */
  25950. color: Nullable<Color4>;
  25951. /**
  25952. * The world space position of the particle.
  25953. */
  25954. position: Vector3;
  25955. /**
  25956. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25957. */
  25958. rotation: Vector3;
  25959. /**
  25960. * The world space rotation quaternion of the particle.
  25961. */
  25962. rotationQuaternion: Nullable<Quaternion>;
  25963. /**
  25964. * The scaling of the particle.
  25965. */
  25966. scaling: Vector3;
  25967. /**
  25968. * The uvs of the particle.
  25969. */
  25970. uvs: Vector4;
  25971. /**
  25972. * The current speed of the particle.
  25973. */
  25974. velocity: Vector3;
  25975. /**
  25976. * The pivot point in the particle local space.
  25977. */
  25978. pivot: Vector3;
  25979. /**
  25980. * Must the particle be translated from its pivot point in its local space ?
  25981. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25982. * Default : false
  25983. */
  25984. translateFromPivot: boolean;
  25985. /**
  25986. * Is the particle active or not ?
  25987. */
  25988. alive: boolean;
  25989. /**
  25990. * Is the particle visible or not ?
  25991. */
  25992. isVisible: boolean;
  25993. /**
  25994. * Index of this particle in the global "positions" array (Internal use)
  25995. * @hidden
  25996. */
  25997. _pos: number;
  25998. /**
  25999. * @hidden Index of this particle in the global "indices" array (Internal use)
  26000. */
  26001. _ind: number;
  26002. /**
  26003. * @hidden ModelShape of this particle (Internal use)
  26004. */
  26005. _model: ModelShape;
  26006. /**
  26007. * ModelShape id of this particle
  26008. */
  26009. shapeId: number;
  26010. /**
  26011. * Index of the particle in its shape id (Internal use)
  26012. */
  26013. idxInShape: number;
  26014. /**
  26015. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26016. */
  26017. _modelBoundingInfo: BoundingInfo;
  26018. /**
  26019. * @hidden Particle BoundingInfo object (Internal use)
  26020. */
  26021. _boundingInfo: BoundingInfo;
  26022. /**
  26023. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26024. */
  26025. _sps: SolidParticleSystem;
  26026. /**
  26027. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26028. */
  26029. _stillInvisible: boolean;
  26030. /**
  26031. * @hidden Last computed particle rotation matrix
  26032. */
  26033. _rotationMatrix: number[];
  26034. /**
  26035. * Parent particle Id, if any.
  26036. * Default null.
  26037. */
  26038. parentId: Nullable<number>;
  26039. /**
  26040. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26041. * The possible values are :
  26042. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26043. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26045. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26046. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26047. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26048. * */
  26049. cullingStrategy: number;
  26050. /**
  26051. * @hidden Internal global position in the SPS.
  26052. */
  26053. _globalPosition: Vector3;
  26054. /**
  26055. * Creates a Solid Particle object.
  26056. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26057. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26058. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26059. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26060. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26061. * @param shapeId (integer) is the model shape identifier in the SPS.
  26062. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26063. * @param sps defines the sps it is associated to
  26064. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26065. */
  26066. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26067. /**
  26068. * Legacy support, changed scale to scaling
  26069. */
  26070. /**
  26071. * Legacy support, changed scale to scaling
  26072. */
  26073. scale: Vector3;
  26074. /**
  26075. * Legacy support, changed quaternion to rotationQuaternion
  26076. */
  26077. /**
  26078. * Legacy support, changed quaternion to rotationQuaternion
  26079. */
  26080. quaternion: Nullable<Quaternion>;
  26081. /**
  26082. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26083. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26084. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26085. * @returns true if it intersects
  26086. */
  26087. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26088. /**
  26089. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26090. * A particle is in the frustum if its bounding box intersects the frustum
  26091. * @param frustumPlanes defines the frustum to test
  26092. * @returns true if the particle is in the frustum planes
  26093. */
  26094. isInFrustum(frustumPlanes: Plane[]): boolean;
  26095. /**
  26096. * get the rotation matrix of the particle
  26097. * @hidden
  26098. */
  26099. getRotationMatrix(m: Matrix): void;
  26100. }
  26101. /**
  26102. * Represents the shape of the model used by one particle of a solid particle system.
  26103. * SPS internal tool, don't use it manually.
  26104. */
  26105. export class ModelShape {
  26106. /**
  26107. * The shape id
  26108. * @hidden
  26109. */
  26110. shapeID: number;
  26111. /**
  26112. * flat array of model positions (internal use)
  26113. * @hidden
  26114. */
  26115. _shape: Vector3[];
  26116. /**
  26117. * flat array of model UVs (internal use)
  26118. * @hidden
  26119. */
  26120. _shapeUV: number[];
  26121. /**
  26122. * length of the shape in the model indices array (internal use)
  26123. * @hidden
  26124. */
  26125. _indicesLength: number;
  26126. /**
  26127. * Custom position function (internal use)
  26128. * @hidden
  26129. */
  26130. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26131. /**
  26132. * Custom vertex function (internal use)
  26133. * @hidden
  26134. */
  26135. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26136. /**
  26137. * 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.
  26138. * SPS internal tool, don't use it manually.
  26139. * @hidden
  26140. */
  26141. 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>);
  26142. }
  26143. /**
  26144. * Represents a Depth Sorted Particle in the solid particle system.
  26145. */
  26146. export class DepthSortedParticle {
  26147. /**
  26148. * Index of the particle in the "indices" array
  26149. */
  26150. ind: number;
  26151. /**
  26152. * Length of the particle shape in the "indices" array
  26153. */
  26154. indicesLength: number;
  26155. /**
  26156. * Squared distance from the particle to the camera
  26157. */
  26158. sqDistance: number;
  26159. }
  26160. }
  26161. declare module "babylonjs/Collisions/meshCollisionData" {
  26162. import { Collider } from "babylonjs/Collisions/collider";
  26163. import { Vector3 } from "babylonjs/Maths/math.vector";
  26164. import { Nullable } from "babylonjs/types";
  26165. import { Observer } from "babylonjs/Misc/observable";
  26166. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26167. /**
  26168. * @hidden
  26169. */
  26170. export class _MeshCollisionData {
  26171. _checkCollisions: boolean;
  26172. _collisionMask: number;
  26173. _collisionGroup: number;
  26174. _collider: Nullable<Collider>;
  26175. _oldPositionForCollisions: Vector3;
  26176. _diffPositionForCollisions: Vector3;
  26177. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26178. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26179. }
  26180. }
  26181. declare module "babylonjs/Meshes/abstractMesh" {
  26182. import { Observable } from "babylonjs/Misc/observable";
  26183. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26184. import { Camera } from "babylonjs/Cameras/camera";
  26185. import { Scene, IDisposable } from "babylonjs/scene";
  26186. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26187. import { Node } from "babylonjs/node";
  26188. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26189. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26191. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26192. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26193. import { Material } from "babylonjs/Materials/material";
  26194. import { Light } from "babylonjs/Lights/light";
  26195. import { Skeleton } from "babylonjs/Bones/skeleton";
  26196. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26197. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26198. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26199. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26200. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26201. import { Plane } from "babylonjs/Maths/math.plane";
  26202. import { Ray } from "babylonjs/Culling/ray";
  26203. import { Collider } from "babylonjs/Collisions/collider";
  26204. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26205. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26206. /** @hidden */
  26207. class _FacetDataStorage {
  26208. facetPositions: Vector3[];
  26209. facetNormals: Vector3[];
  26210. facetPartitioning: number[][];
  26211. facetNb: number;
  26212. partitioningSubdivisions: number;
  26213. partitioningBBoxRatio: number;
  26214. facetDataEnabled: boolean;
  26215. facetParameters: any;
  26216. bbSize: Vector3;
  26217. subDiv: {
  26218. max: number;
  26219. X: number;
  26220. Y: number;
  26221. Z: number;
  26222. };
  26223. facetDepthSort: boolean;
  26224. facetDepthSortEnabled: boolean;
  26225. depthSortedIndices: IndicesArray;
  26226. depthSortedFacets: {
  26227. ind: number;
  26228. sqDistance: number;
  26229. }[];
  26230. facetDepthSortFunction: (f1: {
  26231. ind: number;
  26232. sqDistance: number;
  26233. }, f2: {
  26234. ind: number;
  26235. sqDistance: number;
  26236. }) => number;
  26237. facetDepthSortFrom: Vector3;
  26238. facetDepthSortOrigin: Vector3;
  26239. invertedMatrix: Matrix;
  26240. }
  26241. /**
  26242. * @hidden
  26243. **/
  26244. class _InternalAbstractMeshDataInfo {
  26245. _hasVertexAlpha: boolean;
  26246. _useVertexColors: boolean;
  26247. _numBoneInfluencers: number;
  26248. _applyFog: boolean;
  26249. _receiveShadows: boolean;
  26250. _facetData: _FacetDataStorage;
  26251. _visibility: number;
  26252. _skeleton: Nullable<Skeleton>;
  26253. _layerMask: number;
  26254. _computeBonesUsingShaders: boolean;
  26255. _isActive: boolean;
  26256. _onlyForInstances: boolean;
  26257. _isActiveIntermediate: boolean;
  26258. _onlyForInstancesIntermediate: boolean;
  26259. }
  26260. /**
  26261. * Class used to store all common mesh properties
  26262. */
  26263. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26264. /** No occlusion */
  26265. static OCCLUSION_TYPE_NONE: number;
  26266. /** Occlusion set to optimisitic */
  26267. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26268. /** Occlusion set to strict */
  26269. static OCCLUSION_TYPE_STRICT: number;
  26270. /** Use an accurante occlusion algorithm */
  26271. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26272. /** Use a conservative occlusion algorithm */
  26273. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26274. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26275. * Test order :
  26276. * Is the bounding sphere outside the frustum ?
  26277. * If not, are the bounding box vertices outside the frustum ?
  26278. * It not, then the cullable object is in the frustum.
  26279. */
  26280. static readonly CULLINGSTRATEGY_STANDARD: number;
  26281. /** Culling strategy : Bounding Sphere Only.
  26282. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26283. * It's also less accurate than the standard because some not visible objects can still be selected.
  26284. * Test : is the bounding sphere outside the frustum ?
  26285. * If not, then the cullable object is in the frustum.
  26286. */
  26287. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26288. /** Culling strategy : Optimistic Inclusion.
  26289. * This in an inclusion test first, then the standard exclusion test.
  26290. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26291. * 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.
  26292. * Anyway, it's as accurate as the standard strategy.
  26293. * Test :
  26294. * Is the cullable object bounding sphere center in the frustum ?
  26295. * If not, apply the default culling strategy.
  26296. */
  26297. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26298. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26299. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26300. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26301. * 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.
  26302. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26303. * Test :
  26304. * Is the cullable object bounding sphere center in the frustum ?
  26305. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26306. */
  26307. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26308. /**
  26309. * No billboard
  26310. */
  26311. static readonly BILLBOARDMODE_NONE: number;
  26312. /** Billboard on X axis */
  26313. static readonly BILLBOARDMODE_X: number;
  26314. /** Billboard on Y axis */
  26315. static readonly BILLBOARDMODE_Y: number;
  26316. /** Billboard on Z axis */
  26317. static readonly BILLBOARDMODE_Z: number;
  26318. /** Billboard on all axes */
  26319. static readonly BILLBOARDMODE_ALL: number;
  26320. /** @hidden */
  26321. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26322. /**
  26323. * The culling strategy to use to check whether the mesh must be rendered or not.
  26324. * This value can be changed at any time and will be used on the next render mesh selection.
  26325. * The possible values are :
  26326. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26327. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26328. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26329. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26330. * Please read each static variable documentation to get details about the culling process.
  26331. * */
  26332. cullingStrategy: number;
  26333. /**
  26334. * Gets the number of facets in the mesh
  26335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26336. */
  26337. readonly facetNb: number;
  26338. /**
  26339. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26341. */
  26342. partitioningSubdivisions: number;
  26343. /**
  26344. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26345. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26347. */
  26348. partitioningBBoxRatio: number;
  26349. /**
  26350. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26351. * Works only for updatable meshes.
  26352. * Doesn't work with multi-materials
  26353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26354. */
  26355. mustDepthSortFacets: boolean;
  26356. /**
  26357. * The location (Vector3) where the facet depth sort must be computed from.
  26358. * By default, the active camera position.
  26359. * Used only when facet depth sort is enabled
  26360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26361. */
  26362. facetDepthSortFrom: Vector3;
  26363. /**
  26364. * gets a boolean indicating if facetData is enabled
  26365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26366. */
  26367. readonly isFacetDataEnabled: boolean;
  26368. /** @hidden */
  26369. _updateNonUniformScalingState(value: boolean): boolean;
  26370. /**
  26371. * An event triggered when this mesh collides with another one
  26372. */
  26373. onCollideObservable: Observable<AbstractMesh>;
  26374. /** Set a function to call when this mesh collides with another one */
  26375. onCollide: () => void;
  26376. /**
  26377. * An event triggered when the collision's position changes
  26378. */
  26379. onCollisionPositionChangeObservable: Observable<Vector3>;
  26380. /** Set a function to call when the collision's position changes */
  26381. onCollisionPositionChange: () => void;
  26382. /**
  26383. * An event triggered when material is changed
  26384. */
  26385. onMaterialChangedObservable: Observable<AbstractMesh>;
  26386. /**
  26387. * Gets or sets the orientation for POV movement & rotation
  26388. */
  26389. definedFacingForward: boolean;
  26390. /** @hidden */
  26391. _occlusionQuery: Nullable<WebGLQuery>;
  26392. /** @hidden */
  26393. _renderingGroup: Nullable<RenderingGroup>;
  26394. /**
  26395. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26396. */
  26397. /**
  26398. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26399. */
  26400. visibility: number;
  26401. /** Gets or sets the alpha index used to sort transparent meshes
  26402. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26403. */
  26404. alphaIndex: number;
  26405. /**
  26406. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26407. */
  26408. isVisible: boolean;
  26409. /**
  26410. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26411. */
  26412. isPickable: boolean;
  26413. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26414. showSubMeshesBoundingBox: boolean;
  26415. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26416. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26417. */
  26418. isBlocker: boolean;
  26419. /**
  26420. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26421. */
  26422. enablePointerMoveEvents: boolean;
  26423. /**
  26424. * Specifies the rendering group id for this mesh (0 by default)
  26425. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26426. */
  26427. renderingGroupId: number;
  26428. private _material;
  26429. /** Gets or sets current material */
  26430. material: Nullable<Material>;
  26431. /**
  26432. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26433. * @see http://doc.babylonjs.com/babylon101/shadows
  26434. */
  26435. receiveShadows: boolean;
  26436. /** Defines color to use when rendering outline */
  26437. outlineColor: Color3;
  26438. /** Define width to use when rendering outline */
  26439. outlineWidth: number;
  26440. /** Defines color to use when rendering overlay */
  26441. overlayColor: Color3;
  26442. /** Defines alpha to use when rendering overlay */
  26443. overlayAlpha: number;
  26444. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26445. hasVertexAlpha: boolean;
  26446. /** 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) */
  26447. useVertexColors: boolean;
  26448. /**
  26449. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26450. */
  26451. computeBonesUsingShaders: boolean;
  26452. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26453. numBoneInfluencers: number;
  26454. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26455. applyFog: boolean;
  26456. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26457. useOctreeForRenderingSelection: boolean;
  26458. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26459. useOctreeForPicking: boolean;
  26460. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26461. useOctreeForCollisions: boolean;
  26462. /**
  26463. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26464. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26465. */
  26466. layerMask: number;
  26467. /**
  26468. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26469. */
  26470. alwaysSelectAsActiveMesh: boolean;
  26471. /**
  26472. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26473. */
  26474. doNotSyncBoundingInfo: boolean;
  26475. /**
  26476. * Gets or sets the current action manager
  26477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26478. */
  26479. actionManager: Nullable<AbstractActionManager>;
  26480. private _meshCollisionData;
  26481. /**
  26482. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26484. */
  26485. ellipsoid: Vector3;
  26486. /**
  26487. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26489. */
  26490. ellipsoidOffset: Vector3;
  26491. /**
  26492. * Gets or sets a collision mask used to mask collisions (default is -1).
  26493. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26494. */
  26495. collisionMask: number;
  26496. /**
  26497. * Gets or sets the current collision group mask (-1 by default).
  26498. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26499. */
  26500. collisionGroup: number;
  26501. /**
  26502. * Defines edge width used when edgesRenderer is enabled
  26503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26504. */
  26505. edgesWidth: number;
  26506. /**
  26507. * Defines edge color used when edgesRenderer is enabled
  26508. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26509. */
  26510. edgesColor: Color4;
  26511. /** @hidden */
  26512. _edgesRenderer: Nullable<IEdgesRenderer>;
  26513. /** @hidden */
  26514. _masterMesh: Nullable<AbstractMesh>;
  26515. /** @hidden */
  26516. _boundingInfo: Nullable<BoundingInfo>;
  26517. /** @hidden */
  26518. _renderId: number;
  26519. /**
  26520. * Gets or sets the list of subMeshes
  26521. * @see http://doc.babylonjs.com/how_to/multi_materials
  26522. */
  26523. subMeshes: SubMesh[];
  26524. /** @hidden */
  26525. _intersectionsInProgress: AbstractMesh[];
  26526. /** @hidden */
  26527. _unIndexed: boolean;
  26528. /** @hidden */
  26529. _lightSources: Light[];
  26530. /** Gets the list of lights affecting that mesh */
  26531. readonly lightSources: Light[];
  26532. /** @hidden */
  26533. readonly _positions: Nullable<Vector3[]>;
  26534. /** @hidden */
  26535. _waitingData: {
  26536. lods: Nullable<any>;
  26537. actions: Nullable<any>;
  26538. freezeWorldMatrix: Nullable<boolean>;
  26539. };
  26540. /** @hidden */
  26541. _bonesTransformMatrices: Nullable<Float32Array>;
  26542. /** @hidden */
  26543. _transformMatrixTexture: Nullable<RawTexture>;
  26544. /**
  26545. * Gets or sets a skeleton to apply skining transformations
  26546. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26547. */
  26548. skeleton: Nullable<Skeleton>;
  26549. /**
  26550. * An event triggered when the mesh is rebuilt.
  26551. */
  26552. onRebuildObservable: Observable<AbstractMesh>;
  26553. /**
  26554. * Creates a new AbstractMesh
  26555. * @param name defines the name of the mesh
  26556. * @param scene defines the hosting scene
  26557. */
  26558. constructor(name: string, scene?: Nullable<Scene>);
  26559. /**
  26560. * Returns the string "AbstractMesh"
  26561. * @returns "AbstractMesh"
  26562. */
  26563. getClassName(): string;
  26564. /**
  26565. * Gets a string representation of the current mesh
  26566. * @param fullDetails defines a boolean indicating if full details must be included
  26567. * @returns a string representation of the current mesh
  26568. */
  26569. toString(fullDetails?: boolean): string;
  26570. /**
  26571. * @hidden
  26572. */
  26573. protected _getEffectiveParent(): Nullable<Node>;
  26574. /** @hidden */
  26575. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26576. /** @hidden */
  26577. _rebuild(): void;
  26578. /** @hidden */
  26579. _resyncLightSources(): void;
  26580. /** @hidden */
  26581. _resyncLighSource(light: Light): void;
  26582. /** @hidden */
  26583. _unBindEffect(): void;
  26584. /** @hidden */
  26585. _removeLightSource(light: Light): void;
  26586. private _markSubMeshesAsDirty;
  26587. /** @hidden */
  26588. _markSubMeshesAsLightDirty(): void;
  26589. /** @hidden */
  26590. _markSubMeshesAsAttributesDirty(): void;
  26591. /** @hidden */
  26592. _markSubMeshesAsMiscDirty(): void;
  26593. /**
  26594. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26595. */
  26596. scaling: Vector3;
  26597. /**
  26598. * Returns true if the mesh is blocked. Implemented by child classes
  26599. */
  26600. readonly isBlocked: boolean;
  26601. /**
  26602. * Returns the mesh itself by default. Implemented by child classes
  26603. * @param camera defines the camera to use to pick the right LOD level
  26604. * @returns the currentAbstractMesh
  26605. */
  26606. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26607. /**
  26608. * Returns 0 by default. Implemented by child classes
  26609. * @returns an integer
  26610. */
  26611. getTotalVertices(): number;
  26612. /**
  26613. * Returns a positive integer : the total number of indices in this mesh geometry.
  26614. * @returns the numner of indices or zero if the mesh has no geometry.
  26615. */
  26616. getTotalIndices(): number;
  26617. /**
  26618. * Returns null by default. Implemented by child classes
  26619. * @returns null
  26620. */
  26621. getIndices(): Nullable<IndicesArray>;
  26622. /**
  26623. * Returns the array of the requested vertex data kind. Implemented by child classes
  26624. * @param kind defines the vertex data kind to use
  26625. * @returns null
  26626. */
  26627. getVerticesData(kind: string): Nullable<FloatArray>;
  26628. /**
  26629. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26630. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26631. * Note that a new underlying VertexBuffer object is created each call.
  26632. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26633. * @param kind defines vertex data kind:
  26634. * * VertexBuffer.PositionKind
  26635. * * VertexBuffer.UVKind
  26636. * * VertexBuffer.UV2Kind
  26637. * * VertexBuffer.UV3Kind
  26638. * * VertexBuffer.UV4Kind
  26639. * * VertexBuffer.UV5Kind
  26640. * * VertexBuffer.UV6Kind
  26641. * * VertexBuffer.ColorKind
  26642. * * VertexBuffer.MatricesIndicesKind
  26643. * * VertexBuffer.MatricesIndicesExtraKind
  26644. * * VertexBuffer.MatricesWeightsKind
  26645. * * VertexBuffer.MatricesWeightsExtraKind
  26646. * @param data defines the data source
  26647. * @param updatable defines if the data must be flagged as updatable (or static)
  26648. * @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
  26649. * @returns the current mesh
  26650. */
  26651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26652. /**
  26653. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26654. * If the mesh has no geometry, it is simply returned as it is.
  26655. * @param kind defines vertex data kind:
  26656. * * VertexBuffer.PositionKind
  26657. * * VertexBuffer.UVKind
  26658. * * VertexBuffer.UV2Kind
  26659. * * VertexBuffer.UV3Kind
  26660. * * VertexBuffer.UV4Kind
  26661. * * VertexBuffer.UV5Kind
  26662. * * VertexBuffer.UV6Kind
  26663. * * VertexBuffer.ColorKind
  26664. * * VertexBuffer.MatricesIndicesKind
  26665. * * VertexBuffer.MatricesIndicesExtraKind
  26666. * * VertexBuffer.MatricesWeightsKind
  26667. * * VertexBuffer.MatricesWeightsExtraKind
  26668. * @param data defines the data source
  26669. * @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
  26670. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26671. * @returns the current mesh
  26672. */
  26673. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26674. /**
  26675. * Sets the mesh indices,
  26676. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26677. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26678. * @param totalVertices Defines the total number of vertices
  26679. * @returns the current mesh
  26680. */
  26681. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26682. /**
  26683. * Gets a boolean indicating if specific vertex data is present
  26684. * @param kind defines the vertex data kind to use
  26685. * @returns true is data kind is present
  26686. */
  26687. isVerticesDataPresent(kind: string): boolean;
  26688. /**
  26689. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26690. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26691. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26692. * @returns a BoundingInfo
  26693. */
  26694. getBoundingInfo(): BoundingInfo;
  26695. /**
  26696. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26697. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26698. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26699. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26700. * @returns the current mesh
  26701. */
  26702. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26703. /**
  26704. * Overwrite the current bounding info
  26705. * @param boundingInfo defines the new bounding info
  26706. * @returns the current mesh
  26707. */
  26708. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26709. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26710. readonly useBones: boolean;
  26711. /** @hidden */
  26712. _preActivate(): void;
  26713. /** @hidden */
  26714. _preActivateForIntermediateRendering(renderId: number): void;
  26715. /** @hidden */
  26716. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26717. /** @hidden */
  26718. _postActivate(): void;
  26719. /** @hidden */
  26720. _freeze(): void;
  26721. /** @hidden */
  26722. _unFreeze(): void;
  26723. /**
  26724. * Gets the current world matrix
  26725. * @returns a Matrix
  26726. */
  26727. getWorldMatrix(): Matrix;
  26728. /** @hidden */
  26729. _getWorldMatrixDeterminant(): number;
  26730. /**
  26731. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26732. */
  26733. readonly isAnInstance: boolean;
  26734. /**
  26735. * Perform relative position change from the point of view of behind the front of the mesh.
  26736. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26737. * Supports definition of mesh facing forward or backward
  26738. * @param amountRight defines the distance on the right axis
  26739. * @param amountUp defines the distance on the up axis
  26740. * @param amountForward defines the distance on the forward axis
  26741. * @returns the current mesh
  26742. */
  26743. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26744. /**
  26745. * Calculate relative position change from the point of view of behind the front of the mesh.
  26746. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26747. * Supports definition of mesh facing forward or backward
  26748. * @param amountRight defines the distance on the right axis
  26749. * @param amountUp defines the distance on the up axis
  26750. * @param amountForward defines the distance on the forward axis
  26751. * @returns the new displacement vector
  26752. */
  26753. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26754. /**
  26755. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26756. * Supports definition of mesh facing forward or backward
  26757. * @param flipBack defines the flip
  26758. * @param twirlClockwise defines the twirl
  26759. * @param tiltRight defines the tilt
  26760. * @returns the current mesh
  26761. */
  26762. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26763. /**
  26764. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26765. * Supports definition of mesh facing forward or backward.
  26766. * @param flipBack defines the flip
  26767. * @param twirlClockwise defines the twirl
  26768. * @param tiltRight defines the tilt
  26769. * @returns the new rotation vector
  26770. */
  26771. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26772. /**
  26773. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26774. * This means the mesh underlying bounding box and sphere are recomputed.
  26775. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26776. * @returns the current mesh
  26777. */
  26778. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26779. /** @hidden */
  26780. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26781. /** @hidden */
  26782. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26783. /** @hidden */
  26784. _updateBoundingInfo(): AbstractMesh;
  26785. /** @hidden */
  26786. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26787. /** @hidden */
  26788. protected _afterComputeWorldMatrix(): void;
  26789. /** @hidden */
  26790. readonly _effectiveMesh: AbstractMesh;
  26791. /**
  26792. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26793. * A mesh is in the frustum if its bounding box intersects the frustum
  26794. * @param frustumPlanes defines the frustum to test
  26795. * @returns true if the mesh is in the frustum planes
  26796. */
  26797. isInFrustum(frustumPlanes: Plane[]): boolean;
  26798. /**
  26799. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26800. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26801. * @param frustumPlanes defines the frustum to test
  26802. * @returns true if the mesh is completely in the frustum planes
  26803. */
  26804. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26805. /**
  26806. * True if the mesh intersects another mesh or a SolidParticle object
  26807. * @param mesh defines a target mesh or SolidParticle to test
  26808. * @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)
  26809. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26810. * @returns true if there is an intersection
  26811. */
  26812. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26813. /**
  26814. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26815. * @param point defines the point to test
  26816. * @returns true if there is an intersection
  26817. */
  26818. intersectsPoint(point: Vector3): boolean;
  26819. /**
  26820. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26822. */
  26823. checkCollisions: boolean;
  26824. /**
  26825. * Gets Collider object used to compute collisions (not physics)
  26826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26827. */
  26828. readonly collider: Nullable<Collider>;
  26829. /**
  26830. * Move the mesh using collision engine
  26831. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26832. * @param displacement defines the requested displacement vector
  26833. * @returns the current mesh
  26834. */
  26835. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26836. private _onCollisionPositionChange;
  26837. /** @hidden */
  26838. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26839. /** @hidden */
  26840. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26841. /** @hidden */
  26842. _checkCollision(collider: Collider): AbstractMesh;
  26843. /** @hidden */
  26844. _generatePointsArray(): boolean;
  26845. /**
  26846. * Checks if the passed Ray intersects with the mesh
  26847. * @param ray defines the ray to use
  26848. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26849. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26850. * @returns the picking info
  26851. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26852. */
  26853. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26854. /**
  26855. * Clones the current mesh
  26856. * @param name defines the mesh name
  26857. * @param newParent defines the new mesh parent
  26858. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26859. * @returns the new mesh
  26860. */
  26861. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26862. /**
  26863. * Disposes all the submeshes of the current meshnp
  26864. * @returns the current mesh
  26865. */
  26866. releaseSubMeshes(): AbstractMesh;
  26867. /**
  26868. * Releases resources associated with this abstract mesh.
  26869. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26870. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26871. */
  26872. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26873. /**
  26874. * Adds the passed mesh as a child to the current mesh
  26875. * @param mesh defines the child mesh
  26876. * @returns the current mesh
  26877. */
  26878. addChild(mesh: AbstractMesh): AbstractMesh;
  26879. /**
  26880. * Removes the passed mesh from the current mesh children list
  26881. * @param mesh defines the child mesh
  26882. * @returns the current mesh
  26883. */
  26884. removeChild(mesh: AbstractMesh): AbstractMesh;
  26885. /** @hidden */
  26886. private _initFacetData;
  26887. /**
  26888. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26889. * This method can be called within the render loop.
  26890. * 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
  26891. * @returns the current mesh
  26892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26893. */
  26894. updateFacetData(): AbstractMesh;
  26895. /**
  26896. * Returns the facetLocalNormals array.
  26897. * The normals are expressed in the mesh local spac
  26898. * @returns an array of Vector3
  26899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26900. */
  26901. getFacetLocalNormals(): Vector3[];
  26902. /**
  26903. * Returns the facetLocalPositions array.
  26904. * The facet positions are expressed in the mesh local space
  26905. * @returns an array of Vector3
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26907. */
  26908. getFacetLocalPositions(): Vector3[];
  26909. /**
  26910. * Returns the facetLocalPartioning array
  26911. * @returns an array of array of numbers
  26912. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26913. */
  26914. getFacetLocalPartitioning(): number[][];
  26915. /**
  26916. * Returns the i-th facet position in the world system.
  26917. * This method allocates a new Vector3 per call
  26918. * @param i defines the facet index
  26919. * @returns a new Vector3
  26920. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26921. */
  26922. getFacetPosition(i: number): Vector3;
  26923. /**
  26924. * Sets the reference Vector3 with the i-th facet position in the world system
  26925. * @param i defines the facet index
  26926. * @param ref defines the target vector
  26927. * @returns the current mesh
  26928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26929. */
  26930. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26931. /**
  26932. * Returns the i-th facet normal in the world system.
  26933. * This method allocates a new Vector3 per call
  26934. * @param i defines the facet index
  26935. * @returns a new Vector3
  26936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26937. */
  26938. getFacetNormal(i: number): Vector3;
  26939. /**
  26940. * Sets the reference Vector3 with the i-th facet normal in the world system
  26941. * @param i defines the facet index
  26942. * @param ref defines the target vector
  26943. * @returns the current mesh
  26944. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26945. */
  26946. getFacetNormalToRef(i: number, ref: Vector3): this;
  26947. /**
  26948. * 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)
  26949. * @param x defines x coordinate
  26950. * @param y defines y coordinate
  26951. * @param z defines z coordinate
  26952. * @returns the array of facet indexes
  26953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26954. */
  26955. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26956. /**
  26957. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26958. * @param projected sets as the (x,y,z) world projection on the facet
  26959. * @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
  26960. * @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
  26961. * @param x defines x coordinate
  26962. * @param y defines y coordinate
  26963. * @param z defines z coordinate
  26964. * @returns the face index if found (or null instead)
  26965. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26966. */
  26967. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26968. /**
  26969. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26970. * @param projected sets as the (x,y,z) local projection on the facet
  26971. * @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
  26972. * @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
  26973. * @param x defines x coordinate
  26974. * @param y defines y coordinate
  26975. * @param z defines z coordinate
  26976. * @returns the face index if found (or null instead)
  26977. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26978. */
  26979. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26980. /**
  26981. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26982. * @returns the parameters
  26983. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26984. */
  26985. getFacetDataParameters(): any;
  26986. /**
  26987. * Disables the feature FacetData and frees the related memory
  26988. * @returns the current mesh
  26989. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26990. */
  26991. disableFacetData(): AbstractMesh;
  26992. /**
  26993. * Updates the AbstractMesh indices array
  26994. * @param indices defines the data source
  26995. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26996. * @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)
  26997. * @returns the current mesh
  26998. */
  26999. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27000. /**
  27001. * Creates new normals data for the mesh
  27002. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27003. * @returns the current mesh
  27004. */
  27005. createNormals(updatable: boolean): AbstractMesh;
  27006. /**
  27007. * Align the mesh with a normal
  27008. * @param normal defines the normal to use
  27009. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27010. * @returns the current mesh
  27011. */
  27012. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27013. /** @hidden */
  27014. _checkOcclusionQuery(): boolean;
  27015. /**
  27016. * Disables the mesh edge rendering mode
  27017. * @returns the currentAbstractMesh
  27018. */
  27019. disableEdgesRendering(): AbstractMesh;
  27020. /**
  27021. * Enables the edge rendering mode on the mesh.
  27022. * This mode makes the mesh edges visible
  27023. * @param epsilon defines the maximal distance between two angles to detect a face
  27024. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27025. * @returns the currentAbstractMesh
  27026. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27027. */
  27028. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27029. }
  27030. }
  27031. declare module "babylonjs/Actions/actionEvent" {
  27032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27033. import { Nullable } from "babylonjs/types";
  27034. import { Sprite } from "babylonjs/Sprites/sprite";
  27035. import { Scene } from "babylonjs/scene";
  27036. import { Vector2 } from "babylonjs/Maths/math.vector";
  27037. /**
  27038. * Interface used to define ActionEvent
  27039. */
  27040. export interface IActionEvent {
  27041. /** The mesh or sprite that triggered the action */
  27042. source: any;
  27043. /** The X mouse cursor position at the time of the event */
  27044. pointerX: number;
  27045. /** The Y mouse cursor position at the time of the event */
  27046. pointerY: number;
  27047. /** The mesh that is currently pointed at (can be null) */
  27048. meshUnderPointer: Nullable<AbstractMesh>;
  27049. /** the original (browser) event that triggered the ActionEvent */
  27050. sourceEvent?: any;
  27051. /** additional data for the event */
  27052. additionalData?: any;
  27053. }
  27054. /**
  27055. * ActionEvent is the event being sent when an action is triggered.
  27056. */
  27057. export class ActionEvent implements IActionEvent {
  27058. /** The mesh or sprite that triggered the action */
  27059. source: any;
  27060. /** The X mouse cursor position at the time of the event */
  27061. pointerX: number;
  27062. /** The Y mouse cursor position at the time of the event */
  27063. pointerY: number;
  27064. /** The mesh that is currently pointed at (can be null) */
  27065. meshUnderPointer: Nullable<AbstractMesh>;
  27066. /** the original (browser) event that triggered the ActionEvent */
  27067. sourceEvent?: any;
  27068. /** additional data for the event */
  27069. additionalData?: any;
  27070. /**
  27071. * Creates a new ActionEvent
  27072. * @param source The mesh or sprite that triggered the action
  27073. * @param pointerX The X mouse cursor position at the time of the event
  27074. * @param pointerY The Y mouse cursor position at the time of the event
  27075. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27076. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27077. * @param additionalData additional data for the event
  27078. */
  27079. constructor(
  27080. /** The mesh or sprite that triggered the action */
  27081. source: any,
  27082. /** The X mouse cursor position at the time of the event */
  27083. pointerX: number,
  27084. /** The Y mouse cursor position at the time of the event */
  27085. pointerY: number,
  27086. /** The mesh that is currently pointed at (can be null) */
  27087. meshUnderPointer: Nullable<AbstractMesh>,
  27088. /** the original (browser) event that triggered the ActionEvent */
  27089. sourceEvent?: any,
  27090. /** additional data for the event */
  27091. additionalData?: any);
  27092. /**
  27093. * Helper function to auto-create an ActionEvent from a source mesh.
  27094. * @param source The source mesh that triggered the event
  27095. * @param evt The original (browser) event
  27096. * @param additionalData additional data for the event
  27097. * @returns the new ActionEvent
  27098. */
  27099. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27100. /**
  27101. * Helper function to auto-create an ActionEvent from a source sprite
  27102. * @param source The source sprite that triggered the event
  27103. * @param scene Scene associated with the sprite
  27104. * @param evt The original (browser) event
  27105. * @param additionalData additional data for the event
  27106. * @returns the new ActionEvent
  27107. */
  27108. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27109. /**
  27110. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27111. * @param scene the scene where the event occurred
  27112. * @param evt The original (browser) event
  27113. * @returns the new ActionEvent
  27114. */
  27115. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27116. /**
  27117. * Helper function to auto-create an ActionEvent from a primitive
  27118. * @param prim defines the target primitive
  27119. * @param pointerPos defines the pointer position
  27120. * @param evt The original (browser) event
  27121. * @param additionalData additional data for the event
  27122. * @returns the new ActionEvent
  27123. */
  27124. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27125. }
  27126. }
  27127. declare module "babylonjs/Actions/abstractActionManager" {
  27128. import { IDisposable } from "babylonjs/scene";
  27129. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27130. import { IAction } from "babylonjs/Actions/action";
  27131. import { Nullable } from "babylonjs/types";
  27132. /**
  27133. * Abstract class used to decouple action Manager from scene and meshes.
  27134. * Do not instantiate.
  27135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27136. */
  27137. export abstract class AbstractActionManager implements IDisposable {
  27138. /** Gets the list of active triggers */
  27139. static Triggers: {
  27140. [key: string]: number;
  27141. };
  27142. /** Gets the cursor to use when hovering items */
  27143. hoverCursor: string;
  27144. /** Gets the list of actions */
  27145. actions: IAction[];
  27146. /**
  27147. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27148. */
  27149. isRecursive: boolean;
  27150. /**
  27151. * Releases all associated resources
  27152. */
  27153. abstract dispose(): void;
  27154. /**
  27155. * Does this action manager has pointer triggers
  27156. */
  27157. abstract readonly hasPointerTriggers: boolean;
  27158. /**
  27159. * Does this action manager has pick triggers
  27160. */
  27161. abstract readonly hasPickTriggers: boolean;
  27162. /**
  27163. * Process a specific trigger
  27164. * @param trigger defines the trigger to process
  27165. * @param evt defines the event details to be processed
  27166. */
  27167. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27168. /**
  27169. * Does this action manager handles actions of any of the given triggers
  27170. * @param triggers defines the triggers to be tested
  27171. * @return a boolean indicating whether one (or more) of the triggers is handled
  27172. */
  27173. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27174. /**
  27175. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27176. * speed.
  27177. * @param triggerA defines the trigger to be tested
  27178. * @param triggerB defines the trigger to be tested
  27179. * @return a boolean indicating whether one (or more) of the triggers is handled
  27180. */
  27181. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27182. /**
  27183. * Does this action manager handles actions of a given trigger
  27184. * @param trigger defines the trigger to be tested
  27185. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27186. * @return whether the trigger is handled
  27187. */
  27188. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27189. /**
  27190. * Serialize this manager to a JSON object
  27191. * @param name defines the property name to store this manager
  27192. * @returns a JSON representation of this manager
  27193. */
  27194. abstract serialize(name: string): any;
  27195. /**
  27196. * Registers an action to this action manager
  27197. * @param action defines the action to be registered
  27198. * @return the action amended (prepared) after registration
  27199. */
  27200. abstract registerAction(action: IAction): Nullable<IAction>;
  27201. /**
  27202. * Unregisters an action to this action manager
  27203. * @param action defines the action to be unregistered
  27204. * @return a boolean indicating whether the action has been unregistered
  27205. */
  27206. abstract unregisterAction(action: IAction): Boolean;
  27207. /**
  27208. * Does exist one action manager with at least one trigger
  27209. **/
  27210. static readonly HasTriggers: boolean;
  27211. /**
  27212. * Does exist one action manager with at least one pick trigger
  27213. **/
  27214. static readonly HasPickTriggers: boolean;
  27215. /**
  27216. * Does exist one action manager that handles actions of a given trigger
  27217. * @param trigger defines the trigger to be tested
  27218. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27219. **/
  27220. static HasSpecificTrigger(trigger: number): boolean;
  27221. }
  27222. }
  27223. declare module "babylonjs/node" {
  27224. import { Scene } from "babylonjs/scene";
  27225. import { Nullable } from "babylonjs/types";
  27226. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27227. import { Engine } from "babylonjs/Engines/engine";
  27228. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27229. import { Observable } from "babylonjs/Misc/observable";
  27230. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27231. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27232. import { Animatable } from "babylonjs/Animations/animatable";
  27233. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27234. import { Animation } from "babylonjs/Animations/animation";
  27235. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27237. /**
  27238. * Defines how a node can be built from a string name.
  27239. */
  27240. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27241. /**
  27242. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27243. */
  27244. export class Node implements IBehaviorAware<Node> {
  27245. /** @hidden */
  27246. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27247. private static _NodeConstructors;
  27248. /**
  27249. * Add a new node constructor
  27250. * @param type defines the type name of the node to construct
  27251. * @param constructorFunc defines the constructor function
  27252. */
  27253. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27254. /**
  27255. * Returns a node constructor based on type name
  27256. * @param type defines the type name
  27257. * @param name defines the new node name
  27258. * @param scene defines the hosting scene
  27259. * @param options defines optional options to transmit to constructors
  27260. * @returns the new constructor or null
  27261. */
  27262. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27263. /**
  27264. * Gets or sets the name of the node
  27265. */
  27266. name: string;
  27267. /**
  27268. * Gets or sets the id of the node
  27269. */
  27270. id: string;
  27271. /**
  27272. * Gets or sets the unique id of the node
  27273. */
  27274. uniqueId: number;
  27275. /**
  27276. * Gets or sets a string used to store user defined state for the node
  27277. */
  27278. state: string;
  27279. /**
  27280. * Gets or sets an object used to store user defined information for the node
  27281. */
  27282. metadata: any;
  27283. /**
  27284. * For internal use only. Please do not use.
  27285. */
  27286. reservedDataStore: any;
  27287. /**
  27288. * List of inspectable custom properties (used by the Inspector)
  27289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27290. */
  27291. inspectableCustomProperties: IInspectable[];
  27292. /**
  27293. * Gets or sets a boolean used to define if the node must be serialized
  27294. */
  27295. doNotSerialize: boolean;
  27296. /** @hidden */
  27297. _isDisposed: boolean;
  27298. /**
  27299. * Gets a list of Animations associated with the node
  27300. */
  27301. animations: import("babylonjs/Animations/animation").Animation[];
  27302. protected _ranges: {
  27303. [name: string]: Nullable<AnimationRange>;
  27304. };
  27305. /**
  27306. * Callback raised when the node is ready to be used
  27307. */
  27308. onReady: Nullable<(node: Node) => void>;
  27309. private _isEnabled;
  27310. private _isParentEnabled;
  27311. private _isReady;
  27312. /** @hidden */
  27313. _currentRenderId: number;
  27314. private _parentUpdateId;
  27315. /** @hidden */
  27316. _childUpdateId: number;
  27317. /** @hidden */
  27318. _waitingParentId: Nullable<string>;
  27319. /** @hidden */
  27320. _scene: Scene;
  27321. /** @hidden */
  27322. _cache: any;
  27323. private _parentNode;
  27324. private _children;
  27325. /** @hidden */
  27326. _worldMatrix: Matrix;
  27327. /** @hidden */
  27328. _worldMatrixDeterminant: number;
  27329. /** @hidden */
  27330. _worldMatrixDeterminantIsDirty: boolean;
  27331. /** @hidden */
  27332. private _sceneRootNodesIndex;
  27333. /**
  27334. * Gets a boolean indicating if the node has been disposed
  27335. * @returns true if the node was disposed
  27336. */
  27337. isDisposed(): boolean;
  27338. /**
  27339. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27340. * @see https://doc.babylonjs.com/how_to/parenting
  27341. */
  27342. parent: Nullable<Node>;
  27343. private addToSceneRootNodes;
  27344. private removeFromSceneRootNodes;
  27345. private _animationPropertiesOverride;
  27346. /**
  27347. * Gets or sets the animation properties override
  27348. */
  27349. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27350. /**
  27351. * Gets a string idenfifying the name of the class
  27352. * @returns "Node" string
  27353. */
  27354. getClassName(): string;
  27355. /** @hidden */
  27356. readonly _isNode: boolean;
  27357. /**
  27358. * An event triggered when the mesh is disposed
  27359. */
  27360. onDisposeObservable: Observable<Node>;
  27361. private _onDisposeObserver;
  27362. /**
  27363. * Sets a callback that will be raised when the node will be disposed
  27364. */
  27365. onDispose: () => void;
  27366. /**
  27367. * Creates a new Node
  27368. * @param name the name and id to be given to this node
  27369. * @param scene the scene this node will be added to
  27370. * @param addToRootNodes the node will be added to scene.rootNodes
  27371. */
  27372. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27373. /**
  27374. * Gets the scene of the node
  27375. * @returns a scene
  27376. */
  27377. getScene(): Scene;
  27378. /**
  27379. * Gets the engine of the node
  27380. * @returns a Engine
  27381. */
  27382. getEngine(): Engine;
  27383. private _behaviors;
  27384. /**
  27385. * Attach a behavior to the node
  27386. * @see http://doc.babylonjs.com/features/behaviour
  27387. * @param behavior defines the behavior to attach
  27388. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27389. * @returns the current Node
  27390. */
  27391. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27392. /**
  27393. * Remove an attached behavior
  27394. * @see http://doc.babylonjs.com/features/behaviour
  27395. * @param behavior defines the behavior to attach
  27396. * @returns the current Node
  27397. */
  27398. removeBehavior(behavior: Behavior<Node>): Node;
  27399. /**
  27400. * Gets the list of attached behaviors
  27401. * @see http://doc.babylonjs.com/features/behaviour
  27402. */
  27403. readonly behaviors: Behavior<Node>[];
  27404. /**
  27405. * Gets an attached behavior by name
  27406. * @param name defines the name of the behavior to look for
  27407. * @see http://doc.babylonjs.com/features/behaviour
  27408. * @returns null if behavior was not found else the requested behavior
  27409. */
  27410. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27411. /**
  27412. * Returns the latest update of the World matrix
  27413. * @returns a Matrix
  27414. */
  27415. getWorldMatrix(): Matrix;
  27416. /** @hidden */
  27417. _getWorldMatrixDeterminant(): number;
  27418. /**
  27419. * Returns directly the latest state of the mesh World matrix.
  27420. * A Matrix is returned.
  27421. */
  27422. readonly worldMatrixFromCache: Matrix;
  27423. /** @hidden */
  27424. _initCache(): void;
  27425. /** @hidden */
  27426. updateCache(force?: boolean): void;
  27427. /** @hidden */
  27428. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27429. /** @hidden */
  27430. _updateCache(ignoreParentClass?: boolean): void;
  27431. /** @hidden */
  27432. _isSynchronized(): boolean;
  27433. /** @hidden */
  27434. _markSyncedWithParent(): void;
  27435. /** @hidden */
  27436. isSynchronizedWithParent(): boolean;
  27437. /** @hidden */
  27438. isSynchronized(): boolean;
  27439. /**
  27440. * Is this node ready to be used/rendered
  27441. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27442. * @return true if the node is ready
  27443. */
  27444. isReady(completeCheck?: boolean): boolean;
  27445. /**
  27446. * Is this node enabled?
  27447. * 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
  27448. * @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
  27449. * @return whether this node (and its parent) is enabled
  27450. */
  27451. isEnabled(checkAncestors?: boolean): boolean;
  27452. /** @hidden */
  27453. protected _syncParentEnabledState(): void;
  27454. /**
  27455. * Set the enabled state of this node
  27456. * @param value defines the new enabled state
  27457. */
  27458. setEnabled(value: boolean): void;
  27459. /**
  27460. * Is this node a descendant of the given node?
  27461. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27462. * @param ancestor defines the parent node to inspect
  27463. * @returns a boolean indicating if this node is a descendant of the given node
  27464. */
  27465. isDescendantOf(ancestor: Node): boolean;
  27466. /** @hidden */
  27467. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27468. /**
  27469. * Will return all nodes that have this node as ascendant
  27470. * @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
  27471. * @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
  27472. * @return all children nodes of all types
  27473. */
  27474. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27475. /**
  27476. * Get all child-meshes of this node
  27477. * @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)
  27478. * @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
  27479. * @returns an array of AbstractMesh
  27480. */
  27481. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27482. /**
  27483. * Get all direct children of this node
  27484. * @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
  27485. * @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)
  27486. * @returns an array of Node
  27487. */
  27488. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27489. /** @hidden */
  27490. _setReady(state: boolean): void;
  27491. /**
  27492. * Get an animation by name
  27493. * @param name defines the name of the animation to look for
  27494. * @returns null if not found else the requested animation
  27495. */
  27496. getAnimationByName(name: string): Nullable<Animation>;
  27497. /**
  27498. * Creates an animation range for this node
  27499. * @param name defines the name of the range
  27500. * @param from defines the starting key
  27501. * @param to defines the end key
  27502. */
  27503. createAnimationRange(name: string, from: number, to: number): void;
  27504. /**
  27505. * Delete a specific animation range
  27506. * @param name defines the name of the range to delete
  27507. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27508. */
  27509. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27510. /**
  27511. * Get an animation range by name
  27512. * @param name defines the name of the animation range to look for
  27513. * @returns null if not found else the requested animation range
  27514. */
  27515. getAnimationRange(name: string): Nullable<AnimationRange>;
  27516. /**
  27517. * Gets the list of all animation ranges defined on this node
  27518. * @returns an array
  27519. */
  27520. getAnimationRanges(): Nullable<AnimationRange>[];
  27521. /**
  27522. * Will start the animation sequence
  27523. * @param name defines the range frames for animation sequence
  27524. * @param loop defines if the animation should loop (false by default)
  27525. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27526. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27527. * @returns the object created for this animation. If range does not exist, it will return null
  27528. */
  27529. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27530. /**
  27531. * Serialize animation ranges into a JSON compatible object
  27532. * @returns serialization object
  27533. */
  27534. serializeAnimationRanges(): any;
  27535. /**
  27536. * Computes the world matrix of the node
  27537. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27538. * @returns the world matrix
  27539. */
  27540. computeWorldMatrix(force?: boolean): Matrix;
  27541. /**
  27542. * Releases resources associated with this node.
  27543. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27544. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27545. */
  27546. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27547. /**
  27548. * Parse animation range data from a serialization object and store them into a given node
  27549. * @param node defines where to store the animation ranges
  27550. * @param parsedNode defines the serialization object to read data from
  27551. * @param scene defines the hosting scene
  27552. */
  27553. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27554. /**
  27555. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27556. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27557. * @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
  27558. * @returns the new bounding vectors
  27559. */
  27560. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27561. min: Vector3;
  27562. max: Vector3;
  27563. };
  27564. }
  27565. }
  27566. declare module "babylonjs/Animations/animation" {
  27567. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27568. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27569. import { Color3 } from "babylonjs/Maths/math.color";
  27570. import { Nullable } from "babylonjs/types";
  27571. import { Scene } from "babylonjs/scene";
  27572. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27573. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27574. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27575. import { Node } from "babylonjs/node";
  27576. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27577. import { Size } from "babylonjs/Maths/math.size";
  27578. import { Animatable } from "babylonjs/Animations/animatable";
  27579. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27580. /**
  27581. * @hidden
  27582. */
  27583. export class _IAnimationState {
  27584. key: number;
  27585. repeatCount: number;
  27586. workValue?: any;
  27587. loopMode?: number;
  27588. offsetValue?: any;
  27589. highLimitValue?: any;
  27590. }
  27591. /**
  27592. * Class used to store any kind of animation
  27593. */
  27594. export class Animation {
  27595. /**Name of the animation */
  27596. name: string;
  27597. /**Property to animate */
  27598. targetProperty: string;
  27599. /**The frames per second of the animation */
  27600. framePerSecond: number;
  27601. /**The data type of the animation */
  27602. dataType: number;
  27603. /**The loop mode of the animation */
  27604. loopMode?: number | undefined;
  27605. /**Specifies if blending should be enabled */
  27606. enableBlending?: boolean | undefined;
  27607. /**
  27608. * Use matrix interpolation instead of using direct key value when animating matrices
  27609. */
  27610. static AllowMatricesInterpolation: boolean;
  27611. /**
  27612. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27613. */
  27614. static AllowMatrixDecomposeForInterpolation: boolean;
  27615. /**
  27616. * Stores the key frames of the animation
  27617. */
  27618. private _keys;
  27619. /**
  27620. * Stores the easing function of the animation
  27621. */
  27622. private _easingFunction;
  27623. /**
  27624. * @hidden Internal use only
  27625. */
  27626. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27627. /**
  27628. * The set of event that will be linked to this animation
  27629. */
  27630. private _events;
  27631. /**
  27632. * Stores an array of target property paths
  27633. */
  27634. targetPropertyPath: string[];
  27635. /**
  27636. * Stores the blending speed of the animation
  27637. */
  27638. blendingSpeed: number;
  27639. /**
  27640. * Stores the animation ranges for the animation
  27641. */
  27642. private _ranges;
  27643. /**
  27644. * @hidden Internal use
  27645. */
  27646. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27647. /**
  27648. * Sets up an animation
  27649. * @param property The property to animate
  27650. * @param animationType The animation type to apply
  27651. * @param framePerSecond The frames per second of the animation
  27652. * @param easingFunction The easing function used in the animation
  27653. * @returns The created animation
  27654. */
  27655. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27656. /**
  27657. * Create and start an animation on a node
  27658. * @param name defines the name of the global animation that will be run on all nodes
  27659. * @param node defines the root node where the animation will take place
  27660. * @param targetProperty defines property to animate
  27661. * @param framePerSecond defines the number of frame per second yo use
  27662. * @param totalFrame defines the number of frames in total
  27663. * @param from defines the initial value
  27664. * @param to defines the final value
  27665. * @param loopMode defines which loop mode you want to use (off by default)
  27666. * @param easingFunction defines the easing function to use (linear by default)
  27667. * @param onAnimationEnd defines the callback to call when animation end
  27668. * @returns the animatable created for this animation
  27669. */
  27670. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27671. /**
  27672. * Create and start an animation on a node and its descendants
  27673. * @param name defines the name of the global animation that will be run on all nodes
  27674. * @param node defines the root node where the animation will take place
  27675. * @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
  27676. * @param targetProperty defines property to animate
  27677. * @param framePerSecond defines the number of frame per second to use
  27678. * @param totalFrame defines the number of frames in total
  27679. * @param from defines the initial value
  27680. * @param to defines the final value
  27681. * @param loopMode defines which loop mode you want to use (off by default)
  27682. * @param easingFunction defines the easing function to use (linear by default)
  27683. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27684. * @returns the list of animatables created for all nodes
  27685. * @example https://www.babylonjs-playground.com/#MH0VLI
  27686. */
  27687. 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[]>;
  27688. /**
  27689. * Creates a new animation, merges it with the existing animations and starts it
  27690. * @param name Name of the animation
  27691. * @param node Node which contains the scene that begins the animations
  27692. * @param targetProperty Specifies which property to animate
  27693. * @param framePerSecond The frames per second of the animation
  27694. * @param totalFrame The total number of frames
  27695. * @param from The frame at the beginning of the animation
  27696. * @param to The frame at the end of the animation
  27697. * @param loopMode Specifies the loop mode of the animation
  27698. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27699. * @param onAnimationEnd Callback to run once the animation is complete
  27700. * @returns Nullable animation
  27701. */
  27702. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27703. /**
  27704. * Transition property of an host to the target Value
  27705. * @param property The property to transition
  27706. * @param targetValue The target Value of the property
  27707. * @param host The object where the property to animate belongs
  27708. * @param scene Scene used to run the animation
  27709. * @param frameRate Framerate (in frame/s) to use
  27710. * @param transition The transition type we want to use
  27711. * @param duration The duration of the animation, in milliseconds
  27712. * @param onAnimationEnd Callback trigger at the end of the animation
  27713. * @returns Nullable animation
  27714. */
  27715. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27716. /**
  27717. * Return the array of runtime animations currently using this animation
  27718. */
  27719. readonly runtimeAnimations: RuntimeAnimation[];
  27720. /**
  27721. * Specifies if any of the runtime animations are currently running
  27722. */
  27723. readonly hasRunningRuntimeAnimations: boolean;
  27724. /**
  27725. * Initializes the animation
  27726. * @param name Name of the animation
  27727. * @param targetProperty Property to animate
  27728. * @param framePerSecond The frames per second of the animation
  27729. * @param dataType The data type of the animation
  27730. * @param loopMode The loop mode of the animation
  27731. * @param enableBlending Specifies if blending should be enabled
  27732. */
  27733. constructor(
  27734. /**Name of the animation */
  27735. name: string,
  27736. /**Property to animate */
  27737. targetProperty: string,
  27738. /**The frames per second of the animation */
  27739. framePerSecond: number,
  27740. /**The data type of the animation */
  27741. dataType: number,
  27742. /**The loop mode of the animation */
  27743. loopMode?: number | undefined,
  27744. /**Specifies if blending should be enabled */
  27745. enableBlending?: boolean | undefined);
  27746. /**
  27747. * Converts the animation to a string
  27748. * @param fullDetails support for multiple levels of logging within scene loading
  27749. * @returns String form of the animation
  27750. */
  27751. toString(fullDetails?: boolean): string;
  27752. /**
  27753. * Add an event to this animation
  27754. * @param event Event to add
  27755. */
  27756. addEvent(event: AnimationEvent): void;
  27757. /**
  27758. * Remove all events found at the given frame
  27759. * @param frame The frame to remove events from
  27760. */
  27761. removeEvents(frame: number): void;
  27762. /**
  27763. * Retrieves all the events from the animation
  27764. * @returns Events from the animation
  27765. */
  27766. getEvents(): AnimationEvent[];
  27767. /**
  27768. * Creates an animation range
  27769. * @param name Name of the animation range
  27770. * @param from Starting frame of the animation range
  27771. * @param to Ending frame of the animation
  27772. */
  27773. createRange(name: string, from: number, to: number): void;
  27774. /**
  27775. * Deletes an animation range by name
  27776. * @param name Name of the animation range to delete
  27777. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27778. */
  27779. deleteRange(name: string, deleteFrames?: boolean): void;
  27780. /**
  27781. * Gets the animation range by name, or null if not defined
  27782. * @param name Name of the animation range
  27783. * @returns Nullable animation range
  27784. */
  27785. getRange(name: string): Nullable<AnimationRange>;
  27786. /**
  27787. * Gets the key frames from the animation
  27788. * @returns The key frames of the animation
  27789. */
  27790. getKeys(): Array<IAnimationKey>;
  27791. /**
  27792. * Gets the highest frame rate of the animation
  27793. * @returns Highest frame rate of the animation
  27794. */
  27795. getHighestFrame(): number;
  27796. /**
  27797. * Gets the easing function of the animation
  27798. * @returns Easing function of the animation
  27799. */
  27800. getEasingFunction(): IEasingFunction;
  27801. /**
  27802. * Sets the easing function of the animation
  27803. * @param easingFunction A custom mathematical formula for animation
  27804. */
  27805. setEasingFunction(easingFunction: EasingFunction): void;
  27806. /**
  27807. * Interpolates a scalar linearly
  27808. * @param startValue Start value of the animation curve
  27809. * @param endValue End value of the animation curve
  27810. * @param gradient Scalar amount to interpolate
  27811. * @returns Interpolated scalar value
  27812. */
  27813. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27814. /**
  27815. * Interpolates a scalar cubically
  27816. * @param startValue Start value of the animation curve
  27817. * @param outTangent End tangent of the animation
  27818. * @param endValue End value of the animation curve
  27819. * @param inTangent Start tangent of the animation curve
  27820. * @param gradient Scalar amount to interpolate
  27821. * @returns Interpolated scalar value
  27822. */
  27823. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27824. /**
  27825. * Interpolates a quaternion using a spherical linear interpolation
  27826. * @param startValue Start value of the animation curve
  27827. * @param endValue End value of the animation curve
  27828. * @param gradient Scalar amount to interpolate
  27829. * @returns Interpolated quaternion value
  27830. */
  27831. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27832. /**
  27833. * Interpolates a quaternion cubically
  27834. * @param startValue Start value of the animation curve
  27835. * @param outTangent End tangent of the animation curve
  27836. * @param endValue End value of the animation curve
  27837. * @param inTangent Start tangent of the animation curve
  27838. * @param gradient Scalar amount to interpolate
  27839. * @returns Interpolated quaternion value
  27840. */
  27841. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27842. /**
  27843. * Interpolates a Vector3 linearl
  27844. * @param startValue Start value of the animation curve
  27845. * @param endValue End value of the animation curve
  27846. * @param gradient Scalar amount to interpolate
  27847. * @returns Interpolated scalar value
  27848. */
  27849. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27850. /**
  27851. * Interpolates a Vector3 cubically
  27852. * @param startValue Start value of the animation curve
  27853. * @param outTangent End tangent of the animation
  27854. * @param endValue End value of the animation curve
  27855. * @param inTangent Start tangent of the animation curve
  27856. * @param gradient Scalar amount to interpolate
  27857. * @returns InterpolatedVector3 value
  27858. */
  27859. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27860. /**
  27861. * Interpolates a Vector2 linearly
  27862. * @param startValue Start value of the animation curve
  27863. * @param endValue End value of the animation curve
  27864. * @param gradient Scalar amount to interpolate
  27865. * @returns Interpolated Vector2 value
  27866. */
  27867. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27868. /**
  27869. * Interpolates a Vector2 cubically
  27870. * @param startValue Start value of the animation curve
  27871. * @param outTangent End tangent of the animation
  27872. * @param endValue End value of the animation curve
  27873. * @param inTangent Start tangent of the animation curve
  27874. * @param gradient Scalar amount to interpolate
  27875. * @returns Interpolated Vector2 value
  27876. */
  27877. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27878. /**
  27879. * Interpolates a size linearly
  27880. * @param startValue Start value of the animation curve
  27881. * @param endValue End value of the animation curve
  27882. * @param gradient Scalar amount to interpolate
  27883. * @returns Interpolated Size value
  27884. */
  27885. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27886. /**
  27887. * Interpolates a Color3 linearly
  27888. * @param startValue Start value of the animation curve
  27889. * @param endValue End value of the animation curve
  27890. * @param gradient Scalar amount to interpolate
  27891. * @returns Interpolated Color3 value
  27892. */
  27893. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27894. /**
  27895. * @hidden Internal use only
  27896. */
  27897. _getKeyValue(value: any): any;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27902. /**
  27903. * Defines the function to use to interpolate matrices
  27904. * @param startValue defines the start matrix
  27905. * @param endValue defines the end matrix
  27906. * @param gradient defines the gradient between both matrices
  27907. * @param result defines an optional target matrix where to store the interpolation
  27908. * @returns the interpolated matrix
  27909. */
  27910. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27911. /**
  27912. * Makes a copy of the animation
  27913. * @returns Cloned animation
  27914. */
  27915. clone(): Animation;
  27916. /**
  27917. * Sets the key frames of the animation
  27918. * @param values The animation key frames to set
  27919. */
  27920. setKeys(values: Array<IAnimationKey>): void;
  27921. /**
  27922. * Serializes the animation to an object
  27923. * @returns Serialized object
  27924. */
  27925. serialize(): any;
  27926. /**
  27927. * Float animation type
  27928. */
  27929. private static _ANIMATIONTYPE_FLOAT;
  27930. /**
  27931. * Vector3 animation type
  27932. */
  27933. private static _ANIMATIONTYPE_VECTOR3;
  27934. /**
  27935. * Quaternion animation type
  27936. */
  27937. private static _ANIMATIONTYPE_QUATERNION;
  27938. /**
  27939. * Matrix animation type
  27940. */
  27941. private static _ANIMATIONTYPE_MATRIX;
  27942. /**
  27943. * Color3 animation type
  27944. */
  27945. private static _ANIMATIONTYPE_COLOR3;
  27946. /**
  27947. * Vector2 animation type
  27948. */
  27949. private static _ANIMATIONTYPE_VECTOR2;
  27950. /**
  27951. * Size animation type
  27952. */
  27953. private static _ANIMATIONTYPE_SIZE;
  27954. /**
  27955. * Relative Loop Mode
  27956. */
  27957. private static _ANIMATIONLOOPMODE_RELATIVE;
  27958. /**
  27959. * Cycle Loop Mode
  27960. */
  27961. private static _ANIMATIONLOOPMODE_CYCLE;
  27962. /**
  27963. * Constant Loop Mode
  27964. */
  27965. private static _ANIMATIONLOOPMODE_CONSTANT;
  27966. /**
  27967. * Get the float animation type
  27968. */
  27969. static readonly ANIMATIONTYPE_FLOAT: number;
  27970. /**
  27971. * Get the Vector3 animation type
  27972. */
  27973. static readonly ANIMATIONTYPE_VECTOR3: number;
  27974. /**
  27975. * Get the Vector2 animation type
  27976. */
  27977. static readonly ANIMATIONTYPE_VECTOR2: number;
  27978. /**
  27979. * Get the Size animation type
  27980. */
  27981. static readonly ANIMATIONTYPE_SIZE: number;
  27982. /**
  27983. * Get the Quaternion animation type
  27984. */
  27985. static readonly ANIMATIONTYPE_QUATERNION: number;
  27986. /**
  27987. * Get the Matrix animation type
  27988. */
  27989. static readonly ANIMATIONTYPE_MATRIX: number;
  27990. /**
  27991. * Get the Color3 animation type
  27992. */
  27993. static readonly ANIMATIONTYPE_COLOR3: number;
  27994. /**
  27995. * Get the Relative Loop Mode
  27996. */
  27997. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27998. /**
  27999. * Get the Cycle Loop Mode
  28000. */
  28001. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28002. /**
  28003. * Get the Constant Loop Mode
  28004. */
  28005. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28006. /** @hidden */
  28007. static _UniversalLerp(left: any, right: any, amount: number): any;
  28008. /**
  28009. * Parses an animation object and creates an animation
  28010. * @param parsedAnimation Parsed animation object
  28011. * @returns Animation object
  28012. */
  28013. static Parse(parsedAnimation: any): Animation;
  28014. /**
  28015. * Appends the serialized animations from the source animations
  28016. * @param source Source containing the animations
  28017. * @param destination Target to store the animations
  28018. */
  28019. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28020. }
  28021. }
  28022. declare module "babylonjs/Animations/animatable.interface" {
  28023. import { Nullable } from "babylonjs/types";
  28024. import { Animation } from "babylonjs/Animations/animation";
  28025. /**
  28026. * Interface containing an array of animations
  28027. */
  28028. export interface IAnimatable {
  28029. /**
  28030. * Array of animations
  28031. */
  28032. animations: Nullable<Array<Animation>>;
  28033. }
  28034. }
  28035. declare module "babylonjs/Materials/fresnelParameters" {
  28036. import { Color3 } from "babylonjs/Maths/math.color";
  28037. /**
  28038. * This represents all the required information to add a fresnel effect on a material:
  28039. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28040. */
  28041. export class FresnelParameters {
  28042. private _isEnabled;
  28043. /**
  28044. * Define if the fresnel effect is enable or not.
  28045. */
  28046. isEnabled: boolean;
  28047. /**
  28048. * Define the color used on edges (grazing angle)
  28049. */
  28050. leftColor: Color3;
  28051. /**
  28052. * Define the color used on center
  28053. */
  28054. rightColor: Color3;
  28055. /**
  28056. * Define bias applied to computed fresnel term
  28057. */
  28058. bias: number;
  28059. /**
  28060. * Defined the power exponent applied to fresnel term
  28061. */
  28062. power: number;
  28063. /**
  28064. * Clones the current fresnel and its valuues
  28065. * @returns a clone fresnel configuration
  28066. */
  28067. clone(): FresnelParameters;
  28068. /**
  28069. * Serializes the current fresnel parameters to a JSON representation.
  28070. * @return the JSON serialization
  28071. */
  28072. serialize(): any;
  28073. /**
  28074. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28075. * @param parsedFresnelParameters Define the JSON representation
  28076. * @returns the parsed parameters
  28077. */
  28078. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28079. }
  28080. }
  28081. declare module "babylonjs/Misc/decorators" {
  28082. import { Nullable } from "babylonjs/types";
  28083. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28084. import { Scene } from "babylonjs/scene";
  28085. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28086. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28087. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28088. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28089. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28090. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28091. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28092. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28093. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28094. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28095. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28096. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28097. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28098. /**
  28099. * Decorator used to define property that can be serialized as reference to a camera
  28100. * @param sourceName defines the name of the property to decorate
  28101. */
  28102. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28103. /**
  28104. * Class used to help serialization objects
  28105. */
  28106. export class SerializationHelper {
  28107. /** @hidden */
  28108. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28109. /** @hidden */
  28110. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28111. /** @hidden */
  28112. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28113. /** @hidden */
  28114. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28115. /**
  28116. * Appends the serialized animations from the source animations
  28117. * @param source Source containing the animations
  28118. * @param destination Target to store the animations
  28119. */
  28120. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28121. /**
  28122. * Static function used to serialized a specific entity
  28123. * @param entity defines the entity to serialize
  28124. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28125. * @returns a JSON compatible object representing the serialization of the entity
  28126. */
  28127. static Serialize<T>(entity: T, serializationObject?: any): any;
  28128. /**
  28129. * Creates a new entity from a serialization data object
  28130. * @param creationFunction defines a function used to instanciated the new entity
  28131. * @param source defines the source serialization data
  28132. * @param scene defines the hosting scene
  28133. * @param rootUrl defines the root url for resources
  28134. * @returns a new entity
  28135. */
  28136. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28137. /**
  28138. * Clones an object
  28139. * @param creationFunction defines the function used to instanciate the new object
  28140. * @param source defines the source object
  28141. * @returns the cloned object
  28142. */
  28143. static Clone<T>(creationFunction: () => T, source: T): T;
  28144. /**
  28145. * Instanciates a new object based on a source one (some data will be shared between both object)
  28146. * @param creationFunction defines the function used to instanciate the new object
  28147. * @param source defines the source object
  28148. * @returns the new object
  28149. */
  28150. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28151. }
  28152. }
  28153. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28154. import { Nullable } from "babylonjs/types";
  28155. /**
  28156. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28157. */
  28158. export interface CubeMapInfo {
  28159. /**
  28160. * The pixel array for the front face.
  28161. * This is stored in format, left to right, up to down format.
  28162. */
  28163. front: Nullable<ArrayBufferView>;
  28164. /**
  28165. * The pixel array for the back face.
  28166. * This is stored in format, left to right, up to down format.
  28167. */
  28168. back: Nullable<ArrayBufferView>;
  28169. /**
  28170. * The pixel array for the left face.
  28171. * This is stored in format, left to right, up to down format.
  28172. */
  28173. left: Nullable<ArrayBufferView>;
  28174. /**
  28175. * The pixel array for the right face.
  28176. * This is stored in format, left to right, up to down format.
  28177. */
  28178. right: Nullable<ArrayBufferView>;
  28179. /**
  28180. * The pixel array for the up face.
  28181. * This is stored in format, left to right, up to down format.
  28182. */
  28183. up: Nullable<ArrayBufferView>;
  28184. /**
  28185. * The pixel array for the down face.
  28186. * This is stored in format, left to right, up to down format.
  28187. */
  28188. down: Nullable<ArrayBufferView>;
  28189. /**
  28190. * The size of the cubemap stored.
  28191. *
  28192. * Each faces will be size * size pixels.
  28193. */
  28194. size: number;
  28195. /**
  28196. * The format of the texture.
  28197. *
  28198. * RGBA, RGB.
  28199. */
  28200. format: number;
  28201. /**
  28202. * The type of the texture data.
  28203. *
  28204. * UNSIGNED_INT, FLOAT.
  28205. */
  28206. type: number;
  28207. /**
  28208. * Specifies whether the texture is in gamma space.
  28209. */
  28210. gammaSpace: boolean;
  28211. }
  28212. /**
  28213. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28214. */
  28215. export class PanoramaToCubeMapTools {
  28216. private static FACE_FRONT;
  28217. private static FACE_BACK;
  28218. private static FACE_RIGHT;
  28219. private static FACE_LEFT;
  28220. private static FACE_DOWN;
  28221. private static FACE_UP;
  28222. /**
  28223. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28224. *
  28225. * @param float32Array The source data.
  28226. * @param inputWidth The width of the input panorama.
  28227. * @param inputHeight The height of the input panorama.
  28228. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28229. * @return The cubemap data
  28230. */
  28231. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28232. private static CreateCubemapTexture;
  28233. private static CalcProjectionSpherical;
  28234. }
  28235. }
  28236. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28237. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28238. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28239. import { Nullable } from "babylonjs/types";
  28240. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28241. /**
  28242. * Helper class dealing with the extraction of spherical polynomial dataArray
  28243. * from a cube map.
  28244. */
  28245. export class CubeMapToSphericalPolynomialTools {
  28246. private static FileFaces;
  28247. /**
  28248. * Converts a texture to the according Spherical Polynomial data.
  28249. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28250. *
  28251. * @param texture The texture to extract the information from.
  28252. * @return The Spherical Polynomial data.
  28253. */
  28254. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28255. /**
  28256. * Converts a cubemap to the according Spherical Polynomial data.
  28257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28258. *
  28259. * @param cubeInfo The Cube map to extract the information from.
  28260. * @return The Spherical Polynomial data.
  28261. */
  28262. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28263. }
  28264. }
  28265. declare module "babylonjs/Misc/guid" {
  28266. /**
  28267. * Class used to manipulate GUIDs
  28268. */
  28269. export class GUID {
  28270. /**
  28271. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28272. * Be aware Math.random() could cause collisions, but:
  28273. * "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"
  28274. * @returns a pseudo random id
  28275. */
  28276. static RandomId(): string;
  28277. }
  28278. }
  28279. declare module "babylonjs/Materials/Textures/baseTexture" {
  28280. import { Observable } from "babylonjs/Misc/observable";
  28281. import { Nullable } from "babylonjs/types";
  28282. import { Scene } from "babylonjs/scene";
  28283. import { Matrix } from "babylonjs/Maths/math.vector";
  28284. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28285. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28286. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28287. import { ISize } from "babylonjs/Maths/math.size";
  28288. /**
  28289. * Base class of all the textures in babylon.
  28290. * It groups all the common properties the materials, post process, lights... might need
  28291. * in order to make a correct use of the texture.
  28292. */
  28293. export class BaseTexture implements IAnimatable {
  28294. /**
  28295. * Default anisotropic filtering level for the application.
  28296. * It is set to 4 as a good tradeoff between perf and quality.
  28297. */
  28298. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28299. /**
  28300. * Gets or sets the unique id of the texture
  28301. */
  28302. uniqueId: number;
  28303. /**
  28304. * Define the name of the texture.
  28305. */
  28306. name: string;
  28307. /**
  28308. * Gets or sets an object used to store user defined information.
  28309. */
  28310. metadata: any;
  28311. /**
  28312. * For internal use only. Please do not use.
  28313. */
  28314. reservedDataStore: any;
  28315. private _hasAlpha;
  28316. /**
  28317. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28318. */
  28319. hasAlpha: boolean;
  28320. /**
  28321. * Defines if the alpha value should be determined via the rgb values.
  28322. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28323. */
  28324. getAlphaFromRGB: boolean;
  28325. /**
  28326. * Intensity or strength of the texture.
  28327. * It is commonly used by materials to fine tune the intensity of the texture
  28328. */
  28329. level: number;
  28330. /**
  28331. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28332. * This is part of the texture as textures usually maps to one uv set.
  28333. */
  28334. coordinatesIndex: number;
  28335. private _coordinatesMode;
  28336. /**
  28337. * How a texture is mapped.
  28338. *
  28339. * | Value | Type | Description |
  28340. * | ----- | ----------------------------------- | ----------- |
  28341. * | 0 | EXPLICIT_MODE | |
  28342. * | 1 | SPHERICAL_MODE | |
  28343. * | 2 | PLANAR_MODE | |
  28344. * | 3 | CUBIC_MODE | |
  28345. * | 4 | PROJECTION_MODE | |
  28346. * | 5 | SKYBOX_MODE | |
  28347. * | 6 | INVCUBIC_MODE | |
  28348. * | 7 | EQUIRECTANGULAR_MODE | |
  28349. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28350. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28351. */
  28352. coordinatesMode: number;
  28353. /**
  28354. * | Value | Type | Description |
  28355. * | ----- | ------------------ | ----------- |
  28356. * | 0 | CLAMP_ADDRESSMODE | |
  28357. * | 1 | WRAP_ADDRESSMODE | |
  28358. * | 2 | MIRROR_ADDRESSMODE | |
  28359. */
  28360. wrapU: number;
  28361. /**
  28362. * | Value | Type | Description |
  28363. * | ----- | ------------------ | ----------- |
  28364. * | 0 | CLAMP_ADDRESSMODE | |
  28365. * | 1 | WRAP_ADDRESSMODE | |
  28366. * | 2 | MIRROR_ADDRESSMODE | |
  28367. */
  28368. wrapV: number;
  28369. /**
  28370. * | Value | Type | Description |
  28371. * | ----- | ------------------ | ----------- |
  28372. * | 0 | CLAMP_ADDRESSMODE | |
  28373. * | 1 | WRAP_ADDRESSMODE | |
  28374. * | 2 | MIRROR_ADDRESSMODE | |
  28375. */
  28376. wrapR: number;
  28377. /**
  28378. * With compliant hardware and browser (supporting anisotropic filtering)
  28379. * this defines the level of anisotropic filtering in the texture.
  28380. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28381. */
  28382. anisotropicFilteringLevel: number;
  28383. /**
  28384. * Define if the texture is a cube texture or if false a 2d texture.
  28385. */
  28386. isCube: boolean;
  28387. /**
  28388. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28389. */
  28390. is3D: boolean;
  28391. /**
  28392. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28393. * HDR texture are usually stored in linear space.
  28394. * This only impacts the PBR and Background materials
  28395. */
  28396. gammaSpace: boolean;
  28397. /**
  28398. * Gets whether or not the texture contains RGBD data.
  28399. */
  28400. readonly isRGBD: boolean;
  28401. /**
  28402. * Is Z inverted in the texture (useful in a cube texture).
  28403. */
  28404. invertZ: boolean;
  28405. /**
  28406. * Are mip maps generated for this texture or not.
  28407. */
  28408. readonly noMipmap: boolean;
  28409. /**
  28410. * @hidden
  28411. */
  28412. lodLevelInAlpha: boolean;
  28413. /**
  28414. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28415. */
  28416. lodGenerationOffset: number;
  28417. /**
  28418. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28419. */
  28420. lodGenerationScale: number;
  28421. /**
  28422. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28423. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28424. * average roughness values.
  28425. */
  28426. linearSpecularLOD: boolean;
  28427. /**
  28428. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28429. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28430. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28431. */
  28432. irradianceTexture: Nullable<BaseTexture>;
  28433. /**
  28434. * Define if the texture is a render target.
  28435. */
  28436. isRenderTarget: boolean;
  28437. /**
  28438. * Define the unique id of the texture in the scene.
  28439. */
  28440. readonly uid: string;
  28441. /**
  28442. * Return a string representation of the texture.
  28443. * @returns the texture as a string
  28444. */
  28445. toString(): string;
  28446. /**
  28447. * Get the class name of the texture.
  28448. * @returns "BaseTexture"
  28449. */
  28450. getClassName(): string;
  28451. /**
  28452. * Define the list of animation attached to the texture.
  28453. */
  28454. animations: import("babylonjs/Animations/animation").Animation[];
  28455. /**
  28456. * An event triggered when the texture is disposed.
  28457. */
  28458. onDisposeObservable: Observable<BaseTexture>;
  28459. private _onDisposeObserver;
  28460. /**
  28461. * Callback triggered when the texture has been disposed.
  28462. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28463. */
  28464. onDispose: () => void;
  28465. /**
  28466. * Define the current state of the loading sequence when in delayed load mode.
  28467. */
  28468. delayLoadState: number;
  28469. private _scene;
  28470. /** @hidden */
  28471. _texture: Nullable<InternalTexture>;
  28472. private _uid;
  28473. /**
  28474. * Define if the texture is preventinga material to render or not.
  28475. * If not and the texture is not ready, the engine will use a default black texture instead.
  28476. */
  28477. readonly isBlocking: boolean;
  28478. /**
  28479. * Instantiates a new BaseTexture.
  28480. * Base class of all the textures in babylon.
  28481. * It groups all the common properties the materials, post process, lights... might need
  28482. * in order to make a correct use of the texture.
  28483. * @param scene Define the scene the texture blongs to
  28484. */
  28485. constructor(scene: Nullable<Scene>);
  28486. /**
  28487. * Get the scene the texture belongs to.
  28488. * @returns the scene or null if undefined
  28489. */
  28490. getScene(): Nullable<Scene>;
  28491. /**
  28492. * Get the texture transform matrix used to offset tile the texture for istance.
  28493. * @returns the transformation matrix
  28494. */
  28495. getTextureMatrix(): Matrix;
  28496. /**
  28497. * Get the texture reflection matrix used to rotate/transform the reflection.
  28498. * @returns the reflection matrix
  28499. */
  28500. getReflectionTextureMatrix(): Matrix;
  28501. /**
  28502. * Get the underlying lower level texture from Babylon.
  28503. * @returns the insternal texture
  28504. */
  28505. getInternalTexture(): Nullable<InternalTexture>;
  28506. /**
  28507. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28508. * @returns true if ready or not blocking
  28509. */
  28510. isReadyOrNotBlocking(): boolean;
  28511. /**
  28512. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28513. * @returns true if fully ready
  28514. */
  28515. isReady(): boolean;
  28516. private _cachedSize;
  28517. /**
  28518. * Get the size of the texture.
  28519. * @returns the texture size.
  28520. */
  28521. getSize(): ISize;
  28522. /**
  28523. * Get the base size of the texture.
  28524. * It can be different from the size if the texture has been resized for POT for instance
  28525. * @returns the base size
  28526. */
  28527. getBaseSize(): ISize;
  28528. /**
  28529. * Update the sampling mode of the texture.
  28530. * Default is Trilinear mode.
  28531. *
  28532. * | Value | Type | Description |
  28533. * | ----- | ------------------ | ----------- |
  28534. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28535. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28536. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28537. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28538. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28539. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28540. * | 7 | NEAREST_LINEAR | |
  28541. * | 8 | NEAREST_NEAREST | |
  28542. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28543. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28544. * | 11 | LINEAR_LINEAR | |
  28545. * | 12 | LINEAR_NEAREST | |
  28546. *
  28547. * > _mag_: magnification filter (close to the viewer)
  28548. * > _min_: minification filter (far from the viewer)
  28549. * > _mip_: filter used between mip map levels
  28550. *@param samplingMode Define the new sampling mode of the texture
  28551. */
  28552. updateSamplingMode(samplingMode: number): void;
  28553. /**
  28554. * Scales the texture if is `canRescale()`
  28555. * @param ratio the resize factor we want to use to rescale
  28556. */
  28557. scale(ratio: number): void;
  28558. /**
  28559. * Get if the texture can rescale.
  28560. */
  28561. readonly canRescale: boolean;
  28562. /** @hidden */
  28563. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28564. /** @hidden */
  28565. _rebuild(): void;
  28566. /**
  28567. * Triggers the load sequence in delayed load mode.
  28568. */
  28569. delayLoad(): void;
  28570. /**
  28571. * Clones the texture.
  28572. * @returns the cloned texture
  28573. */
  28574. clone(): Nullable<BaseTexture>;
  28575. /**
  28576. * Get the texture underlying type (INT, FLOAT...)
  28577. */
  28578. readonly textureType: number;
  28579. /**
  28580. * Get the texture underlying format (RGB, RGBA...)
  28581. */
  28582. readonly textureFormat: number;
  28583. /**
  28584. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28585. * This will returns an RGBA array buffer containing either in values (0-255) or
  28586. * float values (0-1) depending of the underlying buffer type.
  28587. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28588. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28589. * @param buffer defines a user defined buffer to fill with data (can be null)
  28590. * @returns The Array buffer containing the pixels data.
  28591. */
  28592. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28593. /**
  28594. * Release and destroy the underlying lower level texture aka internalTexture.
  28595. */
  28596. releaseInternalTexture(): void;
  28597. /**
  28598. * Get the polynomial representation of the texture data.
  28599. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28600. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28601. */
  28602. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28603. /** @hidden */
  28604. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28605. /** @hidden */
  28606. readonly _lodTextureMid: Nullable<BaseTexture>;
  28607. /** @hidden */
  28608. readonly _lodTextureLow: Nullable<BaseTexture>;
  28609. /**
  28610. * Dispose the texture and release its associated resources.
  28611. */
  28612. dispose(): void;
  28613. /**
  28614. * Serialize the texture into a JSON representation that can be parsed later on.
  28615. * @returns the JSON representation of the texture
  28616. */
  28617. serialize(): any;
  28618. /**
  28619. * Helper function to be called back once a list of texture contains only ready textures.
  28620. * @param textures Define the list of textures to wait for
  28621. * @param callback Define the callback triggered once the entire list will be ready
  28622. */
  28623. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28624. }
  28625. }
  28626. declare module "babylonjs/Materials/Textures/internalTexture" {
  28627. import { Observable } from "babylonjs/Misc/observable";
  28628. import { Nullable, int } from "babylonjs/types";
  28629. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28630. import { Engine } from "babylonjs/Engines/engine";
  28631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28632. /**
  28633. * Class used to store data associated with WebGL texture data for the engine
  28634. * This class should not be used directly
  28635. */
  28636. export class InternalTexture {
  28637. /** @hidden */
  28638. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28639. /**
  28640. * The source of the texture data is unknown
  28641. */
  28642. static DATASOURCE_UNKNOWN: number;
  28643. /**
  28644. * Texture data comes from an URL
  28645. */
  28646. static DATASOURCE_URL: number;
  28647. /**
  28648. * Texture data is only used for temporary storage
  28649. */
  28650. static DATASOURCE_TEMP: number;
  28651. /**
  28652. * Texture data comes from raw data (ArrayBuffer)
  28653. */
  28654. static DATASOURCE_RAW: number;
  28655. /**
  28656. * Texture content is dynamic (video or dynamic texture)
  28657. */
  28658. static DATASOURCE_DYNAMIC: number;
  28659. /**
  28660. * Texture content is generated by rendering to it
  28661. */
  28662. static DATASOURCE_RENDERTARGET: number;
  28663. /**
  28664. * Texture content is part of a multi render target process
  28665. */
  28666. static DATASOURCE_MULTIRENDERTARGET: number;
  28667. /**
  28668. * Texture data comes from a cube data file
  28669. */
  28670. static DATASOURCE_CUBE: number;
  28671. /**
  28672. * Texture data comes from a raw cube data
  28673. */
  28674. static DATASOURCE_CUBERAW: number;
  28675. /**
  28676. * Texture data come from a prefiltered cube data file
  28677. */
  28678. static DATASOURCE_CUBEPREFILTERED: number;
  28679. /**
  28680. * Texture content is raw 3D data
  28681. */
  28682. static DATASOURCE_RAW3D: number;
  28683. /**
  28684. * Texture content is a depth texture
  28685. */
  28686. static DATASOURCE_DEPTHTEXTURE: number;
  28687. /**
  28688. * Texture data comes from a raw cube data encoded with RGBD
  28689. */
  28690. static DATASOURCE_CUBERAW_RGBD: number;
  28691. /**
  28692. * Defines if the texture is ready
  28693. */
  28694. isReady: boolean;
  28695. /**
  28696. * Defines if the texture is a cube texture
  28697. */
  28698. isCube: boolean;
  28699. /**
  28700. * Defines if the texture contains 3D data
  28701. */
  28702. is3D: boolean;
  28703. /**
  28704. * Defines if the texture contains multiview data
  28705. */
  28706. isMultiview: boolean;
  28707. /**
  28708. * Gets the URL used to load this texture
  28709. */
  28710. url: string;
  28711. /**
  28712. * Gets the sampling mode of the texture
  28713. */
  28714. samplingMode: number;
  28715. /**
  28716. * Gets a boolean indicating if the texture needs mipmaps generation
  28717. */
  28718. generateMipMaps: boolean;
  28719. /**
  28720. * Gets the number of samples used by the texture (WebGL2+ only)
  28721. */
  28722. samples: number;
  28723. /**
  28724. * Gets the type of the texture (int, float...)
  28725. */
  28726. type: number;
  28727. /**
  28728. * Gets the format of the texture (RGB, RGBA...)
  28729. */
  28730. format: number;
  28731. /**
  28732. * Observable called when the texture is loaded
  28733. */
  28734. onLoadedObservable: Observable<InternalTexture>;
  28735. /**
  28736. * Gets the width of the texture
  28737. */
  28738. width: number;
  28739. /**
  28740. * Gets the height of the texture
  28741. */
  28742. height: number;
  28743. /**
  28744. * Gets the depth of the texture
  28745. */
  28746. depth: number;
  28747. /**
  28748. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28749. */
  28750. baseWidth: number;
  28751. /**
  28752. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28753. */
  28754. baseHeight: number;
  28755. /**
  28756. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28757. */
  28758. baseDepth: number;
  28759. /**
  28760. * Gets a boolean indicating if the texture is inverted on Y axis
  28761. */
  28762. invertY: boolean;
  28763. /** @hidden */
  28764. _invertVScale: boolean;
  28765. /** @hidden */
  28766. _associatedChannel: number;
  28767. /** @hidden */
  28768. _dataSource: number;
  28769. /** @hidden */
  28770. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28771. /** @hidden */
  28772. _bufferView: Nullable<ArrayBufferView>;
  28773. /** @hidden */
  28774. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28775. /** @hidden */
  28776. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28777. /** @hidden */
  28778. _size: number;
  28779. /** @hidden */
  28780. _extension: string;
  28781. /** @hidden */
  28782. _files: Nullable<string[]>;
  28783. /** @hidden */
  28784. _workingCanvas: Nullable<HTMLCanvasElement>;
  28785. /** @hidden */
  28786. _workingContext: Nullable<CanvasRenderingContext2D>;
  28787. /** @hidden */
  28788. _framebuffer: Nullable<WebGLFramebuffer>;
  28789. /** @hidden */
  28790. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28791. /** @hidden */
  28792. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28793. /** @hidden */
  28794. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28795. /** @hidden */
  28796. _attachments: Nullable<number[]>;
  28797. /** @hidden */
  28798. _cachedCoordinatesMode: Nullable<number>;
  28799. /** @hidden */
  28800. _cachedWrapU: Nullable<number>;
  28801. /** @hidden */
  28802. _cachedWrapV: Nullable<number>;
  28803. /** @hidden */
  28804. _cachedWrapR: Nullable<number>;
  28805. /** @hidden */
  28806. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28807. /** @hidden */
  28808. _isDisabled: boolean;
  28809. /** @hidden */
  28810. _compression: Nullable<string>;
  28811. /** @hidden */
  28812. _generateStencilBuffer: boolean;
  28813. /** @hidden */
  28814. _generateDepthBuffer: boolean;
  28815. /** @hidden */
  28816. _comparisonFunction: number;
  28817. /** @hidden */
  28818. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28819. /** @hidden */
  28820. _lodGenerationScale: number;
  28821. /** @hidden */
  28822. _lodGenerationOffset: number;
  28823. /** @hidden */
  28824. _colorTextureArray: Nullable<WebGLTexture>;
  28825. /** @hidden */
  28826. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28827. /** @hidden */
  28828. _lodTextureHigh: Nullable<BaseTexture>;
  28829. /** @hidden */
  28830. _lodTextureMid: Nullable<BaseTexture>;
  28831. /** @hidden */
  28832. _lodTextureLow: Nullable<BaseTexture>;
  28833. /** @hidden */
  28834. _isRGBD: boolean;
  28835. /** @hidden */
  28836. _linearSpecularLOD: boolean;
  28837. /** @hidden */
  28838. _irradianceTexture: Nullable<BaseTexture>;
  28839. /** @hidden */
  28840. _webGLTexture: Nullable<WebGLTexture>;
  28841. /** @hidden */
  28842. _references: number;
  28843. private _engine;
  28844. /**
  28845. * Gets the Engine the texture belongs to.
  28846. * @returns The babylon engine
  28847. */
  28848. getEngine(): Engine;
  28849. /**
  28850. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28851. */
  28852. readonly dataSource: number;
  28853. /**
  28854. * Creates a new InternalTexture
  28855. * @param engine defines the engine to use
  28856. * @param dataSource defines the type of data that will be used
  28857. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28858. */
  28859. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28860. /**
  28861. * Increments the number of references (ie. the number of Texture that point to it)
  28862. */
  28863. incrementReferences(): void;
  28864. /**
  28865. * Change the size of the texture (not the size of the content)
  28866. * @param width defines the new width
  28867. * @param height defines the new height
  28868. * @param depth defines the new depth (1 by default)
  28869. */
  28870. updateSize(width: int, height: int, depth?: int): void;
  28871. /** @hidden */
  28872. _rebuild(): void;
  28873. /** @hidden */
  28874. _swapAndDie(target: InternalTexture): void;
  28875. /**
  28876. * Dispose the current allocated resources
  28877. */
  28878. dispose(): void;
  28879. }
  28880. }
  28881. declare module "babylonjs/Materials/effect" {
  28882. import { Observable } from "babylonjs/Misc/observable";
  28883. import { Nullable } from "babylonjs/types";
  28884. import { IDisposable } from "babylonjs/scene";
  28885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28886. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28887. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28888. import { Engine } from "babylonjs/Engines/engine";
  28889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28891. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28892. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28893. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28894. /**
  28895. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28896. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28897. */
  28898. export class EffectFallbacks {
  28899. private _defines;
  28900. private _currentRank;
  28901. private _maxRank;
  28902. private _mesh;
  28903. /**
  28904. * Removes the fallback from the bound mesh.
  28905. */
  28906. unBindMesh(): void;
  28907. /**
  28908. * Adds a fallback on the specified property.
  28909. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28910. * @param define The name of the define in the shader
  28911. */
  28912. addFallback(rank: number, define: string): void;
  28913. /**
  28914. * Sets the mesh to use CPU skinning when needing to fallback.
  28915. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28916. * @param mesh The mesh to use the fallbacks.
  28917. */
  28918. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28919. /**
  28920. * Checks to see if more fallbacks are still availible.
  28921. */
  28922. readonly isMoreFallbacks: boolean;
  28923. /**
  28924. * Removes the defines that should be removed when falling back.
  28925. * @param currentDefines defines the current define statements for the shader.
  28926. * @param effect defines the current effect we try to compile
  28927. * @returns The resulting defines with defines of the current rank removed.
  28928. */
  28929. reduce(currentDefines: string, effect: Effect): string;
  28930. }
  28931. /**
  28932. * Options to be used when creating an effect.
  28933. */
  28934. export class EffectCreationOptions {
  28935. /**
  28936. * Atrributes that will be used in the shader.
  28937. */
  28938. attributes: string[];
  28939. /**
  28940. * Uniform varible names that will be set in the shader.
  28941. */
  28942. uniformsNames: string[];
  28943. /**
  28944. * Uniform buffer varible names that will be set in the shader.
  28945. */
  28946. uniformBuffersNames: string[];
  28947. /**
  28948. * Sampler texture variable names that will be set in the shader.
  28949. */
  28950. samplers: string[];
  28951. /**
  28952. * Define statements that will be set in the shader.
  28953. */
  28954. defines: any;
  28955. /**
  28956. * Possible fallbacks for this effect to improve performance when needed.
  28957. */
  28958. fallbacks: Nullable<EffectFallbacks>;
  28959. /**
  28960. * Callback that will be called when the shader is compiled.
  28961. */
  28962. onCompiled: Nullable<(effect: Effect) => void>;
  28963. /**
  28964. * Callback that will be called if an error occurs during shader compilation.
  28965. */
  28966. onError: Nullable<(effect: Effect, errors: string) => void>;
  28967. /**
  28968. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28969. */
  28970. indexParameters: any;
  28971. /**
  28972. * Max number of lights that can be used in the shader.
  28973. */
  28974. maxSimultaneousLights: number;
  28975. /**
  28976. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28977. */
  28978. transformFeedbackVaryings: Nullable<string[]>;
  28979. }
  28980. /**
  28981. * Effect containing vertex and fragment shader that can be executed on an object.
  28982. */
  28983. export class Effect implements IDisposable {
  28984. /**
  28985. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28986. */
  28987. static ShadersRepository: string;
  28988. /**
  28989. * Name of the effect.
  28990. */
  28991. name: any;
  28992. /**
  28993. * String container all the define statements that should be set on the shader.
  28994. */
  28995. defines: string;
  28996. /**
  28997. * Callback that will be called when the shader is compiled.
  28998. */
  28999. onCompiled: Nullable<(effect: Effect) => void>;
  29000. /**
  29001. * Callback that will be called if an error occurs during shader compilation.
  29002. */
  29003. onError: Nullable<(effect: Effect, errors: string) => void>;
  29004. /**
  29005. * Callback that will be called when effect is bound.
  29006. */
  29007. onBind: Nullable<(effect: Effect) => void>;
  29008. /**
  29009. * Unique ID of the effect.
  29010. */
  29011. uniqueId: number;
  29012. /**
  29013. * Observable that will be called when the shader is compiled.
  29014. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29015. */
  29016. onCompileObservable: Observable<Effect>;
  29017. /**
  29018. * Observable that will be called if an error occurs during shader compilation.
  29019. */
  29020. onErrorObservable: Observable<Effect>;
  29021. /** @hidden */
  29022. _onBindObservable: Nullable<Observable<Effect>>;
  29023. /**
  29024. * Observable that will be called when effect is bound.
  29025. */
  29026. readonly onBindObservable: Observable<Effect>;
  29027. /** @hidden */
  29028. _bonesComputationForcedToCPU: boolean;
  29029. private static _uniqueIdSeed;
  29030. private _engine;
  29031. private _uniformBuffersNames;
  29032. private _uniformsNames;
  29033. private _samplerList;
  29034. private _samplers;
  29035. private _isReady;
  29036. private _compilationError;
  29037. private _attributesNames;
  29038. private _attributes;
  29039. private _uniforms;
  29040. /**
  29041. * Key for the effect.
  29042. * @hidden
  29043. */
  29044. _key: string;
  29045. private _indexParameters;
  29046. private _fallbacks;
  29047. private _vertexSourceCode;
  29048. private _fragmentSourceCode;
  29049. private _vertexSourceCodeOverride;
  29050. private _fragmentSourceCodeOverride;
  29051. private _transformFeedbackVaryings;
  29052. /**
  29053. * Compiled shader to webGL program.
  29054. * @hidden
  29055. */
  29056. _pipelineContext: Nullable<IPipelineContext>;
  29057. private _valueCache;
  29058. private static _baseCache;
  29059. /**
  29060. * Instantiates an effect.
  29061. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29062. * @param baseName Name of the effect.
  29063. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29064. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29065. * @param samplers List of sampler variables that will be passed to the shader.
  29066. * @param engine Engine to be used to render the effect
  29067. * @param defines Define statements to be added to the shader.
  29068. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29069. * @param onCompiled Callback that will be called when the shader is compiled.
  29070. * @param onError Callback that will be called if an error occurs during shader compilation.
  29071. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29072. */
  29073. 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);
  29074. private _useFinalCode;
  29075. /**
  29076. * Unique key for this effect
  29077. */
  29078. readonly key: string;
  29079. /**
  29080. * If the effect has been compiled and prepared.
  29081. * @returns if the effect is compiled and prepared.
  29082. */
  29083. isReady(): boolean;
  29084. /**
  29085. * The engine the effect was initialized with.
  29086. * @returns the engine.
  29087. */
  29088. getEngine(): Engine;
  29089. /**
  29090. * The pipeline context for this effect
  29091. * @returns the associated pipeline context
  29092. */
  29093. getPipelineContext(): Nullable<IPipelineContext>;
  29094. /**
  29095. * The set of names of attribute variables for the shader.
  29096. * @returns An array of attribute names.
  29097. */
  29098. getAttributesNames(): string[];
  29099. /**
  29100. * Returns the attribute at the given index.
  29101. * @param index The index of the attribute.
  29102. * @returns The location of the attribute.
  29103. */
  29104. getAttributeLocation(index: number): number;
  29105. /**
  29106. * Returns the attribute based on the name of the variable.
  29107. * @param name of the attribute to look up.
  29108. * @returns the attribute location.
  29109. */
  29110. getAttributeLocationByName(name: string): number;
  29111. /**
  29112. * The number of attributes.
  29113. * @returns the numnber of attributes.
  29114. */
  29115. getAttributesCount(): number;
  29116. /**
  29117. * Gets the index of a uniform variable.
  29118. * @param uniformName of the uniform to look up.
  29119. * @returns the index.
  29120. */
  29121. getUniformIndex(uniformName: string): number;
  29122. /**
  29123. * Returns the attribute based on the name of the variable.
  29124. * @param uniformName of the uniform to look up.
  29125. * @returns the location of the uniform.
  29126. */
  29127. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29128. /**
  29129. * Returns an array of sampler variable names
  29130. * @returns The array of sampler variable neames.
  29131. */
  29132. getSamplers(): string[];
  29133. /**
  29134. * The error from the last compilation.
  29135. * @returns the error string.
  29136. */
  29137. getCompilationError(): string;
  29138. /**
  29139. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29140. * @param func The callback to be used.
  29141. */
  29142. executeWhenCompiled(func: (effect: Effect) => void): void;
  29143. private _checkIsReady;
  29144. /** @hidden */
  29145. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29146. /** @hidden */
  29147. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29148. /** @hidden */
  29149. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29150. /**
  29151. * Recompiles the webGL program
  29152. * @param vertexSourceCode The source code for the vertex shader.
  29153. * @param fragmentSourceCode The source code for the fragment shader.
  29154. * @param onCompiled Callback called when completed.
  29155. * @param onError Callback called on error.
  29156. * @hidden
  29157. */
  29158. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29159. /**
  29160. * Prepares the effect
  29161. * @hidden
  29162. */
  29163. _prepareEffect(): void;
  29164. /**
  29165. * Checks if the effect is supported. (Must be called after compilation)
  29166. */
  29167. readonly isSupported: boolean;
  29168. /**
  29169. * Binds a texture to the engine to be used as output of the shader.
  29170. * @param channel Name of the output variable.
  29171. * @param texture Texture to bind.
  29172. * @hidden
  29173. */
  29174. _bindTexture(channel: string, texture: InternalTexture): void;
  29175. /**
  29176. * Sets a texture on the engine to be used in the shader.
  29177. * @param channel Name of the sampler variable.
  29178. * @param texture Texture to set.
  29179. */
  29180. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29181. /**
  29182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29183. * @param channel Name of the sampler variable.
  29184. * @param texture Texture to set.
  29185. */
  29186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29187. /**
  29188. * Sets an array of textures on the engine to be used in the shader.
  29189. * @param channel Name of the variable.
  29190. * @param textures Textures to set.
  29191. */
  29192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29193. /**
  29194. * 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)
  29195. * @param channel Name of the sampler variable.
  29196. * @param postProcess Post process to get the input texture from.
  29197. */
  29198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29199. /**
  29200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29201. * 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)
  29202. * @param channel Name of the sampler variable.
  29203. * @param postProcess Post process to get the output texture from.
  29204. */
  29205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29206. /** @hidden */
  29207. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29208. /** @hidden */
  29209. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29210. /** @hidden */
  29211. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29212. /** @hidden */
  29213. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29214. /**
  29215. * Binds a buffer to a uniform.
  29216. * @param buffer Buffer to bind.
  29217. * @param name Name of the uniform variable to bind to.
  29218. */
  29219. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29220. /**
  29221. * Binds block to a uniform.
  29222. * @param blockName Name of the block to bind.
  29223. * @param index Index to bind.
  29224. */
  29225. bindUniformBlock(blockName: string, index: number): void;
  29226. /**
  29227. * Sets an interger value on a uniform variable.
  29228. * @param uniformName Name of the variable.
  29229. * @param value Value to be set.
  29230. * @returns this effect.
  29231. */
  29232. setInt(uniformName: string, value: number): Effect;
  29233. /**
  29234. * Sets an int array on a uniform variable.
  29235. * @param uniformName Name of the variable.
  29236. * @param array array to be set.
  29237. * @returns this effect.
  29238. */
  29239. setIntArray(uniformName: string, array: Int32Array): Effect;
  29240. /**
  29241. * 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)
  29242. * @param uniformName Name of the variable.
  29243. * @param array array to be set.
  29244. * @returns this effect.
  29245. */
  29246. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29247. /**
  29248. * 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)
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29261. /**
  29262. * Sets an float array on a uniform variable.
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29275. /**
  29276. * 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)
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29289. /**
  29290. * Sets an array on a uniform variable.
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setArray(uniformName: string, array: number[]): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setArray2(uniformName: string, array: number[]): Effect;
  29303. /**
  29304. * 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)
  29305. * @param uniformName Name of the variable.
  29306. * @param array array to be set.
  29307. * @returns this effect.
  29308. */
  29309. setArray3(uniformName: string, array: number[]): Effect;
  29310. /**
  29311. * 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)
  29312. * @param uniformName Name of the variable.
  29313. * @param array array to be set.
  29314. * @returns this effect.
  29315. */
  29316. setArray4(uniformName: string, array: number[]): Effect;
  29317. /**
  29318. * Sets matrices on a uniform variable.
  29319. * @param uniformName Name of the variable.
  29320. * @param matrices matrices to be set.
  29321. * @returns this effect.
  29322. */
  29323. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29324. /**
  29325. * Sets matrix on a uniform variable.
  29326. * @param uniformName Name of the variable.
  29327. * @param matrix matrix to be set.
  29328. * @returns this effect.
  29329. */
  29330. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29331. /**
  29332. * 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)
  29333. * @param uniformName Name of the variable.
  29334. * @param matrix matrix to be set.
  29335. * @returns this effect.
  29336. */
  29337. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29338. /**
  29339. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29340. * @param uniformName Name of the variable.
  29341. * @param matrix matrix to be set.
  29342. * @returns this effect.
  29343. */
  29344. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29345. /**
  29346. * Sets a float on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param value value to be set.
  29349. * @returns this effect.
  29350. */
  29351. setFloat(uniformName: string, value: number): Effect;
  29352. /**
  29353. * Sets a boolean on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param bool value to be set.
  29356. * @returns this effect.
  29357. */
  29358. setBool(uniformName: string, bool: boolean): Effect;
  29359. /**
  29360. * Sets a Vector2 on a uniform variable.
  29361. * @param uniformName Name of the variable.
  29362. * @param vector2 vector2 to be set.
  29363. * @returns this effect.
  29364. */
  29365. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29366. /**
  29367. * Sets a float2 on a uniform variable.
  29368. * @param uniformName Name of the variable.
  29369. * @param x First float in float2.
  29370. * @param y Second float in float2.
  29371. * @returns this effect.
  29372. */
  29373. setFloat2(uniformName: string, x: number, y: number): Effect;
  29374. /**
  29375. * Sets a Vector3 on a uniform variable.
  29376. * @param uniformName Name of the variable.
  29377. * @param vector3 Value to be set.
  29378. * @returns this effect.
  29379. */
  29380. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29381. /**
  29382. * Sets a float3 on a uniform variable.
  29383. * @param uniformName Name of the variable.
  29384. * @param x First float in float3.
  29385. * @param y Second float in float3.
  29386. * @param z Third float in float3.
  29387. * @returns this effect.
  29388. */
  29389. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29390. /**
  29391. * Sets a Vector4 on a uniform variable.
  29392. * @param uniformName Name of the variable.
  29393. * @param vector4 Value to be set.
  29394. * @returns this effect.
  29395. */
  29396. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29397. /**
  29398. * Sets a float4 on a uniform variable.
  29399. * @param uniformName Name of the variable.
  29400. * @param x First float in float4.
  29401. * @param y Second float in float4.
  29402. * @param z Third float in float4.
  29403. * @param w Fourth float in float4.
  29404. * @returns this effect.
  29405. */
  29406. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29407. /**
  29408. * Sets a Color3 on a uniform variable.
  29409. * @param uniformName Name of the variable.
  29410. * @param color3 Value to be set.
  29411. * @returns this effect.
  29412. */
  29413. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29414. /**
  29415. * Sets a Color4 on a uniform variable.
  29416. * @param uniformName Name of the variable.
  29417. * @param color3 Value to be set.
  29418. * @param alpha Alpha value to be set.
  29419. * @returns this effect.
  29420. */
  29421. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29422. /**
  29423. * Sets a Color4 on a uniform variable
  29424. * @param uniformName defines the name of the variable
  29425. * @param color4 defines the value to be set
  29426. * @returns this effect.
  29427. */
  29428. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29429. /** Release all associated resources */
  29430. dispose(): void;
  29431. /**
  29432. * This function will add a new shader to the shader store
  29433. * @param name the name of the shader
  29434. * @param pixelShader optional pixel shader content
  29435. * @param vertexShader optional vertex shader content
  29436. */
  29437. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29438. /**
  29439. * Store of each shader (The can be looked up using effect.key)
  29440. */
  29441. static ShadersStore: {
  29442. [key: string]: string;
  29443. };
  29444. /**
  29445. * Store of each included file for a shader (The can be looked up using effect.key)
  29446. */
  29447. static IncludesShadersStore: {
  29448. [key: string]: string;
  29449. };
  29450. /**
  29451. * Resets the cache of effects.
  29452. */
  29453. static ResetCache(): void;
  29454. }
  29455. }
  29456. declare module "babylonjs/Materials/uniformBuffer" {
  29457. import { Nullable, FloatArray } from "babylonjs/types";
  29458. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29459. import { Engine } from "babylonjs/Engines/engine";
  29460. import { Effect } from "babylonjs/Materials/effect";
  29461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29462. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29463. import { Color3 } from "babylonjs/Maths/math.color";
  29464. /**
  29465. * Uniform buffer objects.
  29466. *
  29467. * Handles blocks of uniform on the GPU.
  29468. *
  29469. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29470. *
  29471. * For more information, please refer to :
  29472. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29473. */
  29474. export class UniformBuffer {
  29475. private _engine;
  29476. private _buffer;
  29477. private _data;
  29478. private _bufferData;
  29479. private _dynamic?;
  29480. private _uniformLocations;
  29481. private _uniformSizes;
  29482. private _uniformLocationPointer;
  29483. private _needSync;
  29484. private _noUBO;
  29485. private _currentEffect;
  29486. private static _MAX_UNIFORM_SIZE;
  29487. private static _tempBuffer;
  29488. /**
  29489. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29490. * This is dynamic to allow compat with webgl 1 and 2.
  29491. * You will need to pass the name of the uniform as well as the value.
  29492. */
  29493. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29494. /**
  29495. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29496. * This is dynamic to allow compat with webgl 1 and 2.
  29497. * You will need to pass the name of the uniform as well as the value.
  29498. */
  29499. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29500. /**
  29501. * Lambda to Update a single float in a uniform buffer.
  29502. * This is dynamic to allow compat with webgl 1 and 2.
  29503. * You will need to pass the name of the uniform as well as the value.
  29504. */
  29505. updateFloat: (name: string, x: number) => void;
  29506. /**
  29507. * Lambda to Update a vec2 of float in a uniform buffer.
  29508. * This is dynamic to allow compat with webgl 1 and 2.
  29509. * You will need to pass the name of the uniform as well as the value.
  29510. */
  29511. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29512. /**
  29513. * Lambda to Update a vec3 of float in a uniform buffer.
  29514. * This is dynamic to allow compat with webgl 1 and 2.
  29515. * You will need to pass the name of the uniform as well as the value.
  29516. */
  29517. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29518. /**
  29519. * Lambda to Update a vec4 of float in a uniform buffer.
  29520. * This is dynamic to allow compat with webgl 1 and 2.
  29521. * You will need to pass the name of the uniform as well as the value.
  29522. */
  29523. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29524. /**
  29525. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29526. * This is dynamic to allow compat with webgl 1 and 2.
  29527. * You will need to pass the name of the uniform as well as the value.
  29528. */
  29529. updateMatrix: (name: string, mat: Matrix) => void;
  29530. /**
  29531. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29532. * This is dynamic to allow compat with webgl 1 and 2.
  29533. * You will need to pass the name of the uniform as well as the value.
  29534. */
  29535. updateVector3: (name: string, vector: Vector3) => void;
  29536. /**
  29537. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29538. * This is dynamic to allow compat with webgl 1 and 2.
  29539. * You will need to pass the name of the uniform as well as the value.
  29540. */
  29541. updateVector4: (name: string, vector: Vector4) => void;
  29542. /**
  29543. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29544. * This is dynamic to allow compat with webgl 1 and 2.
  29545. * You will need to pass the name of the uniform as well as the value.
  29546. */
  29547. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29548. /**
  29549. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29550. * This is dynamic to allow compat with webgl 1 and 2.
  29551. * You will need to pass the name of the uniform as well as the value.
  29552. */
  29553. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29554. /**
  29555. * Instantiates a new Uniform buffer objects.
  29556. *
  29557. * Handles blocks of uniform on the GPU.
  29558. *
  29559. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29560. *
  29561. * For more information, please refer to :
  29562. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29563. * @param engine Define the engine the buffer is associated with
  29564. * @param data Define the data contained in the buffer
  29565. * @param dynamic Define if the buffer is updatable
  29566. */
  29567. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29568. /**
  29569. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29570. * or just falling back on setUniformXXX calls.
  29571. */
  29572. readonly useUbo: boolean;
  29573. /**
  29574. * Indicates if the WebGL underlying uniform buffer is in sync
  29575. * with the javascript cache data.
  29576. */
  29577. readonly isSync: boolean;
  29578. /**
  29579. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29580. * Also, a dynamic UniformBuffer will disable cache verification and always
  29581. * update the underlying WebGL uniform buffer to the GPU.
  29582. * @returns if Dynamic, otherwise false
  29583. */
  29584. isDynamic(): boolean;
  29585. /**
  29586. * The data cache on JS side.
  29587. * @returns the underlying data as a float array
  29588. */
  29589. getData(): Float32Array;
  29590. /**
  29591. * The underlying WebGL Uniform buffer.
  29592. * @returns the webgl buffer
  29593. */
  29594. getBuffer(): Nullable<DataBuffer>;
  29595. /**
  29596. * std140 layout specifies how to align data within an UBO structure.
  29597. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29598. * for specs.
  29599. */
  29600. private _fillAlignment;
  29601. /**
  29602. * Adds an uniform in the buffer.
  29603. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29604. * for the layout to be correct !
  29605. * @param name Name of the uniform, as used in the uniform block in the shader.
  29606. * @param size Data size, or data directly.
  29607. */
  29608. addUniform(name: string, size: number | number[]): void;
  29609. /**
  29610. * Adds a Matrix 4x4 to the uniform buffer.
  29611. * @param name Name of the uniform, as used in the uniform block in the shader.
  29612. * @param mat A 4x4 matrix.
  29613. */
  29614. addMatrix(name: string, mat: Matrix): void;
  29615. /**
  29616. * Adds a vec2 to the uniform buffer.
  29617. * @param name Name of the uniform, as used in the uniform block in the shader.
  29618. * @param x Define the x component value of the vec2
  29619. * @param y Define the y component value of the vec2
  29620. */
  29621. addFloat2(name: string, x: number, y: number): void;
  29622. /**
  29623. * Adds a vec3 to the uniform buffer.
  29624. * @param name Name of the uniform, as used in the uniform block in the shader.
  29625. * @param x Define the x component value of the vec3
  29626. * @param y Define the y component value of the vec3
  29627. * @param z Define the z component value of the vec3
  29628. */
  29629. addFloat3(name: string, x: number, y: number, z: number): void;
  29630. /**
  29631. * Adds a vec3 to the uniform buffer.
  29632. * @param name Name of the uniform, as used in the uniform block in the shader.
  29633. * @param color Define the vec3 from a Color
  29634. */
  29635. addColor3(name: string, color: Color3): void;
  29636. /**
  29637. * Adds a vec4 to the uniform buffer.
  29638. * @param name Name of the uniform, as used in the uniform block in the shader.
  29639. * @param color Define the rgb components from a Color
  29640. * @param alpha Define the a component of the vec4
  29641. */
  29642. addColor4(name: string, color: Color3, alpha: number): void;
  29643. /**
  29644. * Adds a vec3 to the uniform buffer.
  29645. * @param name Name of the uniform, as used in the uniform block in the shader.
  29646. * @param vector Define the vec3 components from a Vector
  29647. */
  29648. addVector3(name: string, vector: Vector3): void;
  29649. /**
  29650. * Adds a Matrix 3x3 to the uniform buffer.
  29651. * @param name Name of the uniform, as used in the uniform block in the shader.
  29652. */
  29653. addMatrix3x3(name: string): void;
  29654. /**
  29655. * Adds a Matrix 2x2 to the uniform buffer.
  29656. * @param name Name of the uniform, as used in the uniform block in the shader.
  29657. */
  29658. addMatrix2x2(name: string): void;
  29659. /**
  29660. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29661. */
  29662. create(): void;
  29663. /** @hidden */
  29664. _rebuild(): void;
  29665. /**
  29666. * Updates the WebGL Uniform Buffer on the GPU.
  29667. * If the `dynamic` flag is set to true, no cache comparison is done.
  29668. * Otherwise, the buffer will be updated only if the cache differs.
  29669. */
  29670. update(): void;
  29671. /**
  29672. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29673. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29674. * @param data Define the flattened data
  29675. * @param size Define the size of the data.
  29676. */
  29677. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29678. private _updateMatrix3x3ForUniform;
  29679. private _updateMatrix3x3ForEffect;
  29680. private _updateMatrix2x2ForEffect;
  29681. private _updateMatrix2x2ForUniform;
  29682. private _updateFloatForEffect;
  29683. private _updateFloatForUniform;
  29684. private _updateFloat2ForEffect;
  29685. private _updateFloat2ForUniform;
  29686. private _updateFloat3ForEffect;
  29687. private _updateFloat3ForUniform;
  29688. private _updateFloat4ForEffect;
  29689. private _updateFloat4ForUniform;
  29690. private _updateMatrixForEffect;
  29691. private _updateMatrixForUniform;
  29692. private _updateVector3ForEffect;
  29693. private _updateVector3ForUniform;
  29694. private _updateVector4ForEffect;
  29695. private _updateVector4ForUniform;
  29696. private _updateColor3ForEffect;
  29697. private _updateColor3ForUniform;
  29698. private _updateColor4ForEffect;
  29699. private _updateColor4ForUniform;
  29700. /**
  29701. * Sets a sampler uniform on the effect.
  29702. * @param name Define the name of the sampler.
  29703. * @param texture Define the texture to set in the sampler
  29704. */
  29705. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29706. /**
  29707. * Directly updates the value of the uniform in the cache AND on the GPU.
  29708. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29709. * @param data Define the flattened data
  29710. */
  29711. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29712. /**
  29713. * Binds this uniform buffer to an effect.
  29714. * @param effect Define the effect to bind the buffer to
  29715. * @param name Name of the uniform block in the shader.
  29716. */
  29717. bindToEffect(effect: Effect, name: string): void;
  29718. /**
  29719. * Disposes the uniform buffer.
  29720. */
  29721. dispose(): void;
  29722. }
  29723. }
  29724. declare module "babylonjs/Audio/analyser" {
  29725. import { Scene } from "babylonjs/scene";
  29726. /**
  29727. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29729. */
  29730. export class Analyser {
  29731. /**
  29732. * Gets or sets the smoothing
  29733. * @ignorenaming
  29734. */
  29735. SMOOTHING: number;
  29736. /**
  29737. * Gets or sets the FFT table size
  29738. * @ignorenaming
  29739. */
  29740. FFT_SIZE: number;
  29741. /**
  29742. * Gets or sets the bar graph amplitude
  29743. * @ignorenaming
  29744. */
  29745. BARGRAPHAMPLITUDE: number;
  29746. /**
  29747. * Gets or sets the position of the debug canvas
  29748. * @ignorenaming
  29749. */
  29750. DEBUGCANVASPOS: {
  29751. x: number;
  29752. y: number;
  29753. };
  29754. /**
  29755. * Gets or sets the debug canvas size
  29756. * @ignorenaming
  29757. */
  29758. DEBUGCANVASSIZE: {
  29759. width: number;
  29760. height: number;
  29761. };
  29762. private _byteFreqs;
  29763. private _byteTime;
  29764. private _floatFreqs;
  29765. private _webAudioAnalyser;
  29766. private _debugCanvas;
  29767. private _debugCanvasContext;
  29768. private _scene;
  29769. private _registerFunc;
  29770. private _audioEngine;
  29771. /**
  29772. * Creates a new analyser
  29773. * @param scene defines hosting scene
  29774. */
  29775. constructor(scene: Scene);
  29776. /**
  29777. * Get the number of data values you will have to play with for the visualization
  29778. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29779. * @returns a number
  29780. */
  29781. getFrequencyBinCount(): number;
  29782. /**
  29783. * Gets the current frequency data as a byte array
  29784. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29785. * @returns a Uint8Array
  29786. */
  29787. getByteFrequencyData(): Uint8Array;
  29788. /**
  29789. * Gets the current waveform as a byte array
  29790. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29791. * @returns a Uint8Array
  29792. */
  29793. getByteTimeDomainData(): Uint8Array;
  29794. /**
  29795. * Gets the current frequency data as a float array
  29796. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29797. * @returns a Float32Array
  29798. */
  29799. getFloatFrequencyData(): Float32Array;
  29800. /**
  29801. * Renders the debug canvas
  29802. */
  29803. drawDebugCanvas(): void;
  29804. /**
  29805. * Stops rendering the debug canvas and removes it
  29806. */
  29807. stopDebugCanvas(): void;
  29808. /**
  29809. * Connects two audio nodes
  29810. * @param inputAudioNode defines first node to connect
  29811. * @param outputAudioNode defines second node to connect
  29812. */
  29813. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29814. /**
  29815. * Releases all associated resources
  29816. */
  29817. dispose(): void;
  29818. }
  29819. }
  29820. declare module "babylonjs/Audio/audioEngine" {
  29821. import { IDisposable } from "babylonjs/scene";
  29822. import { Analyser } from "babylonjs/Audio/analyser";
  29823. import { Nullable } from "babylonjs/types";
  29824. import { Observable } from "babylonjs/Misc/observable";
  29825. /**
  29826. * This represents an audio engine and it is responsible
  29827. * to play, synchronize and analyse sounds throughout the application.
  29828. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29829. */
  29830. export interface IAudioEngine extends IDisposable {
  29831. /**
  29832. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29833. */
  29834. readonly canUseWebAudio: boolean;
  29835. /**
  29836. * Gets the current AudioContext if available.
  29837. */
  29838. readonly audioContext: Nullable<AudioContext>;
  29839. /**
  29840. * The master gain node defines the global audio volume of your audio engine.
  29841. */
  29842. readonly masterGain: GainNode;
  29843. /**
  29844. * Gets whether or not mp3 are supported by your browser.
  29845. */
  29846. readonly isMP3supported: boolean;
  29847. /**
  29848. * Gets whether or not ogg are supported by your browser.
  29849. */
  29850. readonly isOGGsupported: boolean;
  29851. /**
  29852. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29853. * @ignoreNaming
  29854. */
  29855. WarnedWebAudioUnsupported: boolean;
  29856. /**
  29857. * Defines if the audio engine relies on a custom unlocked button.
  29858. * In this case, the embedded button will not be displayed.
  29859. */
  29860. useCustomUnlockedButton: boolean;
  29861. /**
  29862. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29863. */
  29864. readonly unlocked: boolean;
  29865. /**
  29866. * Event raised when audio has been unlocked on the browser.
  29867. */
  29868. onAudioUnlockedObservable: Observable<AudioEngine>;
  29869. /**
  29870. * Event raised when audio has been locked on the browser.
  29871. */
  29872. onAudioLockedObservable: Observable<AudioEngine>;
  29873. /**
  29874. * Flags the audio engine in Locked state.
  29875. * This happens due to new browser policies preventing audio to autoplay.
  29876. */
  29877. lock(): void;
  29878. /**
  29879. * Unlocks the audio engine once a user action has been done on the dom.
  29880. * This is helpful to resume play once browser policies have been satisfied.
  29881. */
  29882. unlock(): void;
  29883. }
  29884. /**
  29885. * This represents the default audio engine used in babylon.
  29886. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29887. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29888. */
  29889. export class AudioEngine implements IAudioEngine {
  29890. private _audioContext;
  29891. private _audioContextInitialized;
  29892. private _muteButton;
  29893. private _hostElement;
  29894. /**
  29895. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29896. */
  29897. canUseWebAudio: boolean;
  29898. /**
  29899. * The master gain node defines the global audio volume of your audio engine.
  29900. */
  29901. masterGain: GainNode;
  29902. /**
  29903. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29904. * @ignoreNaming
  29905. */
  29906. WarnedWebAudioUnsupported: boolean;
  29907. /**
  29908. * Gets whether or not mp3 are supported by your browser.
  29909. */
  29910. isMP3supported: boolean;
  29911. /**
  29912. * Gets whether or not ogg are supported by your browser.
  29913. */
  29914. isOGGsupported: boolean;
  29915. /**
  29916. * Gets whether audio has been unlocked on the device.
  29917. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29918. * a user interaction has happened.
  29919. */
  29920. unlocked: boolean;
  29921. /**
  29922. * Defines if the audio engine relies on a custom unlocked button.
  29923. * In this case, the embedded button will not be displayed.
  29924. */
  29925. useCustomUnlockedButton: boolean;
  29926. /**
  29927. * Event raised when audio has been unlocked on the browser.
  29928. */
  29929. onAudioUnlockedObservable: Observable<AudioEngine>;
  29930. /**
  29931. * Event raised when audio has been locked on the browser.
  29932. */
  29933. onAudioLockedObservable: Observable<AudioEngine>;
  29934. /**
  29935. * Gets the current AudioContext if available.
  29936. */
  29937. readonly audioContext: Nullable<AudioContext>;
  29938. private _connectedAnalyser;
  29939. /**
  29940. * Instantiates a new audio engine.
  29941. *
  29942. * There should be only one per page as some browsers restrict the number
  29943. * of audio contexts you can create.
  29944. * @param hostElement defines the host element where to display the mute icon if necessary
  29945. */
  29946. constructor(hostElement?: Nullable<HTMLElement>);
  29947. /**
  29948. * Flags the audio engine in Locked state.
  29949. * This happens due to new browser policies preventing audio to autoplay.
  29950. */
  29951. lock(): void;
  29952. /**
  29953. * Unlocks the audio engine once a user action has been done on the dom.
  29954. * This is helpful to resume play once browser policies have been satisfied.
  29955. */
  29956. unlock(): void;
  29957. private _resumeAudioContext;
  29958. private _initializeAudioContext;
  29959. private _tryToRun;
  29960. private _triggerRunningState;
  29961. private _triggerSuspendedState;
  29962. private _displayMuteButton;
  29963. private _moveButtonToTopLeft;
  29964. private _onResize;
  29965. private _hideMuteButton;
  29966. /**
  29967. * Destroy and release the resources associated with the audio ccontext.
  29968. */
  29969. dispose(): void;
  29970. /**
  29971. * Gets the global volume sets on the master gain.
  29972. * @returns the global volume if set or -1 otherwise
  29973. */
  29974. getGlobalVolume(): number;
  29975. /**
  29976. * Sets the global volume of your experience (sets on the master gain).
  29977. * @param newVolume Defines the new global volume of the application
  29978. */
  29979. setGlobalVolume(newVolume: number): void;
  29980. /**
  29981. * Connect the audio engine to an audio analyser allowing some amazing
  29982. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29983. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29984. * @param analyser The analyser to connect to the engine
  29985. */
  29986. connectToAnalyser(analyser: Analyser): void;
  29987. }
  29988. }
  29989. declare module "babylonjs/Loading/loadingScreen" {
  29990. /**
  29991. * Interface used to present a loading screen while loading a scene
  29992. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29993. */
  29994. export interface ILoadingScreen {
  29995. /**
  29996. * Function called to display the loading screen
  29997. */
  29998. displayLoadingUI: () => void;
  29999. /**
  30000. * Function called to hide the loading screen
  30001. */
  30002. hideLoadingUI: () => void;
  30003. /**
  30004. * Gets or sets the color to use for the background
  30005. */
  30006. loadingUIBackgroundColor: string;
  30007. /**
  30008. * Gets or sets the text to display while loading
  30009. */
  30010. loadingUIText: string;
  30011. }
  30012. /**
  30013. * Class used for the default loading screen
  30014. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30015. */
  30016. export class DefaultLoadingScreen implements ILoadingScreen {
  30017. private _renderingCanvas;
  30018. private _loadingText;
  30019. private _loadingDivBackgroundColor;
  30020. private _loadingDiv;
  30021. private _loadingTextDiv;
  30022. /** Gets or sets the logo url to use for the default loading screen */
  30023. static DefaultLogoUrl: string;
  30024. /** Gets or sets the spinner url to use for the default loading screen */
  30025. static DefaultSpinnerUrl: string;
  30026. /**
  30027. * Creates a new default loading screen
  30028. * @param _renderingCanvas defines the canvas used to render the scene
  30029. * @param _loadingText defines the default text to display
  30030. * @param _loadingDivBackgroundColor defines the default background color
  30031. */
  30032. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30033. /**
  30034. * Function called to display the loading screen
  30035. */
  30036. displayLoadingUI(): void;
  30037. /**
  30038. * Function called to hide the loading screen
  30039. */
  30040. hideLoadingUI(): void;
  30041. /**
  30042. * Gets or sets the text to display while loading
  30043. */
  30044. loadingUIText: string;
  30045. /**
  30046. * Gets or sets the color to use for the background
  30047. */
  30048. loadingUIBackgroundColor: string;
  30049. private _resizeLoadingUI;
  30050. }
  30051. }
  30052. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30053. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30054. import { Engine } from "babylonjs/Engines/engine";
  30055. import { Nullable } from "babylonjs/types";
  30056. /** @hidden */
  30057. export class WebGLPipelineContext implements IPipelineContext {
  30058. engine: Engine;
  30059. program: Nullable<WebGLProgram>;
  30060. context?: WebGLRenderingContext;
  30061. vertexShader?: WebGLShader;
  30062. fragmentShader?: WebGLShader;
  30063. isParallelCompiled: boolean;
  30064. onCompiled?: () => void;
  30065. transformFeedback?: WebGLTransformFeedback | null;
  30066. readonly isAsync: boolean;
  30067. readonly isReady: boolean;
  30068. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30069. }
  30070. }
  30071. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30072. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30073. /** @hidden */
  30074. export class WebGLDataBuffer extends DataBuffer {
  30075. private _buffer;
  30076. constructor(resource: WebGLBuffer);
  30077. readonly underlyingResource: any;
  30078. }
  30079. }
  30080. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30081. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30082. /** @hidden */
  30083. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30084. attributeProcessor(attribute: string): string;
  30085. varyingProcessor(varying: string, isFragment: boolean): string;
  30086. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30087. }
  30088. }
  30089. declare module "babylonjs/Misc/perfCounter" {
  30090. /**
  30091. * This class is used to track a performance counter which is number based.
  30092. * The user has access to many properties which give statistics of different nature.
  30093. *
  30094. * The implementer can track two kinds of Performance Counter: time and count.
  30095. * 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.
  30096. * 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.
  30097. */
  30098. export class PerfCounter {
  30099. /**
  30100. * Gets or sets a global boolean to turn on and off all the counters
  30101. */
  30102. static Enabled: boolean;
  30103. /**
  30104. * Returns the smallest value ever
  30105. */
  30106. readonly min: number;
  30107. /**
  30108. * Returns the biggest value ever
  30109. */
  30110. readonly max: number;
  30111. /**
  30112. * Returns the average value since the performance counter is running
  30113. */
  30114. readonly average: number;
  30115. /**
  30116. * Returns the average value of the last second the counter was monitored
  30117. */
  30118. readonly lastSecAverage: number;
  30119. /**
  30120. * Returns the current value
  30121. */
  30122. readonly current: number;
  30123. /**
  30124. * Gets the accumulated total
  30125. */
  30126. readonly total: number;
  30127. /**
  30128. * Gets the total value count
  30129. */
  30130. readonly count: number;
  30131. /**
  30132. * Creates a new counter
  30133. */
  30134. constructor();
  30135. /**
  30136. * Call this method to start monitoring a new frame.
  30137. * 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.
  30138. */
  30139. fetchNewFrame(): void;
  30140. /**
  30141. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30142. * @param newCount the count value to add to the monitored count
  30143. * @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.
  30144. */
  30145. addCount(newCount: number, fetchResult: boolean): void;
  30146. /**
  30147. * Start monitoring this performance counter
  30148. */
  30149. beginMonitoring(): void;
  30150. /**
  30151. * Compute the time lapsed since the previous beginMonitoring() call.
  30152. * @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
  30153. */
  30154. endMonitoring(newFrame?: boolean): void;
  30155. private _fetchResult;
  30156. private _startMonitoringTime;
  30157. private _min;
  30158. private _max;
  30159. private _average;
  30160. private _current;
  30161. private _totalValueCount;
  30162. private _totalAccumulated;
  30163. private _lastSecAverage;
  30164. private _lastSecAccumulated;
  30165. private _lastSecTime;
  30166. private _lastSecValueCount;
  30167. }
  30168. }
  30169. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30170. /**
  30171. * Interface for any object that can request an animation frame
  30172. */
  30173. export interface ICustomAnimationFrameRequester {
  30174. /**
  30175. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30176. */
  30177. renderFunction?: Function;
  30178. /**
  30179. * Called to request the next frame to render to
  30180. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30181. */
  30182. requestAnimationFrame: Function;
  30183. /**
  30184. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30185. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30186. */
  30187. requestID?: number;
  30188. }
  30189. }
  30190. declare module "babylonjs/Materials/Textures/videoTexture" {
  30191. import { Observable } from "babylonjs/Misc/observable";
  30192. import { Nullable } from "babylonjs/types";
  30193. import { Scene } from "babylonjs/scene";
  30194. import { Texture } from "babylonjs/Materials/Textures/texture";
  30195. /**
  30196. * Settings for finer control over video usage
  30197. */
  30198. export interface VideoTextureSettings {
  30199. /**
  30200. * Applies `autoplay` to video, if specified
  30201. */
  30202. autoPlay?: boolean;
  30203. /**
  30204. * Applies `loop` to video, if specified
  30205. */
  30206. loop?: boolean;
  30207. /**
  30208. * Automatically updates internal texture from video at every frame in the render loop
  30209. */
  30210. autoUpdateTexture: boolean;
  30211. /**
  30212. * Image src displayed during the video loading or until the user interacts with the video.
  30213. */
  30214. poster?: string;
  30215. }
  30216. /**
  30217. * If you want to display a video in your scene, this is the special texture for that.
  30218. * This special texture works similar to other textures, with the exception of a few parameters.
  30219. * @see https://doc.babylonjs.com/how_to/video_texture
  30220. */
  30221. export class VideoTexture extends Texture {
  30222. /**
  30223. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30224. */
  30225. readonly autoUpdateTexture: boolean;
  30226. /**
  30227. * The video instance used by the texture internally
  30228. */
  30229. readonly video: HTMLVideoElement;
  30230. private _onUserActionRequestedObservable;
  30231. /**
  30232. * Event triggerd when a dom action is required by the user to play the video.
  30233. * This happens due to recent changes in browser policies preventing video to auto start.
  30234. */
  30235. readonly onUserActionRequestedObservable: Observable<Texture>;
  30236. private _generateMipMaps;
  30237. private _engine;
  30238. private _stillImageCaptured;
  30239. private _displayingPosterTexture;
  30240. private _settings;
  30241. private _createInternalTextureOnEvent;
  30242. /**
  30243. * Creates a video texture.
  30244. * If you want to display a video in your scene, this is the special texture for that.
  30245. * This special texture works similar to other textures, with the exception of a few parameters.
  30246. * @see https://doc.babylonjs.com/how_to/video_texture
  30247. * @param name optional name, will detect from video source, if not defined
  30248. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30249. * @param scene is obviously the current scene.
  30250. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30251. * @param invertY is false by default but can be used to invert video on Y axis
  30252. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30253. * @param settings allows finer control over video usage
  30254. */
  30255. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30256. private _getName;
  30257. private _getVideo;
  30258. private _createInternalTexture;
  30259. private reset;
  30260. /**
  30261. * @hidden Internal method to initiate `update`.
  30262. */
  30263. _rebuild(): void;
  30264. /**
  30265. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30266. */
  30267. update(): void;
  30268. /**
  30269. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30270. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30271. */
  30272. updateTexture(isVisible: boolean): void;
  30273. protected _updateInternalTexture: () => void;
  30274. /**
  30275. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30276. * @param url New url.
  30277. */
  30278. updateURL(url: string): void;
  30279. /**
  30280. * Dispose the texture and release its associated resources.
  30281. */
  30282. dispose(): void;
  30283. /**
  30284. * Creates a video texture straight from a stream.
  30285. * @param scene Define the scene the texture should be created in
  30286. * @param stream Define the stream the texture should be created from
  30287. * @returns The created video texture as a promise
  30288. */
  30289. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30290. /**
  30291. * Creates a video texture straight from your WebCam video feed.
  30292. * @param scene Define the scene the texture should be created in
  30293. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30294. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30295. * @returns The created video texture as a promise
  30296. */
  30297. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30298. minWidth: number;
  30299. maxWidth: number;
  30300. minHeight: number;
  30301. maxHeight: number;
  30302. deviceId: string;
  30303. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30304. /**
  30305. * Creates a video texture straight from your WebCam video feed.
  30306. * @param scene Define the scene the texture should be created in
  30307. * @param onReady Define a callback to triggered once the texture will be ready
  30308. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30309. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30310. */
  30311. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30312. minWidth: number;
  30313. maxWidth: number;
  30314. minHeight: number;
  30315. maxHeight: number;
  30316. deviceId: string;
  30317. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30318. }
  30319. }
  30320. declare module "babylonjs/Engines/engine" {
  30321. import { Observable } from "babylonjs/Misc/observable";
  30322. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30323. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30324. import { Scene } from "babylonjs/scene";
  30325. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30326. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30327. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30328. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30331. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30332. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30333. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30334. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30335. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30336. import { WebRequest } from "babylonjs/Misc/webRequest";
  30337. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30338. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30340. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30341. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30343. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30344. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30345. import { Material } from "babylonjs/Materials/material";
  30346. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30347. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30348. /**
  30349. * Defines the interface used by objects containing a viewport (like a camera)
  30350. */
  30351. interface IViewportOwnerLike {
  30352. /**
  30353. * Gets or sets the viewport
  30354. */
  30355. viewport: IViewportLike;
  30356. }
  30357. /**
  30358. * Interface for attribute information associated with buffer instanciation
  30359. */
  30360. export class InstancingAttributeInfo {
  30361. /**
  30362. * Index/offset of the attribute in the vertex shader
  30363. */
  30364. index: number;
  30365. /**
  30366. * size of the attribute, 1, 2, 3 or 4
  30367. */
  30368. attributeSize: number;
  30369. /**
  30370. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30371. * default is FLOAT
  30372. */
  30373. attribyteType: number;
  30374. /**
  30375. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30376. */
  30377. normalized: boolean;
  30378. /**
  30379. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30380. */
  30381. offset: number;
  30382. /**
  30383. * Name of the GLSL attribute, for debugging purpose only
  30384. */
  30385. attributeName: string;
  30386. }
  30387. /**
  30388. * Define options used to create a depth texture
  30389. */
  30390. export class DepthTextureCreationOptions {
  30391. /** Specifies whether or not a stencil should be allocated in the texture */
  30392. generateStencil?: boolean;
  30393. /** Specifies whether or not bilinear filtering is enable on the texture */
  30394. bilinearFiltering?: boolean;
  30395. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30396. comparisonFunction?: number;
  30397. /** Specifies if the created texture is a cube texture */
  30398. isCube?: boolean;
  30399. }
  30400. /**
  30401. * Class used to describe the capabilities of the engine relatively to the current browser
  30402. */
  30403. export class EngineCapabilities {
  30404. /** Maximum textures units per fragment shader */
  30405. maxTexturesImageUnits: number;
  30406. /** Maximum texture units per vertex shader */
  30407. maxVertexTextureImageUnits: number;
  30408. /** Maximum textures units in the entire pipeline */
  30409. maxCombinedTexturesImageUnits: number;
  30410. /** Maximum texture size */
  30411. maxTextureSize: number;
  30412. /** Maximum cube texture size */
  30413. maxCubemapTextureSize: number;
  30414. /** Maximum render texture size */
  30415. maxRenderTextureSize: number;
  30416. /** Maximum number of vertex attributes */
  30417. maxVertexAttribs: number;
  30418. /** Maximum number of varyings */
  30419. maxVaryingVectors: number;
  30420. /** Maximum number of uniforms per vertex shader */
  30421. maxVertexUniformVectors: number;
  30422. /** Maximum number of uniforms per fragment shader */
  30423. maxFragmentUniformVectors: number;
  30424. /** Defines if standard derivates (dx/dy) are supported */
  30425. standardDerivatives: boolean;
  30426. /** Defines if s3tc texture compression is supported */
  30427. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30428. /** Defines if pvrtc texture compression is supported */
  30429. pvrtc: any;
  30430. /** Defines if etc1 texture compression is supported */
  30431. etc1: any;
  30432. /** Defines if etc2 texture compression is supported */
  30433. etc2: any;
  30434. /** Defines if astc texture compression is supported */
  30435. astc: any;
  30436. /** Defines if float textures are supported */
  30437. textureFloat: boolean;
  30438. /** Defines if vertex array objects are supported */
  30439. vertexArrayObject: boolean;
  30440. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30441. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30442. /** Gets the maximum level of anisotropy supported */
  30443. maxAnisotropy: number;
  30444. /** Defines if instancing is supported */
  30445. instancedArrays: boolean;
  30446. /** Defines if 32 bits indices are supported */
  30447. uintIndices: boolean;
  30448. /** Defines if high precision shaders are supported */
  30449. highPrecisionShaderSupported: boolean;
  30450. /** Defines if depth reading in the fragment shader is supported */
  30451. fragmentDepthSupported: boolean;
  30452. /** Defines if float texture linear filtering is supported*/
  30453. textureFloatLinearFiltering: boolean;
  30454. /** Defines if rendering to float textures is supported */
  30455. textureFloatRender: boolean;
  30456. /** Defines if half float textures are supported*/
  30457. textureHalfFloat: boolean;
  30458. /** Defines if half float texture linear filtering is supported*/
  30459. textureHalfFloatLinearFiltering: boolean;
  30460. /** Defines if rendering to half float textures is supported */
  30461. textureHalfFloatRender: boolean;
  30462. /** Defines if textureLOD shader command is supported */
  30463. textureLOD: boolean;
  30464. /** Defines if draw buffers extension is supported */
  30465. drawBuffersExtension: boolean;
  30466. /** Defines if depth textures are supported */
  30467. depthTextureExtension: boolean;
  30468. /** Defines if float color buffer are supported */
  30469. colorBufferFloat: boolean;
  30470. /** Gets disjoint timer query extension (null if not supported) */
  30471. timerQuery: EXT_disjoint_timer_query;
  30472. /** Defines if timestamp can be used with timer query */
  30473. canUseTimestampForTimerQuery: boolean;
  30474. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30475. multiview: any;
  30476. /** Function used to let the system compiles shaders in background */
  30477. parallelShaderCompile: {
  30478. COMPLETION_STATUS_KHR: number;
  30479. };
  30480. }
  30481. /** Interface defining initialization parameters for Engine class */
  30482. export interface EngineOptions extends WebGLContextAttributes {
  30483. /**
  30484. * Defines if the engine should no exceed a specified device ratio
  30485. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30486. */
  30487. limitDeviceRatio?: number;
  30488. /**
  30489. * Defines if webvr should be enabled automatically
  30490. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30491. */
  30492. autoEnableWebVR?: boolean;
  30493. /**
  30494. * Defines if webgl2 should be turned off even if supported
  30495. * @see http://doc.babylonjs.com/features/webgl2
  30496. */
  30497. disableWebGL2Support?: boolean;
  30498. /**
  30499. * Defines if webaudio should be initialized as well
  30500. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30501. */
  30502. audioEngine?: boolean;
  30503. /**
  30504. * Defines if animations should run using a deterministic lock step
  30505. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30506. */
  30507. deterministicLockstep?: boolean;
  30508. /** Defines the maximum steps to use with deterministic lock step mode */
  30509. lockstepMaxSteps?: number;
  30510. /**
  30511. * Defines that engine should ignore context lost events
  30512. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30513. */
  30514. doNotHandleContextLost?: boolean;
  30515. /**
  30516. * Defines that engine should ignore modifying touch action attribute and style
  30517. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30518. */
  30519. doNotHandleTouchAction?: boolean;
  30520. /**
  30521. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30522. */
  30523. useHighPrecisionFloats?: boolean;
  30524. }
  30525. /**
  30526. * Defines the interface used by display changed events
  30527. */
  30528. export interface IDisplayChangedEventArgs {
  30529. /** Gets the vrDisplay object (if any) */
  30530. vrDisplay: Nullable<any>;
  30531. /** Gets a boolean indicating if webVR is supported */
  30532. vrSupported: boolean;
  30533. }
  30534. /**
  30535. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30536. */
  30537. export class Engine {
  30538. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30539. static ExceptionList: ({
  30540. key: string;
  30541. capture: string;
  30542. captureConstraint: number;
  30543. targets: string[];
  30544. } | {
  30545. key: string;
  30546. capture: null;
  30547. captureConstraint: null;
  30548. targets: string[];
  30549. })[];
  30550. /** Gets the list of created engines */
  30551. static readonly Instances: Engine[];
  30552. /**
  30553. * Gets the latest created engine
  30554. */
  30555. static readonly LastCreatedEngine: Nullable<Engine>;
  30556. /**
  30557. * Gets the latest created scene
  30558. */
  30559. static readonly LastCreatedScene: Nullable<Scene>;
  30560. /**
  30561. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30562. * @param flag defines which part of the materials must be marked as dirty
  30563. * @param predicate defines a predicate used to filter which materials should be affected
  30564. */
  30565. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30566. /** @hidden */
  30567. static _TextureLoaders: IInternalTextureLoader[];
  30568. /** Defines that alpha blending is disabled */
  30569. static readonly ALPHA_DISABLE: number;
  30570. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30571. static readonly ALPHA_ADD: number;
  30572. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30573. static readonly ALPHA_COMBINE: number;
  30574. /** Defines that alpha blending to DEST - SRC * DEST */
  30575. static readonly ALPHA_SUBTRACT: number;
  30576. /** Defines that alpha blending to SRC * DEST */
  30577. static readonly ALPHA_MULTIPLY: number;
  30578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30579. static readonly ALPHA_MAXIMIZED: number;
  30580. /** Defines that alpha blending to SRC + DEST */
  30581. static readonly ALPHA_ONEONE: number;
  30582. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30583. static readonly ALPHA_PREMULTIPLIED: number;
  30584. /**
  30585. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30586. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30587. */
  30588. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30589. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30590. static readonly ALPHA_INTERPOLATE: number;
  30591. /**
  30592. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30593. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30594. */
  30595. static readonly ALPHA_SCREENMODE: number;
  30596. /** Defines that the ressource is not delayed*/
  30597. static readonly DELAYLOADSTATE_NONE: number;
  30598. /** Defines that the ressource was successfully delay loaded */
  30599. static readonly DELAYLOADSTATE_LOADED: number;
  30600. /** Defines that the ressource is currently delay loading */
  30601. static readonly DELAYLOADSTATE_LOADING: number;
  30602. /** Defines that the ressource is delayed and has not started loading */
  30603. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30605. static readonly NEVER: number;
  30606. /** 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 */
  30607. static readonly ALWAYS: number;
  30608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30609. static readonly LESS: number;
  30610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30611. static readonly EQUAL: number;
  30612. /** 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 */
  30613. static readonly LEQUAL: number;
  30614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30615. static readonly GREATER: number;
  30616. /** 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 */
  30617. static readonly GEQUAL: number;
  30618. /** 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 */
  30619. static readonly NOTEQUAL: number;
  30620. /** Passed to stencilOperation to specify that stencil value must be kept */
  30621. static readonly KEEP: number;
  30622. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30623. static readonly REPLACE: number;
  30624. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30625. static readonly INCR: number;
  30626. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30627. static readonly DECR: number;
  30628. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30629. static readonly INVERT: number;
  30630. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30631. static readonly INCR_WRAP: number;
  30632. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30633. static readonly DECR_WRAP: number;
  30634. /** Texture is not repeating outside of 0..1 UVs */
  30635. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30636. /** Texture is repeating outside of 0..1 UVs */
  30637. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30638. /** Texture is repeating and mirrored */
  30639. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30640. /** ALPHA */
  30641. static readonly TEXTUREFORMAT_ALPHA: number;
  30642. /** LUMINANCE */
  30643. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30644. /** LUMINANCE_ALPHA */
  30645. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30646. /** RGB */
  30647. static readonly TEXTUREFORMAT_RGB: number;
  30648. /** RGBA */
  30649. static readonly TEXTUREFORMAT_RGBA: number;
  30650. /** RED */
  30651. static readonly TEXTUREFORMAT_RED: number;
  30652. /** RED (2nd reference) */
  30653. static readonly TEXTUREFORMAT_R: number;
  30654. /** RG */
  30655. static readonly TEXTUREFORMAT_RG: number;
  30656. /** RED_INTEGER */
  30657. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30658. /** RED_INTEGER (2nd reference) */
  30659. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30660. /** RG_INTEGER */
  30661. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30662. /** RGB_INTEGER */
  30663. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30664. /** RGBA_INTEGER */
  30665. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30666. /** UNSIGNED_BYTE */
  30667. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30668. /** UNSIGNED_BYTE (2nd reference) */
  30669. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30670. /** FLOAT */
  30671. static readonly TEXTURETYPE_FLOAT: number;
  30672. /** HALF_FLOAT */
  30673. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30674. /** BYTE */
  30675. static readonly TEXTURETYPE_BYTE: number;
  30676. /** SHORT */
  30677. static readonly TEXTURETYPE_SHORT: number;
  30678. /** UNSIGNED_SHORT */
  30679. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30680. /** INT */
  30681. static readonly TEXTURETYPE_INT: number;
  30682. /** UNSIGNED_INT */
  30683. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30684. /** UNSIGNED_SHORT_4_4_4_4 */
  30685. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30686. /** UNSIGNED_SHORT_5_5_5_1 */
  30687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30688. /** UNSIGNED_SHORT_5_6_5 */
  30689. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30690. /** UNSIGNED_INT_2_10_10_10_REV */
  30691. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30692. /** UNSIGNED_INT_24_8 */
  30693. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30694. /** UNSIGNED_INT_10F_11F_11F_REV */
  30695. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30696. /** UNSIGNED_INT_5_9_9_9_REV */
  30697. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30698. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30699. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30700. /** nearest is mag = nearest and min = nearest and mip = linear */
  30701. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30702. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30703. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30704. /** Trilinear is mag = linear and min = linear and mip = linear */
  30705. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30706. /** nearest is mag = nearest and min = nearest and mip = linear */
  30707. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30709. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30710. /** Trilinear is mag = linear and min = linear and mip = linear */
  30711. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30712. /** mag = nearest and min = nearest and mip = nearest */
  30713. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30714. /** mag = nearest and min = linear and mip = nearest */
  30715. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30716. /** mag = nearest and min = linear and mip = linear */
  30717. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30718. /** mag = nearest and min = linear and mip = none */
  30719. static readonly TEXTURE_NEAREST_LINEAR: number;
  30720. /** mag = nearest and min = nearest and mip = none */
  30721. static readonly TEXTURE_NEAREST_NEAREST: number;
  30722. /** mag = linear and min = nearest and mip = nearest */
  30723. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30724. /** mag = linear and min = nearest and mip = linear */
  30725. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30726. /** mag = linear and min = linear and mip = none */
  30727. static readonly TEXTURE_LINEAR_LINEAR: number;
  30728. /** mag = linear and min = nearest and mip = none */
  30729. static readonly TEXTURE_LINEAR_NEAREST: number;
  30730. /** Explicit coordinates mode */
  30731. static readonly TEXTURE_EXPLICIT_MODE: number;
  30732. /** Spherical coordinates mode */
  30733. static readonly TEXTURE_SPHERICAL_MODE: number;
  30734. /** Planar coordinates mode */
  30735. static readonly TEXTURE_PLANAR_MODE: number;
  30736. /** Cubic coordinates mode */
  30737. static readonly TEXTURE_CUBIC_MODE: number;
  30738. /** Projection coordinates mode */
  30739. static readonly TEXTURE_PROJECTION_MODE: number;
  30740. /** Skybox coordinates mode */
  30741. static readonly TEXTURE_SKYBOX_MODE: number;
  30742. /** Inverse Cubic coordinates mode */
  30743. static readonly TEXTURE_INVCUBIC_MODE: number;
  30744. /** Equirectangular coordinates mode */
  30745. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30746. /** Equirectangular Fixed coordinates mode */
  30747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30748. /** Equirectangular Fixed Mirrored coordinates mode */
  30749. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30750. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30751. static readonly SCALEMODE_FLOOR: number;
  30752. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30753. static readonly SCALEMODE_NEAREST: number;
  30754. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30755. static readonly SCALEMODE_CEILING: number;
  30756. /**
  30757. * Returns the current npm package of the sdk
  30758. */
  30759. static readonly NpmPackage: string;
  30760. /**
  30761. * Returns the current version of the framework
  30762. */
  30763. static readonly Version: string;
  30764. /**
  30765. * Returns a string describing the current engine
  30766. */
  30767. readonly description: string;
  30768. /**
  30769. * Gets or sets the epsilon value used by collision engine
  30770. */
  30771. static CollisionsEpsilon: number;
  30772. /**
  30773. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30774. */
  30775. static ShadersRepository: string;
  30776. /**
  30777. * Method called to create the default loading screen.
  30778. * This can be overriden in your own app.
  30779. * @param canvas The rendering canvas element
  30780. * @returns The loading screen
  30781. */
  30782. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30783. /**
  30784. * Method called to create the default rescale post process on each engine.
  30785. */
  30786. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30787. /** @hidden */
  30788. _shaderProcessor: IShaderProcessor;
  30789. /**
  30790. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30791. */
  30792. forcePOTTextures: boolean;
  30793. /**
  30794. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30795. */
  30796. isFullscreen: boolean;
  30797. /**
  30798. * Gets a boolean indicating if the pointer is currently locked
  30799. */
  30800. isPointerLock: boolean;
  30801. /**
  30802. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30803. */
  30804. cullBackFaces: boolean;
  30805. /**
  30806. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30807. */
  30808. renderEvenInBackground: boolean;
  30809. /**
  30810. * Gets or sets a boolean indicating that cache can be kept between frames
  30811. */
  30812. preventCacheWipeBetweenFrames: boolean;
  30813. /**
  30814. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30815. **/
  30816. enableOfflineSupport: boolean;
  30817. /**
  30818. * 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)
  30819. **/
  30820. disableManifestCheck: boolean;
  30821. /**
  30822. * Gets the list of created scenes
  30823. */
  30824. scenes: Scene[];
  30825. /**
  30826. * Event raised when a new scene is created
  30827. */
  30828. onNewSceneAddedObservable: Observable<Scene>;
  30829. /**
  30830. * Gets the list of created postprocesses
  30831. */
  30832. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30833. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30834. validateShaderPrograms: boolean;
  30835. /**
  30836. * Observable event triggered each time the rendering canvas is resized
  30837. */
  30838. onResizeObservable: Observable<Engine>;
  30839. /**
  30840. * Observable event triggered each time the canvas loses focus
  30841. */
  30842. onCanvasBlurObservable: Observable<Engine>;
  30843. /**
  30844. * Observable event triggered each time the canvas gains focus
  30845. */
  30846. onCanvasFocusObservable: Observable<Engine>;
  30847. /**
  30848. * Observable event triggered each time the canvas receives pointerout event
  30849. */
  30850. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30851. /**
  30852. * Observable event triggered before each texture is initialized
  30853. */
  30854. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30855. /**
  30856. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30857. */
  30858. disableUniformBuffers: boolean;
  30859. /** @hidden */
  30860. _uniformBuffers: UniformBuffer[];
  30861. /**
  30862. * Gets a boolean indicating that the engine supports uniform buffers
  30863. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30864. */
  30865. readonly supportsUniformBuffers: boolean;
  30866. /**
  30867. * Observable raised when the engine begins a new frame
  30868. */
  30869. onBeginFrameObservable: Observable<Engine>;
  30870. /**
  30871. * If set, will be used to request the next animation frame for the render loop
  30872. */
  30873. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30874. /**
  30875. * Observable raised when the engine ends the current frame
  30876. */
  30877. onEndFrameObservable: Observable<Engine>;
  30878. /**
  30879. * Observable raised when the engine is about to compile a shader
  30880. */
  30881. onBeforeShaderCompilationObservable: Observable<Engine>;
  30882. /**
  30883. * Observable raised when the engine has jsut compiled a shader
  30884. */
  30885. onAfterShaderCompilationObservable: Observable<Engine>;
  30886. /** @hidden */
  30887. _gl: WebGLRenderingContext;
  30888. private _renderingCanvas;
  30889. private _windowIsBackground;
  30890. private _webGLVersion;
  30891. protected _highPrecisionShadersAllowed: boolean;
  30892. /** @hidden */
  30893. readonly _shouldUseHighPrecisionShader: boolean;
  30894. /**
  30895. * Gets a boolean indicating that only power of 2 textures are supported
  30896. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30897. */
  30898. readonly needPOTTextures: boolean;
  30899. /** @hidden */
  30900. _badOS: boolean;
  30901. /** @hidden */
  30902. _badDesktopOS: boolean;
  30903. /**
  30904. * Gets the audio engine
  30905. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30906. * @ignorenaming
  30907. */
  30908. static audioEngine: IAudioEngine;
  30909. /**
  30910. * Default AudioEngine factory responsible of creating the Audio Engine.
  30911. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30912. */
  30913. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30914. /**
  30915. * Default offline support factory responsible of creating a tool used to store data locally.
  30916. * By default, this will create a Database object if the workload has been embedded.
  30917. */
  30918. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30919. private _onFocus;
  30920. private _onBlur;
  30921. private _onCanvasPointerOut;
  30922. private _onCanvasBlur;
  30923. private _onCanvasFocus;
  30924. private _onFullscreenChange;
  30925. private _onPointerLockChange;
  30926. private _hardwareScalingLevel;
  30927. /** @hidden */
  30928. _caps: EngineCapabilities;
  30929. private _pointerLockRequested;
  30930. private _isStencilEnable;
  30931. private _colorWrite;
  30932. private _loadingScreen;
  30933. /** @hidden */
  30934. _drawCalls: PerfCounter;
  30935. private _glVersion;
  30936. private _glRenderer;
  30937. private _glVendor;
  30938. private _videoTextureSupported;
  30939. private _renderingQueueLaunched;
  30940. private _activeRenderLoops;
  30941. private _deterministicLockstep;
  30942. private _lockstepMaxSteps;
  30943. /**
  30944. * Observable signaled when a context lost event is raised
  30945. */
  30946. onContextLostObservable: Observable<Engine>;
  30947. /**
  30948. * Observable signaled when a context restored event is raised
  30949. */
  30950. onContextRestoredObservable: Observable<Engine>;
  30951. private _onContextLost;
  30952. private _onContextRestored;
  30953. private _contextWasLost;
  30954. /** @hidden */
  30955. _doNotHandleContextLost: boolean;
  30956. /**
  30957. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30958. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30959. */
  30960. doNotHandleContextLost: boolean;
  30961. private _performanceMonitor;
  30962. private _fps;
  30963. private _deltaTime;
  30964. /**
  30965. * Turn this value on if you want to pause FPS computation when in background
  30966. */
  30967. disablePerformanceMonitorInBackground: boolean;
  30968. /**
  30969. * Gets the performance monitor attached to this engine
  30970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30971. */
  30972. readonly performanceMonitor: PerformanceMonitor;
  30973. /**
  30974. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30975. */
  30976. disableVertexArrayObjects: boolean;
  30977. /** @hidden */
  30978. protected _depthCullingState: _DepthCullingState;
  30979. /** @hidden */
  30980. protected _stencilState: _StencilState;
  30981. /** @hidden */
  30982. protected _alphaState: _AlphaState;
  30983. /** @hidden */
  30984. protected _alphaMode: number;
  30985. /** @hidden */
  30986. _internalTexturesCache: InternalTexture[];
  30987. /** @hidden */
  30988. protected _activeChannel: number;
  30989. private _currentTextureChannel;
  30990. /** @hidden */
  30991. protected _boundTexturesCache: {
  30992. [key: string]: Nullable<InternalTexture>;
  30993. };
  30994. /** @hidden */
  30995. protected _currentEffect: Nullable<Effect>;
  30996. /** @hidden */
  30997. protected _currentProgram: Nullable<WebGLProgram>;
  30998. private _compiledEffects;
  30999. private _vertexAttribArraysEnabled;
  31000. /** @hidden */
  31001. protected _cachedViewport: Nullable<IViewportLike>;
  31002. private _cachedVertexArrayObject;
  31003. /** @hidden */
  31004. protected _cachedVertexBuffers: any;
  31005. /** @hidden */
  31006. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31007. /** @hidden */
  31008. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31009. /** @hidden */
  31010. _currentRenderTarget: Nullable<InternalTexture>;
  31011. private _uintIndicesCurrentlySet;
  31012. private _currentBoundBuffer;
  31013. /** @hidden */
  31014. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31015. private _currentBufferPointers;
  31016. private _currentInstanceLocations;
  31017. private _currentInstanceBuffers;
  31018. private _textureUnits;
  31019. /** @hidden */
  31020. _workingCanvas: Nullable<HTMLCanvasElement>;
  31021. /** @hidden */
  31022. _workingContext: Nullable<CanvasRenderingContext2D>;
  31023. private _rescalePostProcess;
  31024. private _dummyFramebuffer;
  31025. private _externalData;
  31026. /** @hidden */
  31027. _bindedRenderFunction: any;
  31028. private _vaoRecordInProgress;
  31029. private _mustWipeVertexAttributes;
  31030. private _emptyTexture;
  31031. private _emptyCubeTexture;
  31032. private _emptyTexture3D;
  31033. /** @hidden */
  31034. _frameHandler: number;
  31035. private _nextFreeTextureSlots;
  31036. private _maxSimultaneousTextures;
  31037. private _activeRequests;
  31038. private _texturesSupported;
  31039. /** @hidden */
  31040. _textureFormatInUse: Nullable<string>;
  31041. /**
  31042. * Gets the list of texture formats supported
  31043. */
  31044. readonly texturesSupported: Array<string>;
  31045. /**
  31046. * Gets the list of texture formats in use
  31047. */
  31048. readonly textureFormatInUse: Nullable<string>;
  31049. /**
  31050. * Gets the current viewport
  31051. */
  31052. readonly currentViewport: Nullable<IViewportLike>;
  31053. /**
  31054. * Gets the default empty texture
  31055. */
  31056. readonly emptyTexture: InternalTexture;
  31057. /**
  31058. * Gets the default empty 3D texture
  31059. */
  31060. readonly emptyTexture3D: InternalTexture;
  31061. /**
  31062. * Gets the default empty cube texture
  31063. */
  31064. readonly emptyCubeTexture: InternalTexture;
  31065. /**
  31066. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31067. */
  31068. readonly premultipliedAlpha: boolean;
  31069. /**
  31070. * Creates a new engine
  31071. * @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
  31072. * @param antialias defines enable antialiasing (default: false)
  31073. * @param options defines further options to be sent to the getContext() function
  31074. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31075. */
  31076. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31077. /**
  31078. * Initializes a webVR display and starts listening to display change events
  31079. * The onVRDisplayChangedObservable will be notified upon these changes
  31080. * @returns The onVRDisplayChangedObservable
  31081. */
  31082. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31083. /** @hidden */
  31084. _prepareVRComponent(): void;
  31085. /** @hidden */
  31086. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31087. /** @hidden */
  31088. _submitVRFrame(): void;
  31089. /**
  31090. * Call this function to leave webVR mode
  31091. * Will do nothing if webVR is not supported or if there is no webVR device
  31092. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31093. */
  31094. disableVR(): void;
  31095. /**
  31096. * Gets a boolean indicating that the system is in VR mode and is presenting
  31097. * @returns true if VR mode is engaged
  31098. */
  31099. isVRPresenting(): boolean;
  31100. /** @hidden */
  31101. _requestVRFrame(): void;
  31102. private _disableTouchAction;
  31103. private _rebuildInternalTextures;
  31104. private _rebuildEffects;
  31105. /**
  31106. * Gets a boolean indicating if all created effects are ready
  31107. * @returns true if all effects are ready
  31108. */
  31109. areAllEffectsReady(): boolean;
  31110. private _rebuildBuffers;
  31111. private _initGLContext;
  31112. /**
  31113. * Gets version of the current webGL context
  31114. */
  31115. readonly webGLVersion: number;
  31116. /**
  31117. * Gets a string idenfifying the name of the class
  31118. * @returns "Engine" string
  31119. */
  31120. getClassName(): string;
  31121. /**
  31122. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31123. */
  31124. readonly isStencilEnable: boolean;
  31125. /** @hidden */
  31126. _prepareWorkingCanvas(): void;
  31127. /**
  31128. * Reset the texture cache to empty state
  31129. */
  31130. resetTextureCache(): void;
  31131. /**
  31132. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31134. * @returns true if engine is in deterministic lock step mode
  31135. */
  31136. isDeterministicLockStep(): boolean;
  31137. /**
  31138. * Gets the max steps when engine is running in deterministic lock step
  31139. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31140. * @returns the max steps
  31141. */
  31142. getLockstepMaxSteps(): number;
  31143. /**
  31144. * Gets an object containing information about the current webGL context
  31145. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31146. */
  31147. getGlInfo(): {
  31148. vendor: string;
  31149. renderer: string;
  31150. version: string;
  31151. };
  31152. /**
  31153. * Gets current aspect ratio
  31154. * @param viewportOwner defines the camera to use to get the aspect ratio
  31155. * @param useScreen defines if screen size must be used (or the current render target if any)
  31156. * @returns a number defining the aspect ratio
  31157. */
  31158. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31159. /**
  31160. * Gets current screen aspect ratio
  31161. * @returns a number defining the aspect ratio
  31162. */
  31163. getScreenAspectRatio(): number;
  31164. /**
  31165. * Gets the current render width
  31166. * @param useScreen defines if screen size must be used (or the current render target if any)
  31167. * @returns a number defining the current render width
  31168. */
  31169. getRenderWidth(useScreen?: boolean): number;
  31170. /**
  31171. * Gets the current render height
  31172. * @param useScreen defines if screen size must be used (or the current render target if any)
  31173. * @returns a number defining the current render height
  31174. */
  31175. getRenderHeight(useScreen?: boolean): number;
  31176. /**
  31177. * Gets the HTML canvas attached with the current webGL context
  31178. * @returns a HTML canvas
  31179. */
  31180. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31181. /**
  31182. * Gets the client rect of the HTML canvas attached with the current webGL context
  31183. * @returns a client rectanglee
  31184. */
  31185. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31186. /**
  31187. * Defines the hardware scaling level.
  31188. * By default the hardware scaling level is computed from the window device ratio.
  31189. * 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.
  31190. * @param level defines the level to use
  31191. */
  31192. setHardwareScalingLevel(level: number): void;
  31193. /**
  31194. * Gets the current hardware scaling level.
  31195. * By default the hardware scaling level is computed from the window device ratio.
  31196. * 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.
  31197. * @returns a number indicating the current hardware scaling level
  31198. */
  31199. getHardwareScalingLevel(): number;
  31200. /**
  31201. * Gets the list of loaded textures
  31202. * @returns an array containing all loaded textures
  31203. */
  31204. getLoadedTexturesCache(): InternalTexture[];
  31205. /**
  31206. * Gets the object containing all engine capabilities
  31207. * @returns the EngineCapabilities object
  31208. */
  31209. getCaps(): EngineCapabilities;
  31210. /**
  31211. * Gets the current depth function
  31212. * @returns a number defining the depth function
  31213. */
  31214. getDepthFunction(): Nullable<number>;
  31215. /**
  31216. * Sets the current depth function
  31217. * @param depthFunc defines the function to use
  31218. */
  31219. setDepthFunction(depthFunc: number): void;
  31220. /**
  31221. * Sets the current depth function to GREATER
  31222. */
  31223. setDepthFunctionToGreater(): void;
  31224. /**
  31225. * Sets the current depth function to GEQUAL
  31226. */
  31227. setDepthFunctionToGreaterOrEqual(): void;
  31228. /**
  31229. * Sets the current depth function to LESS
  31230. */
  31231. setDepthFunctionToLess(): void;
  31232. private _cachedStencilBuffer;
  31233. private _cachedStencilFunction;
  31234. private _cachedStencilMask;
  31235. private _cachedStencilOperationPass;
  31236. private _cachedStencilOperationFail;
  31237. private _cachedStencilOperationDepthFail;
  31238. private _cachedStencilReference;
  31239. /**
  31240. * Caches the the state of the stencil buffer
  31241. */
  31242. cacheStencilState(): void;
  31243. /**
  31244. * Restores the state of the stencil buffer
  31245. */
  31246. restoreStencilState(): void;
  31247. /**
  31248. * Sets the current depth function to LEQUAL
  31249. */
  31250. setDepthFunctionToLessOrEqual(): void;
  31251. /**
  31252. * Gets a boolean indicating if stencil buffer is enabled
  31253. * @returns the current stencil buffer state
  31254. */
  31255. getStencilBuffer(): boolean;
  31256. /**
  31257. * Enable or disable the stencil buffer
  31258. * @param enable defines if the stencil buffer must be enabled or disabled
  31259. */
  31260. setStencilBuffer(enable: boolean): void;
  31261. /**
  31262. * Gets the current stencil mask
  31263. * @returns a number defining the new stencil mask to use
  31264. */
  31265. getStencilMask(): number;
  31266. /**
  31267. * Sets the current stencil mask
  31268. * @param mask defines the new stencil mask to use
  31269. */
  31270. setStencilMask(mask: number): void;
  31271. /**
  31272. * Gets the current stencil function
  31273. * @returns a number defining the stencil function to use
  31274. */
  31275. getStencilFunction(): number;
  31276. /**
  31277. * Gets the current stencil reference value
  31278. * @returns a number defining the stencil reference value to use
  31279. */
  31280. getStencilFunctionReference(): number;
  31281. /**
  31282. * Gets the current stencil mask
  31283. * @returns a number defining the stencil mask to use
  31284. */
  31285. getStencilFunctionMask(): number;
  31286. /**
  31287. * Sets the current stencil function
  31288. * @param stencilFunc defines the new stencil function to use
  31289. */
  31290. setStencilFunction(stencilFunc: number): void;
  31291. /**
  31292. * Sets the current stencil reference
  31293. * @param reference defines the new stencil reference to use
  31294. */
  31295. setStencilFunctionReference(reference: number): void;
  31296. /**
  31297. * Sets the current stencil mask
  31298. * @param mask defines the new stencil mask to use
  31299. */
  31300. setStencilFunctionMask(mask: number): void;
  31301. /**
  31302. * Gets the current stencil operation when stencil fails
  31303. * @returns a number defining stencil operation to use when stencil fails
  31304. */
  31305. getStencilOperationFail(): number;
  31306. /**
  31307. * Gets the current stencil operation when depth fails
  31308. * @returns a number defining stencil operation to use when depth fails
  31309. */
  31310. getStencilOperationDepthFail(): number;
  31311. /**
  31312. * Gets the current stencil operation when stencil passes
  31313. * @returns a number defining stencil operation to use when stencil passes
  31314. */
  31315. getStencilOperationPass(): number;
  31316. /**
  31317. * Sets the stencil operation to use when stencil fails
  31318. * @param operation defines the stencil operation to use when stencil fails
  31319. */
  31320. setStencilOperationFail(operation: number): void;
  31321. /**
  31322. * Sets the stencil operation to use when depth fails
  31323. * @param operation defines the stencil operation to use when depth fails
  31324. */
  31325. setStencilOperationDepthFail(operation: number): void;
  31326. /**
  31327. * Sets the stencil operation to use when stencil passes
  31328. * @param operation defines the stencil operation to use when stencil passes
  31329. */
  31330. setStencilOperationPass(operation: number): void;
  31331. /**
  31332. * Sets a boolean indicating if the dithering state is enabled or disabled
  31333. * @param value defines the dithering state
  31334. */
  31335. setDitheringState(value: boolean): void;
  31336. /**
  31337. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31338. * @param value defines the rasterizer state
  31339. */
  31340. setRasterizerState(value: boolean): void;
  31341. /**
  31342. * stop executing a render loop function and remove it from the execution array
  31343. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31344. */
  31345. stopRenderLoop(renderFunction?: () => void): void;
  31346. /** @hidden */
  31347. _renderLoop(): void;
  31348. /**
  31349. * Register and execute a render loop. The engine can have more than one render function
  31350. * @param renderFunction defines the function to continuously execute
  31351. */
  31352. runRenderLoop(renderFunction: () => void): void;
  31353. /**
  31354. * Toggle full screen mode
  31355. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31356. */
  31357. switchFullscreen(requestPointerLock: boolean): void;
  31358. /**
  31359. * Enters full screen mode
  31360. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31361. */
  31362. enterFullscreen(requestPointerLock: boolean): void;
  31363. /**
  31364. * Exits full screen mode
  31365. */
  31366. exitFullscreen(): void;
  31367. /**
  31368. * Enters Pointerlock mode
  31369. */
  31370. enterPointerlock(): void;
  31371. /**
  31372. * Exits Pointerlock mode
  31373. */
  31374. exitPointerlock(): void;
  31375. /**
  31376. * Clear the current render buffer or the current render target (if any is set up)
  31377. * @param color defines the color to use
  31378. * @param backBuffer defines if the back buffer must be cleared
  31379. * @param depth defines if the depth buffer must be cleared
  31380. * @param stencil defines if the stencil buffer must be cleared
  31381. */
  31382. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31383. /**
  31384. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31385. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31386. * @param y defines the y-coordinate of the corner of the clear rectangle
  31387. * @param width defines the width of the clear rectangle
  31388. * @param height defines the height of the clear rectangle
  31389. * @param clearColor defines the clear color
  31390. */
  31391. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31392. /**
  31393. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31394. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31395. * @param y defines the y-coordinate of the corner of the clear rectangle
  31396. * @param width defines the width of the clear rectangle
  31397. * @param height defines the height of the clear rectangle
  31398. */
  31399. enableScissor(x: number, y: number, width: number, height: number): void;
  31400. /**
  31401. * Disable previously set scissor test rectangle
  31402. */
  31403. disableScissor(): void;
  31404. private _viewportCached;
  31405. /** @hidden */
  31406. _viewport(x: number, y: number, width: number, height: number): void;
  31407. /**
  31408. * Set the WebGL's viewport
  31409. * @param viewport defines the viewport element to be used
  31410. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31411. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31412. */
  31413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31414. /**
  31415. * Directly set the WebGL Viewport
  31416. * @param x defines the x coordinate of the viewport (in screen space)
  31417. * @param y defines the y coordinate of the viewport (in screen space)
  31418. * @param width defines the width of the viewport (in screen space)
  31419. * @param height defines the height of the viewport (in screen space)
  31420. * @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
  31421. */
  31422. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31423. /**
  31424. * Begin a new frame
  31425. */
  31426. beginFrame(): void;
  31427. /**
  31428. * Enf the current frame
  31429. */
  31430. endFrame(): void;
  31431. /**
  31432. * Resize the view according to the canvas' size
  31433. */
  31434. resize(): void;
  31435. /**
  31436. * Force a specific size of the canvas
  31437. * @param width defines the new canvas' width
  31438. * @param height defines the new canvas' height
  31439. */
  31440. setSize(width: number, height: number): void;
  31441. /**
  31442. * Binds the frame buffer to the specified texture.
  31443. * @param texture The texture to render to or null for the default canvas
  31444. * @param faceIndex The face of the texture to render to in case of cube texture
  31445. * @param requiredWidth The width of the target to render to
  31446. * @param requiredHeight The height of the target to render to
  31447. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31448. * @param depthStencilTexture The depth stencil texture to use to render
  31449. * @param lodLevel defines le lod level to bind to the frame buffer
  31450. */
  31451. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31452. /** @hidden */
  31453. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31454. /**
  31455. * Unbind the current render target texture from the webGL context
  31456. * @param texture defines the render target texture to unbind
  31457. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31458. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31459. */
  31460. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31461. /**
  31462. * Force the mipmap generation for the given render target texture
  31463. * @param texture defines the render target texture to use
  31464. */
  31465. generateMipMapsForCubemap(texture: InternalTexture): void;
  31466. /**
  31467. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31468. */
  31469. flushFramebuffer(): void;
  31470. /**
  31471. * Unbind the current render target and bind the default framebuffer
  31472. */
  31473. restoreDefaultFramebuffer(): void;
  31474. /**
  31475. * Create an uniform buffer
  31476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31477. * @param elements defines the content of the uniform buffer
  31478. * @returns the webGL uniform buffer
  31479. */
  31480. createUniformBuffer(elements: FloatArray): DataBuffer;
  31481. /**
  31482. * Create a dynamic uniform buffer
  31483. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31484. * @param elements defines the content of the uniform buffer
  31485. * @returns the webGL uniform buffer
  31486. */
  31487. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31488. /**
  31489. * Update an existing uniform buffer
  31490. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31491. * @param uniformBuffer defines the target uniform buffer
  31492. * @param elements defines the content to update
  31493. * @param offset defines the offset in the uniform buffer where update should start
  31494. * @param count defines the size of the data to update
  31495. */
  31496. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31497. private _resetVertexBufferBinding;
  31498. /**
  31499. * Creates a vertex buffer
  31500. * @param data the data for the vertex buffer
  31501. * @returns the new WebGL static buffer
  31502. */
  31503. createVertexBuffer(data: DataArray): DataBuffer;
  31504. /**
  31505. * Creates a dynamic vertex buffer
  31506. * @param data the data for the dynamic vertex buffer
  31507. * @returns the new WebGL dynamic buffer
  31508. */
  31509. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31510. /**
  31511. * Update a dynamic index buffer
  31512. * @param indexBuffer defines the target index buffer
  31513. * @param indices defines the data to update
  31514. * @param offset defines the offset in the target index buffer where update should start
  31515. */
  31516. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31517. /**
  31518. * Updates a dynamic vertex buffer.
  31519. * @param vertexBuffer the vertex buffer to update
  31520. * @param data the data used to update the vertex buffer
  31521. * @param byteOffset the byte offset of the data
  31522. * @param byteLength the byte length of the data
  31523. */
  31524. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31525. private _resetIndexBufferBinding;
  31526. /**
  31527. * Creates a new index buffer
  31528. * @param indices defines the content of the index buffer
  31529. * @param updatable defines if the index buffer must be updatable
  31530. * @returns a new webGL buffer
  31531. */
  31532. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31533. /**
  31534. * Bind a webGL buffer to the webGL context
  31535. * @param buffer defines the buffer to bind
  31536. */
  31537. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31538. /**
  31539. * Bind an uniform buffer to the current webGL context
  31540. * @param buffer defines the buffer to bind
  31541. */
  31542. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31543. /**
  31544. * Bind a buffer to the current webGL context at a given location
  31545. * @param buffer defines the buffer to bind
  31546. * @param location defines the index where to bind the buffer
  31547. */
  31548. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31549. /**
  31550. * Bind a specific block at a given index in a specific shader program
  31551. * @param pipelineContext defines the pipeline context to use
  31552. * @param blockName defines the block name
  31553. * @param index defines the index where to bind the block
  31554. */
  31555. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31556. private bindIndexBuffer;
  31557. private bindBuffer;
  31558. /**
  31559. * update the bound buffer with the given data
  31560. * @param data defines the data to update
  31561. */
  31562. updateArrayBuffer(data: Float32Array): void;
  31563. private _vertexAttribPointer;
  31564. private _bindIndexBufferWithCache;
  31565. private _bindVertexBuffersAttributes;
  31566. /**
  31567. * Records a vertex array object
  31568. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31569. * @param vertexBuffers defines the list of vertex buffers to store
  31570. * @param indexBuffer defines the index buffer to store
  31571. * @param effect defines the effect to store
  31572. * @returns the new vertex array object
  31573. */
  31574. recordVertexArrayObject(vertexBuffers: {
  31575. [key: string]: VertexBuffer;
  31576. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31577. /**
  31578. * Bind a specific vertex array object
  31579. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31580. * @param vertexArrayObject defines the vertex array object to bind
  31581. * @param indexBuffer defines the index buffer to bind
  31582. */
  31583. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31584. /**
  31585. * Bind webGl buffers directly to the webGL context
  31586. * @param vertexBuffer defines the vertex buffer to bind
  31587. * @param indexBuffer defines the index buffer to bind
  31588. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31589. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31590. * @param effect defines the effect associated with the vertex buffer
  31591. */
  31592. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31593. private _unbindVertexArrayObject;
  31594. /**
  31595. * Bind a list of vertex buffers to the webGL context
  31596. * @param vertexBuffers defines the list of vertex buffers to bind
  31597. * @param indexBuffer defines the index buffer to bind
  31598. * @param effect defines the effect associated with the vertex buffers
  31599. */
  31600. bindBuffers(vertexBuffers: {
  31601. [key: string]: Nullable<VertexBuffer>;
  31602. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31603. /**
  31604. * Unbind all instance attributes
  31605. */
  31606. unbindInstanceAttributes(): void;
  31607. /**
  31608. * Release and free the memory of a vertex array object
  31609. * @param vao defines the vertex array object to delete
  31610. */
  31611. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31612. /** @hidden */
  31613. _releaseBuffer(buffer: DataBuffer): boolean;
  31614. /**
  31615. * Creates a webGL buffer to use with instanciation
  31616. * @param capacity defines the size of the buffer
  31617. * @returns the webGL buffer
  31618. */
  31619. createInstancesBuffer(capacity: number): DataBuffer;
  31620. /**
  31621. * Delete a webGL buffer used with instanciation
  31622. * @param buffer defines the webGL buffer to delete
  31623. */
  31624. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31625. /**
  31626. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31627. * @param instancesBuffer defines the webGL buffer to update and bind
  31628. * @param data defines the data to store in the buffer
  31629. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31630. */
  31631. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31632. /**
  31633. * Apply all cached states (depth, culling, stencil and alpha)
  31634. */
  31635. applyStates(): void;
  31636. /**
  31637. * Send a draw order
  31638. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31639. * @param indexStart defines the starting index
  31640. * @param indexCount defines the number of index to draw
  31641. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31642. */
  31643. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31644. /**
  31645. * Draw a list of points
  31646. * @param verticesStart defines the index of first vertex to draw
  31647. * @param verticesCount defines the count of vertices to draw
  31648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31649. */
  31650. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31651. /**
  31652. * Draw a list of unindexed primitives
  31653. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31654. * @param verticesStart defines the index of first vertex to draw
  31655. * @param verticesCount defines the count of vertices to draw
  31656. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31657. */
  31658. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31659. /**
  31660. * Draw a list of indexed primitives
  31661. * @param fillMode defines the primitive to use
  31662. * @param indexStart defines the starting index
  31663. * @param indexCount defines the number of index to draw
  31664. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31665. */
  31666. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31667. /**
  31668. * Draw a list of unindexed primitives
  31669. * @param fillMode defines the primitive to use
  31670. * @param verticesStart defines the index of first vertex to draw
  31671. * @param verticesCount defines the count of vertices to draw
  31672. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31673. */
  31674. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31675. private _drawMode;
  31676. /** @hidden */
  31677. _releaseEffect(effect: Effect): void;
  31678. /** @hidden */
  31679. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31680. /**
  31681. * Create a new effect (used to store vertex/fragment shaders)
  31682. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31683. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31684. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31685. * @param samplers defines an array of string used to represent textures
  31686. * @param defines defines the string containing the defines to use to compile the shaders
  31687. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31688. * @param onCompiled defines a function to call when the effect creation is successful
  31689. * @param onError defines a function to call when the effect creation has failed
  31690. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31691. * @returns the new Effect
  31692. */
  31693. 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;
  31694. private _compileShader;
  31695. private _compileRawShader;
  31696. /**
  31697. * Directly creates a webGL program
  31698. * @param pipelineContext defines the pipeline context to attach to
  31699. * @param vertexCode defines the vertex shader code to use
  31700. * @param fragmentCode defines the fragment shader code to use
  31701. * @param context defines the webGL context to use (if not set, the current one will be used)
  31702. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31703. * @returns the new webGL program
  31704. */
  31705. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31706. /**
  31707. * Creates a webGL program
  31708. * @param pipelineContext defines the pipeline context to attach to
  31709. * @param vertexCode defines the vertex shader code to use
  31710. * @param fragmentCode defines the fragment shader code to use
  31711. * @param defines defines the string containing the defines to use to compile the shaders
  31712. * @param context defines the webGL context to use (if not set, the current one will be used)
  31713. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31714. * @returns the new webGL program
  31715. */
  31716. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31717. /**
  31718. * Creates a new pipeline context
  31719. * @returns the new pipeline
  31720. */
  31721. createPipelineContext(): WebGLPipelineContext;
  31722. private _createShaderProgram;
  31723. private _finalizePipelineContext;
  31724. /** @hidden */
  31725. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31726. /** @hidden */
  31727. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31728. /** @hidden */
  31729. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31730. /**
  31731. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31732. * @param pipelineContext defines the pipeline context to use
  31733. * @param uniformsNames defines the list of uniform names
  31734. * @returns an array of webGL uniform locations
  31735. */
  31736. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31737. /**
  31738. * Gets the lsit of active attributes for a given webGL program
  31739. * @param pipelineContext defines the pipeline context to use
  31740. * @param attributesNames defines the list of attribute names to get
  31741. * @returns an array of indices indicating the offset of each attribute
  31742. */
  31743. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31744. /**
  31745. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31746. * @param effect defines the effect to activate
  31747. */
  31748. enableEffect(effect: Nullable<Effect>): void;
  31749. /**
  31750. * Set the value of an uniform to an array of int32
  31751. * @param uniform defines the webGL uniform location where to store the value
  31752. * @param array defines the array of int32 to store
  31753. */
  31754. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31755. /**
  31756. * Set the value of an uniform to an array of int32 (stored as vec2)
  31757. * @param uniform defines the webGL uniform location where to store the value
  31758. * @param array defines the array of int32 to store
  31759. */
  31760. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31761. /**
  31762. * Set the value of an uniform to an array of int32 (stored as vec3)
  31763. * @param uniform defines the webGL uniform location where to store the value
  31764. * @param array defines the array of int32 to store
  31765. */
  31766. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31767. /**
  31768. * Set the value of an uniform to an array of int32 (stored as vec4)
  31769. * @param uniform defines the webGL uniform location where to store the value
  31770. * @param array defines the array of int32 to store
  31771. */
  31772. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31773. /**
  31774. * Set the value of an uniform to an array of float32
  31775. * @param uniform defines the webGL uniform location where to store the value
  31776. * @param array defines the array of float32 to store
  31777. */
  31778. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31779. /**
  31780. * Set the value of an uniform to an array of float32 (stored as vec2)
  31781. * @param uniform defines the webGL uniform location where to store the value
  31782. * @param array defines the array of float32 to store
  31783. */
  31784. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31785. /**
  31786. * Set the value of an uniform to an array of float32 (stored as vec3)
  31787. * @param uniform defines the webGL uniform location where to store the value
  31788. * @param array defines the array of float32 to store
  31789. */
  31790. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31791. /**
  31792. * Set the value of an uniform to an array of float32 (stored as vec4)
  31793. * @param uniform defines the webGL uniform location where to store the value
  31794. * @param array defines the array of float32 to store
  31795. */
  31796. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31797. /**
  31798. * Set the value of an uniform to an array of number
  31799. * @param uniform defines the webGL uniform location where to store the value
  31800. * @param array defines the array of number to store
  31801. */
  31802. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31803. /**
  31804. * Set the value of an uniform to an array of number (stored as vec2)
  31805. * @param uniform defines the webGL uniform location where to store the value
  31806. * @param array defines the array of number to store
  31807. */
  31808. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31809. /**
  31810. * Set the value of an uniform to an array of number (stored as vec3)
  31811. * @param uniform defines the webGL uniform location where to store the value
  31812. * @param array defines the array of number to store
  31813. */
  31814. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31815. /**
  31816. * Set the value of an uniform to an array of number (stored as vec4)
  31817. * @param uniform defines the webGL uniform location where to store the value
  31818. * @param array defines the array of number to store
  31819. */
  31820. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31821. /**
  31822. * Set the value of an uniform to an array of float32 (stored as matrices)
  31823. * @param uniform defines the webGL uniform location where to store the value
  31824. * @param matrices defines the array of float32 to store
  31825. */
  31826. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31827. /**
  31828. * Set the value of an uniform to a matrix (3x3)
  31829. * @param uniform defines the webGL uniform location where to store the value
  31830. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31831. */
  31832. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31833. /**
  31834. * Set the value of an uniform to a matrix (2x2)
  31835. * @param uniform defines the webGL uniform location where to store the value
  31836. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31837. */
  31838. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31839. /**
  31840. * Set the value of an uniform to a number (int)
  31841. * @param uniform defines the webGL uniform location where to store the value
  31842. * @param value defines the int number to store
  31843. */
  31844. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31845. /**
  31846. * Set the value of an uniform to a number (float)
  31847. * @param uniform defines the webGL uniform location where to store the value
  31848. * @param value defines the float number to store
  31849. */
  31850. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31851. /**
  31852. * Set the value of an uniform to a vec2
  31853. * @param uniform defines the webGL uniform location where to store the value
  31854. * @param x defines the 1st component of the value
  31855. * @param y defines the 2nd component of the value
  31856. */
  31857. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31858. /**
  31859. * Set the value of an uniform to a vec3
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param x defines the 1st component of the value
  31862. * @param y defines the 2nd component of the value
  31863. * @param z defines the 3rd component of the value
  31864. */
  31865. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31866. /**
  31867. * Set the value of an uniform to a boolean
  31868. * @param uniform defines the webGL uniform location where to store the value
  31869. * @param bool defines the boolean to store
  31870. */
  31871. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31872. /**
  31873. * Set the value of an uniform to a vec4
  31874. * @param uniform defines the webGL uniform location where to store the value
  31875. * @param x defines the 1st component of the value
  31876. * @param y defines the 2nd component of the value
  31877. * @param z defines the 3rd component of the value
  31878. * @param w defines the 4th component of the value
  31879. */
  31880. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31881. /**
  31882. * Sets a Color4 on a uniform variable
  31883. * @param uniform defines the uniform location
  31884. * @param color4 defines the value to be set
  31885. */
  31886. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31887. /**
  31888. * Set various states to the webGL context
  31889. * @param culling defines backface culling state
  31890. * @param zOffset defines the value to apply to zOffset (0 by default)
  31891. * @param force defines if states must be applied even if cache is up to date
  31892. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31893. */
  31894. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31895. /**
  31896. * Set the z offset to apply to current rendering
  31897. * @param value defines the offset to apply
  31898. */
  31899. setZOffset(value: number): void;
  31900. /**
  31901. * Gets the current value of the zOffset
  31902. * @returns the current zOffset state
  31903. */
  31904. getZOffset(): number;
  31905. /**
  31906. * Enable or disable depth buffering
  31907. * @param enable defines the state to set
  31908. */
  31909. setDepthBuffer(enable: boolean): void;
  31910. /**
  31911. * Gets a boolean indicating if depth writing is enabled
  31912. * @returns the current depth writing state
  31913. */
  31914. getDepthWrite(): boolean;
  31915. /**
  31916. * Enable or disable depth writing
  31917. * @param enable defines the state to set
  31918. */
  31919. setDepthWrite(enable: boolean): void;
  31920. /**
  31921. * Enable or disable color writing
  31922. * @param enable defines the state to set
  31923. */
  31924. setColorWrite(enable: boolean): void;
  31925. /**
  31926. * Gets a boolean indicating if color writing is enabled
  31927. * @returns the current color writing state
  31928. */
  31929. getColorWrite(): boolean;
  31930. /**
  31931. * Sets alpha constants used by some alpha blending modes
  31932. * @param r defines the red component
  31933. * @param g defines the green component
  31934. * @param b defines the blue component
  31935. * @param a defines the alpha component
  31936. */
  31937. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31938. /**
  31939. * Sets the current alpha mode
  31940. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31941. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31942. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31943. */
  31944. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31945. /**
  31946. * Gets the current alpha mode
  31947. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31948. * @returns the current alpha mode
  31949. */
  31950. getAlphaMode(): number;
  31951. /**
  31952. * Clears the list of texture accessible through engine.
  31953. * This can help preventing texture load conflict due to name collision.
  31954. */
  31955. clearInternalTexturesCache(): void;
  31956. /**
  31957. * Force the entire cache to be cleared
  31958. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31959. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31960. */
  31961. wipeCaches(bruteForce?: boolean): void;
  31962. /**
  31963. * Set the compressed texture format to use, based on the formats you have, and the formats
  31964. * supported by the hardware / browser.
  31965. *
  31966. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31967. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31968. * to API arguments needed to compressed textures. This puts the burden on the container
  31969. * generator to house the arcane code for determining these for current & future formats.
  31970. *
  31971. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31972. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31973. *
  31974. * Note: The result of this call is not taken into account when a texture is base64.
  31975. *
  31976. * @param formatsAvailable defines the list of those format families you have created
  31977. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31978. *
  31979. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31980. * @returns The extension selected.
  31981. */
  31982. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31983. /** @hidden */
  31984. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31985. min: number;
  31986. mag: number;
  31987. };
  31988. /** @hidden */
  31989. _createTexture(): WebGLTexture;
  31990. /**
  31991. * Usually called from Texture.ts.
  31992. * Passed information to create a WebGLTexture
  31993. * @param urlArg defines a value which contains one of the following:
  31994. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31995. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31996. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31997. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31998. * @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)
  31999. * @param scene needed for loading to the correct scene
  32000. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32001. * @param onLoad optional callback to be called upon successful completion
  32002. * @param onError optional callback to be called upon failure
  32003. * @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
  32004. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32005. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32006. * @param forcedExtension defines the extension to use to pick the right loader
  32007. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32008. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32009. */
  32010. 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;
  32011. /**
  32012. * @hidden
  32013. * Rescales a texture
  32014. * @param source input texutre
  32015. * @param destination destination texture
  32016. * @param scene scene to use to render the resize
  32017. * @param internalFormat format to use when resizing
  32018. * @param onComplete callback to be called when resize has completed
  32019. */
  32020. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32021. private _unpackFlipYCached;
  32022. /**
  32023. * In case you are sharing the context with other applications, it might
  32024. * be interested to not cache the unpack flip y state to ensure a consistent
  32025. * value would be set.
  32026. */
  32027. enableUnpackFlipYCached: boolean;
  32028. /** @hidden */
  32029. _unpackFlipY(value: boolean): void;
  32030. /** @hidden */
  32031. _getUnpackAlignement(): number;
  32032. /**
  32033. * Creates a dynamic texture
  32034. * @param width defines the width of the texture
  32035. * @param height defines the height of the texture
  32036. * @param generateMipMaps defines if the engine should generate the mip levels
  32037. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32038. * @returns the dynamic texture inside an InternalTexture
  32039. */
  32040. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32041. /**
  32042. * Update the sampling mode of a given texture
  32043. * @param samplingMode defines the required sampling mode
  32044. * @param texture defines the texture to update
  32045. */
  32046. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32047. /**
  32048. * Update the content of a dynamic texture
  32049. * @param texture defines the texture to update
  32050. * @param canvas defines the canvas containing the source
  32051. * @param invertY defines if data must be stored with Y axis inverted
  32052. * @param premulAlpha defines if alpha is stored as premultiplied
  32053. * @param format defines the format of the data
  32054. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32055. */
  32056. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32057. /**
  32058. * Update a video texture
  32059. * @param texture defines the texture to update
  32060. * @param video defines the video element to use
  32061. * @param invertY defines if data must be stored with Y axis inverted
  32062. */
  32063. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32064. /**
  32065. * Updates a depth texture Comparison Mode and Function.
  32066. * If the comparison Function is equal to 0, the mode will be set to none.
  32067. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32068. * @param texture The texture to set the comparison function for
  32069. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32070. */
  32071. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32072. /** @hidden */
  32073. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32074. width: number;
  32075. height: number;
  32076. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32077. /**
  32078. * Creates a depth stencil texture.
  32079. * This is only available in WebGL 2 or with the depth texture extension available.
  32080. * @param size The size of face edge in the texture.
  32081. * @param options The options defining the texture.
  32082. * @returns The texture
  32083. */
  32084. createDepthStencilTexture(size: number | {
  32085. width: number;
  32086. height: number;
  32087. }, options: DepthTextureCreationOptions): InternalTexture;
  32088. /**
  32089. * Creates a depth stencil texture.
  32090. * This is only available in WebGL 2 or with the depth texture extension available.
  32091. * @param size The size of face edge in the texture.
  32092. * @param options The options defining the texture.
  32093. * @returns The texture
  32094. */
  32095. private _createDepthStencilTexture;
  32096. /**
  32097. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32098. * @param renderTarget The render target to set the frame buffer for
  32099. */
  32100. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32101. /**
  32102. * Creates a new render target texture
  32103. * @param size defines the size of the texture
  32104. * @param options defines the options used to create the texture
  32105. * @returns a new render target texture stored in an InternalTexture
  32106. */
  32107. createRenderTargetTexture(size: number | {
  32108. width: number;
  32109. height: number;
  32110. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32111. /** @hidden */
  32112. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32113. /**
  32114. * Updates the sample count of a render target texture
  32115. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32116. * @param texture defines the texture to update
  32117. * @param samples defines the sample count to set
  32118. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32119. */
  32120. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32121. /** @hidden */
  32122. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32123. /** @hidden */
  32124. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32125. /** @hidden */
  32126. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32127. /** @hidden */
  32128. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32129. /**
  32130. * @hidden
  32131. */
  32132. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32133. private _prepareWebGLTextureContinuation;
  32134. private _prepareWebGLTexture;
  32135. /** @hidden */
  32136. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32137. /** @hidden */
  32138. _releaseFramebufferObjects(texture: InternalTexture): void;
  32139. /** @hidden */
  32140. _releaseTexture(texture: InternalTexture): void;
  32141. private setProgram;
  32142. private _boundUniforms;
  32143. /**
  32144. * Binds an effect to the webGL context
  32145. * @param effect defines the effect to bind
  32146. */
  32147. bindSamplers(effect: Effect): void;
  32148. private _activateCurrentTexture;
  32149. /** @hidden */
  32150. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32151. /** @hidden */
  32152. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32153. /**
  32154. * Sets a texture to the webGL context from a postprocess
  32155. * @param channel defines the channel to use
  32156. * @param postProcess defines the source postprocess
  32157. */
  32158. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32159. /**
  32160. * Binds the output of the passed in post process to the texture channel specified
  32161. * @param channel The channel the texture should be bound to
  32162. * @param postProcess The post process which's output should be bound
  32163. */
  32164. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32165. /**
  32166. * Unbind all textures from the webGL context
  32167. */
  32168. unbindAllTextures(): void;
  32169. /**
  32170. * Sets a texture to the according uniform.
  32171. * @param channel The texture channel
  32172. * @param uniform The uniform to set
  32173. * @param texture The texture to apply
  32174. */
  32175. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32176. /**
  32177. * Sets a depth stencil texture from a render target to the according uniform.
  32178. * @param channel The texture channel
  32179. * @param uniform The uniform to set
  32180. * @param texture The render target texture containing the depth stencil texture to apply
  32181. */
  32182. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32183. private _bindSamplerUniformToChannel;
  32184. private _getTextureWrapMode;
  32185. private _setTexture;
  32186. /**
  32187. * Sets an array of texture to the webGL context
  32188. * @param channel defines the channel where the texture array must be set
  32189. * @param uniform defines the associated uniform location
  32190. * @param textures defines the array of textures to bind
  32191. */
  32192. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32193. /** @hidden */
  32194. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32195. private _setTextureParameterFloat;
  32196. private _setTextureParameterInteger;
  32197. /**
  32198. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32199. * @param x defines the x coordinate of the rectangle where pixels must be read
  32200. * @param y defines the y coordinate of the rectangle where pixels must be read
  32201. * @param width defines the width of the rectangle where pixels must be read
  32202. * @param height defines the height of the rectangle where pixels must be read
  32203. * @returns a Uint8Array containing RGBA colors
  32204. */
  32205. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32206. /**
  32207. * Add an externaly attached data from its key.
  32208. * This method call will fail and return false, if such key already exists.
  32209. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32210. * @param key the unique key that identifies the data
  32211. * @param data the data object to associate to the key for this Engine instance
  32212. * @return true if no such key were already present and the data was added successfully, false otherwise
  32213. */
  32214. addExternalData<T>(key: string, data: T): boolean;
  32215. /**
  32216. * Get an externaly attached data from its key
  32217. * @param key the unique key that identifies the data
  32218. * @return the associated data, if present (can be null), or undefined if not present
  32219. */
  32220. getExternalData<T>(key: string): T;
  32221. /**
  32222. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32223. * @param key the unique key that identifies the data
  32224. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32225. * @return the associated data, can be null if the factory returned null.
  32226. */
  32227. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32228. /**
  32229. * Remove an externaly attached data from the Engine instance
  32230. * @param key the unique key that identifies the data
  32231. * @return true if the data was successfully removed, false if it doesn't exist
  32232. */
  32233. removeExternalData(key: string): boolean;
  32234. /**
  32235. * Unbind all vertex attributes from the webGL context
  32236. */
  32237. unbindAllAttributes(): void;
  32238. /**
  32239. * 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
  32240. */
  32241. releaseEffects(): void;
  32242. /**
  32243. * Dispose and release all associated resources
  32244. */
  32245. dispose(): void;
  32246. /**
  32247. * Display the loading screen
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. displayLoadingUI(): void;
  32251. /**
  32252. * Hide the loading screen
  32253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32254. */
  32255. hideLoadingUI(): void;
  32256. /**
  32257. * Gets the current loading screen object
  32258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32259. */
  32260. /**
  32261. * Sets the current loading screen object
  32262. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32263. */
  32264. loadingScreen: ILoadingScreen;
  32265. /**
  32266. * Sets the current loading screen text
  32267. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32268. */
  32269. loadingUIText: string;
  32270. /**
  32271. * Sets the current loading screen background color
  32272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32273. */
  32274. loadingUIBackgroundColor: string;
  32275. /**
  32276. * Attach a new callback raised when context lost event is fired
  32277. * @param callback defines the callback to call
  32278. */
  32279. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32280. /**
  32281. * Attach a new callback raised when context restored event is fired
  32282. * @param callback defines the callback to call
  32283. */
  32284. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32285. /**
  32286. * Gets the source code of the vertex shader associated with a specific webGL program
  32287. * @param program defines the program to use
  32288. * @returns a string containing the source code of the vertex shader associated with the program
  32289. */
  32290. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32291. /**
  32292. * Gets the source code of the fragment shader associated with a specific webGL program
  32293. * @param program defines the program to use
  32294. * @returns a string containing the source code of the fragment shader associated with the program
  32295. */
  32296. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32297. /**
  32298. * Get the current error code of the webGL context
  32299. * @returns the error code
  32300. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32301. */
  32302. getError(): number;
  32303. /**
  32304. * Gets the current framerate
  32305. * @returns a number representing the framerate
  32306. */
  32307. getFps(): number;
  32308. /**
  32309. * Gets the time spent between current and previous frame
  32310. * @returns a number representing the delta time in ms
  32311. */
  32312. getDeltaTime(): number;
  32313. private _measureFps;
  32314. /** @hidden */
  32315. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32316. private _canRenderToFloatFramebuffer;
  32317. private _canRenderToHalfFloatFramebuffer;
  32318. private _canRenderToFramebuffer;
  32319. /** @hidden */
  32320. _getWebGLTextureType(type: number): number;
  32321. /** @hidden */
  32322. _getInternalFormat(format: number): number;
  32323. /** @hidden */
  32324. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32325. /** @hidden */
  32326. _getRGBAMultiSampleBufferFormat(type: number): number;
  32327. /** @hidden */
  32328. _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;
  32329. /** @hidden */
  32330. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32331. /**
  32332. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32333. * @returns true if the engine can be created
  32334. * @ignorenaming
  32335. */
  32336. static isSupported(): boolean;
  32337. /**
  32338. * Find the next highest power of two.
  32339. * @param x Number to start search from.
  32340. * @return Next highest power of two.
  32341. */
  32342. static CeilingPOT(x: number): number;
  32343. /**
  32344. * Find the next lowest power of two.
  32345. * @param x Number to start search from.
  32346. * @return Next lowest power of two.
  32347. */
  32348. static FloorPOT(x: number): number;
  32349. /**
  32350. * Find the nearest power of two.
  32351. * @param x Number to start search from.
  32352. * @return Next nearest power of two.
  32353. */
  32354. static NearestPOT(x: number): number;
  32355. /**
  32356. * Get the closest exponent of two
  32357. * @param value defines the value to approximate
  32358. * @param max defines the maximum value to return
  32359. * @param mode defines how to define the closest value
  32360. * @returns closest exponent of two of the given value
  32361. */
  32362. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32363. /**
  32364. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32365. * @param func - the function to be called
  32366. * @param requester - the object that will request the next frame. Falls back to window.
  32367. * @returns frame number
  32368. */
  32369. static QueueNewFrame(func: () => void, requester?: any): number;
  32370. /**
  32371. * Ask the browser to promote the current element to pointerlock mode
  32372. * @param element defines the DOM element to promote
  32373. */
  32374. static _RequestPointerlock(element: HTMLElement): void;
  32375. /**
  32376. * Asks the browser to exit pointerlock mode
  32377. */
  32378. static _ExitPointerlock(): void;
  32379. /**
  32380. * Ask the browser to promote the current element to fullscreen rendering mode
  32381. * @param element defines the DOM element to promote
  32382. */
  32383. static _RequestFullscreen(element: HTMLElement): void;
  32384. /**
  32385. * Asks the browser to exit fullscreen mode
  32386. */
  32387. static _ExitFullscreen(): void;
  32388. }
  32389. }
  32390. declare module "babylonjs/Engines/engineStore" {
  32391. import { Nullable } from "babylonjs/types";
  32392. import { Engine } from "babylonjs/Engines/engine";
  32393. import { Scene } from "babylonjs/scene";
  32394. /**
  32395. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32396. * during the life time of the application.
  32397. */
  32398. export class EngineStore {
  32399. /** Gets the list of created engines */
  32400. static Instances: import("babylonjs/Engines/engine").Engine[];
  32401. /** @hidden */
  32402. static _LastCreatedScene: Nullable<Scene>;
  32403. /**
  32404. * Gets the latest created engine
  32405. */
  32406. static readonly LastCreatedEngine: Nullable<Engine>;
  32407. /**
  32408. * Gets the latest created scene
  32409. */
  32410. static readonly LastCreatedScene: Nullable<Scene>;
  32411. /**
  32412. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32413. * @ignorenaming
  32414. */
  32415. static UseFallbackTexture: boolean;
  32416. /**
  32417. * Texture content used if a texture cannot loaded
  32418. * @ignorenaming
  32419. */
  32420. static FallbackTexture: string;
  32421. }
  32422. }
  32423. declare module "babylonjs/Misc/promise" {
  32424. /**
  32425. * Helper class that provides a small promise polyfill
  32426. */
  32427. export class PromisePolyfill {
  32428. /**
  32429. * Static function used to check if the polyfill is required
  32430. * If this is the case then the function will inject the polyfill to window.Promise
  32431. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32432. */
  32433. static Apply(force?: boolean): void;
  32434. }
  32435. }
  32436. declare module "babylonjs/Misc/tools" {
  32437. import { Nullable, float } from "babylonjs/types";
  32438. import { DomManagement } from "babylonjs/Misc/domManagement";
  32439. import { WebRequest } from "babylonjs/Misc/webRequest";
  32440. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32441. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32442. import { Camera } from "babylonjs/Cameras/camera";
  32443. import { Engine } from "babylonjs/Engines/engine";
  32444. interface IColor4Like {
  32445. r: float;
  32446. g: float;
  32447. b: float;
  32448. a: float;
  32449. }
  32450. /**
  32451. * Class containing a set of static utilities functions
  32452. */
  32453. export class Tools {
  32454. /**
  32455. * Gets or sets the base URL to use to load assets
  32456. */
  32457. static BaseUrl: string;
  32458. /**
  32459. * Enable/Disable Custom HTTP Request Headers globally.
  32460. * default = false
  32461. * @see CustomRequestHeaders
  32462. */
  32463. static UseCustomRequestHeaders: boolean;
  32464. /**
  32465. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32466. * i.e. when loading files, where the server/service expects an Authorization header
  32467. */
  32468. static CustomRequestHeaders: {
  32469. [key: string]: string;
  32470. };
  32471. /**
  32472. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32473. */
  32474. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32475. /**
  32476. * Default behaviour for cors in the application.
  32477. * It can be a string if the expected behavior is identical in the entire app.
  32478. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32479. */
  32480. static CorsBehavior: string | ((url: string | string[]) => string);
  32481. /**
  32482. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32483. * @ignorenaming
  32484. */
  32485. static UseFallbackTexture: boolean;
  32486. /**
  32487. * Use this object to register external classes like custom textures or material
  32488. * to allow the laoders to instantiate them
  32489. */
  32490. static RegisteredExternalClasses: {
  32491. [key: string]: Object;
  32492. };
  32493. /**
  32494. * Texture content used if a texture cannot loaded
  32495. * @ignorenaming
  32496. */
  32497. static fallbackTexture: string;
  32498. /**
  32499. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32500. * @param u defines the coordinate on X axis
  32501. * @param v defines the coordinate on Y axis
  32502. * @param width defines the width of the source data
  32503. * @param height defines the height of the source data
  32504. * @param pixels defines the source byte array
  32505. * @param color defines the output color
  32506. */
  32507. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32508. /**
  32509. * Interpolates between a and b via alpha
  32510. * @param a The lower value (returned when alpha = 0)
  32511. * @param b The upper value (returned when alpha = 1)
  32512. * @param alpha The interpolation-factor
  32513. * @return The mixed value
  32514. */
  32515. static Mix(a: number, b: number, alpha: number): number;
  32516. /**
  32517. * Tries to instantiate a new object from a given class name
  32518. * @param className defines the class name to instantiate
  32519. * @returns the new object or null if the system was not able to do the instantiation
  32520. */
  32521. static Instantiate(className: string): any;
  32522. /**
  32523. * Provides a slice function that will work even on IE
  32524. * @param data defines the array to slice
  32525. * @param start defines the start of the data (optional)
  32526. * @param end defines the end of the data (optional)
  32527. * @returns the new sliced array
  32528. */
  32529. static Slice<T>(data: T, start?: number, end?: number): T;
  32530. /**
  32531. * Polyfill for setImmediate
  32532. * @param action defines the action to execute after the current execution block
  32533. */
  32534. static SetImmediate(action: () => void): void;
  32535. /**
  32536. * Function indicating if a number is an exponent of 2
  32537. * @param value defines the value to test
  32538. * @returns true if the value is an exponent of 2
  32539. */
  32540. static IsExponentOfTwo(value: number): boolean;
  32541. private static _tmpFloatArray;
  32542. /**
  32543. * Returns the nearest 32-bit single precision float representation of a Number
  32544. * @param value A Number. If the parameter is of a different type, it will get converted
  32545. * to a number or to NaN if it cannot be converted
  32546. * @returns number
  32547. */
  32548. static FloatRound(value: number): number;
  32549. /**
  32550. * Extracts the filename from a path
  32551. * @param path defines the path to use
  32552. * @returns the filename
  32553. */
  32554. static GetFilename(path: string): string;
  32555. /**
  32556. * Extracts the "folder" part of a path (everything before the filename).
  32557. * @param uri The URI to extract the info from
  32558. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32559. * @returns The "folder" part of the path
  32560. */
  32561. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32562. /**
  32563. * Extracts text content from a DOM element hierarchy
  32564. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32565. */
  32566. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32567. /**
  32568. * Convert an angle in radians to degrees
  32569. * @param angle defines the angle to convert
  32570. * @returns the angle in degrees
  32571. */
  32572. static ToDegrees(angle: number): number;
  32573. /**
  32574. * Convert an angle in degrees to radians
  32575. * @param angle defines the angle to convert
  32576. * @returns the angle in radians
  32577. */
  32578. static ToRadians(angle: number): number;
  32579. /**
  32580. * Encode a buffer to a base64 string
  32581. * @param buffer defines the buffer to encode
  32582. * @returns the encoded string
  32583. */
  32584. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32585. /**
  32586. * Returns an array if obj is not an array
  32587. * @param obj defines the object to evaluate as an array
  32588. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32589. * @returns either obj directly if obj is an array or a new array containing obj
  32590. */
  32591. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32592. /**
  32593. * Gets the pointer prefix to use
  32594. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32595. */
  32596. static GetPointerPrefix(): string;
  32597. /**
  32598. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32599. * @param url define the url we are trying
  32600. * @param element define the dom element where to configure the cors policy
  32601. */
  32602. static SetCorsBehavior(url: string | string[], element: {
  32603. crossOrigin: string | null;
  32604. }): void;
  32605. /**
  32606. * Removes unwanted characters from an url
  32607. * @param url defines the url to clean
  32608. * @returns the cleaned url
  32609. */
  32610. static CleanUrl(url: string): string;
  32611. /**
  32612. * Gets or sets a function used to pre-process url before using them to load assets
  32613. */
  32614. static PreprocessUrl: (url: string) => string;
  32615. /**
  32616. * Loads an image as an HTMLImageElement.
  32617. * @param input url string, ArrayBuffer, or Blob to load
  32618. * @param onLoad callback called when the image successfully loads
  32619. * @param onError callback called when the image fails to load
  32620. * @param offlineProvider offline provider for caching
  32621. * @returns the HTMLImageElement of the loaded image
  32622. */
  32623. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32624. /**
  32625. * Loads a file
  32626. * @param url url string, ArrayBuffer, or Blob to load
  32627. * @param onSuccess callback called when the file successfully loads
  32628. * @param onProgress callback called while file is loading (if the server supports this mode)
  32629. * @param offlineProvider defines the offline provider for caching
  32630. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32631. * @param onError callback called when the file fails to load
  32632. * @returns a file request object
  32633. */
  32634. 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;
  32635. /**
  32636. * Loads a file from a url
  32637. * @param url the file url to load
  32638. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32639. */
  32640. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32641. /**
  32642. * Load a script (identified by an url). When the url returns, the
  32643. * content of this file is added into a new script element, attached to the DOM (body element)
  32644. * @param scriptUrl defines the url of the script to laod
  32645. * @param onSuccess defines the callback called when the script is loaded
  32646. * @param onError defines the callback to call if an error occurs
  32647. * @param scriptId defines the id of the script element
  32648. */
  32649. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32650. /**
  32651. * Load an asynchronous script (identified by an url). When the url returns, the
  32652. * content of this file is added into a new script element, attached to the DOM (body element)
  32653. * @param scriptUrl defines the url of the script to laod
  32654. * @param scriptId defines the id of the script element
  32655. * @returns a promise request object
  32656. */
  32657. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32658. /**
  32659. * Loads a file from a blob
  32660. * @param fileToLoad defines the blob to use
  32661. * @param callback defines the callback to call when data is loaded
  32662. * @param progressCallback defines the callback to call during loading process
  32663. * @returns a file request object
  32664. */
  32665. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32666. /**
  32667. * Loads a file
  32668. * @param fileToLoad defines the file to load
  32669. * @param callback defines the callback to call when data is loaded
  32670. * @param progressCallBack defines the callback to call during loading process
  32671. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32672. * @returns a file request object
  32673. */
  32674. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32675. /**
  32676. * Creates a data url from a given string content
  32677. * @param content defines the content to convert
  32678. * @returns the new data url link
  32679. */
  32680. static FileAsURL(content: string): string;
  32681. /**
  32682. * Format the given number to a specific decimal format
  32683. * @param value defines the number to format
  32684. * @param decimals defines the number of decimals to use
  32685. * @returns the formatted string
  32686. */
  32687. static Format(value: number, decimals?: number): string;
  32688. /**
  32689. * Tries to copy an object by duplicating every property
  32690. * @param source defines the source object
  32691. * @param destination defines the target object
  32692. * @param doNotCopyList defines a list of properties to avoid
  32693. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32694. */
  32695. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32696. /**
  32697. * Gets a boolean indicating if the given object has no own property
  32698. * @param obj defines the object to test
  32699. * @returns true if object has no own property
  32700. */
  32701. static IsEmpty(obj: any): boolean;
  32702. /**
  32703. * Function used to register events at window level
  32704. * @param events defines the events to register
  32705. */
  32706. static RegisterTopRootEvents(events: {
  32707. name: string;
  32708. handler: Nullable<(e: FocusEvent) => any>;
  32709. }[]): void;
  32710. /**
  32711. * Function used to unregister events from window level
  32712. * @param events defines the events to unregister
  32713. */
  32714. static UnregisterTopRootEvents(events: {
  32715. name: string;
  32716. handler: Nullable<(e: FocusEvent) => any>;
  32717. }[]): void;
  32718. /**
  32719. * @ignore
  32720. */
  32721. static _ScreenshotCanvas: HTMLCanvasElement;
  32722. /**
  32723. * Dumps the current bound framebuffer
  32724. * @param width defines the rendering width
  32725. * @param height defines the rendering height
  32726. * @param engine defines the hosting engine
  32727. * @param successCallback defines the callback triggered once the data are available
  32728. * @param mimeType defines the mime type of the result
  32729. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32730. */
  32731. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32732. /**
  32733. * Converts the canvas data to blob.
  32734. * This acts as a polyfill for browsers not supporting the to blob function.
  32735. * @param canvas Defines the canvas to extract the data from
  32736. * @param successCallback Defines the callback triggered once the data are available
  32737. * @param mimeType Defines the mime type of the result
  32738. */
  32739. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32740. /**
  32741. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32742. * @param successCallback defines the callback triggered once the data are available
  32743. * @param mimeType defines the mime type of the result
  32744. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32745. */
  32746. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32747. /**
  32748. * Downloads a blob in the browser
  32749. * @param blob defines the blob to download
  32750. * @param fileName defines the name of the downloaded file
  32751. */
  32752. static Download(blob: Blob, fileName: string): void;
  32753. /**
  32754. * Captures a screenshot of the current rendering
  32755. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32756. * @param engine defines the rendering engine
  32757. * @param camera defines the source camera
  32758. * @param size This parameter can be set to a single number or to an object with the
  32759. * following (optional) properties: precision, width, height. If a single number is passed,
  32760. * it will be used for both width and height. If an object is passed, the screenshot size
  32761. * will be derived from the parameters. The precision property is a multiplier allowing
  32762. * rendering at a higher or lower resolution
  32763. * @param successCallback defines the callback receives a single parameter which contains the
  32764. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32765. * src parameter of an <img> to display it
  32766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32767. * Check your browser for supported MIME types
  32768. */
  32769. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32770. /**
  32771. * Captures a screenshot of the current rendering
  32772. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32773. * @param engine defines the rendering engine
  32774. * @param camera defines the source camera
  32775. * @param size This parameter can be set to a single number or to an object with the
  32776. * following (optional) properties: precision, width, height. If a single number is passed,
  32777. * it will be used for both width and height. If an object is passed, the screenshot size
  32778. * will be derived from the parameters. The precision property is a multiplier allowing
  32779. * rendering at a higher or lower resolution
  32780. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32781. * Check your browser for supported MIME types
  32782. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32783. * to the src parameter of an <img> to display it
  32784. */
  32785. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  32786. /**
  32787. * Generates an image screenshot from the specified camera.
  32788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32789. * @param engine The engine to use for rendering
  32790. * @param camera The camera to use for rendering
  32791. * @param size This parameter can be set to a single number or to an object with the
  32792. * following (optional) properties: precision, width, height. If a single number is passed,
  32793. * it will be used for both width and height. If an object is passed, the screenshot size
  32794. * will be derived from the parameters. The precision property is a multiplier allowing
  32795. * rendering at a higher or lower resolution
  32796. * @param successCallback The callback receives a single parameter which contains the
  32797. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32798. * src parameter of an <img> to display it
  32799. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32800. * Check your browser for supported MIME types
  32801. * @param samples Texture samples (default: 1)
  32802. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32803. * @param fileName A name for for the downloaded file.
  32804. */
  32805. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32806. /**
  32807. * Generates an image screenshot from the specified camera.
  32808. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32809. * @param engine The engine to use for rendering
  32810. * @param camera The camera to use for rendering
  32811. * @param size This parameter can be set to a single number or to an object with the
  32812. * following (optional) properties: precision, width, height. If a single number is passed,
  32813. * it will be used for both width and height. If an object is passed, the screenshot size
  32814. * will be derived from the parameters. The precision property is a multiplier allowing
  32815. * rendering at a higher or lower resolution
  32816. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32817. * Check your browser for supported MIME types
  32818. * @param samples Texture samples (default: 1)
  32819. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32820. * @param fileName A name for for the downloaded file.
  32821. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32822. * to the src parameter of an <img> to display it
  32823. */
  32824. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32825. /**
  32826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32827. * Be aware Math.random() could cause collisions, but:
  32828. * "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"
  32829. * @returns a pseudo random id
  32830. */
  32831. static RandomId(): string;
  32832. /**
  32833. * Test if the given uri is a base64 string
  32834. * @param uri The uri to test
  32835. * @return True if the uri is a base64 string or false otherwise
  32836. */
  32837. static IsBase64(uri: string): boolean;
  32838. /**
  32839. * Decode the given base64 uri.
  32840. * @param uri The uri to decode
  32841. * @return The decoded base64 data.
  32842. */
  32843. static DecodeBase64(uri: string): ArrayBuffer;
  32844. /**
  32845. * Gets the absolute url.
  32846. * @param url the input url
  32847. * @return the absolute url
  32848. */
  32849. static GetAbsoluteUrl(url: string): string;
  32850. /**
  32851. * No log
  32852. */
  32853. static readonly NoneLogLevel: number;
  32854. /**
  32855. * Only message logs
  32856. */
  32857. static readonly MessageLogLevel: number;
  32858. /**
  32859. * Only warning logs
  32860. */
  32861. static readonly WarningLogLevel: number;
  32862. /**
  32863. * Only error logs
  32864. */
  32865. static readonly ErrorLogLevel: number;
  32866. /**
  32867. * All logs
  32868. */
  32869. static readonly AllLogLevel: number;
  32870. /**
  32871. * Gets a value indicating the number of loading errors
  32872. * @ignorenaming
  32873. */
  32874. static readonly errorsCount: number;
  32875. /**
  32876. * Callback called when a new log is added
  32877. */
  32878. static OnNewCacheEntry: (entry: string) => void;
  32879. /**
  32880. * Log a message to the console
  32881. * @param message defines the message to log
  32882. */
  32883. static Log(message: string): void;
  32884. /**
  32885. * Write a warning message to the console
  32886. * @param message defines the message to log
  32887. */
  32888. static Warn(message: string): void;
  32889. /**
  32890. * Write an error message to the console
  32891. * @param message defines the message to log
  32892. */
  32893. static Error(message: string): void;
  32894. /**
  32895. * Gets current log cache (list of logs)
  32896. */
  32897. static readonly LogCache: string;
  32898. /**
  32899. * Clears the log cache
  32900. */
  32901. static ClearLogCache(): void;
  32902. /**
  32903. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32904. */
  32905. static LogLevels: number;
  32906. /**
  32907. * Checks if the window object exists
  32908. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32909. */
  32910. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32911. /**
  32912. * No performance log
  32913. */
  32914. static readonly PerformanceNoneLogLevel: number;
  32915. /**
  32916. * Use user marks to log performance
  32917. */
  32918. static readonly PerformanceUserMarkLogLevel: number;
  32919. /**
  32920. * Log performance to the console
  32921. */
  32922. static readonly PerformanceConsoleLogLevel: number;
  32923. private static _performance;
  32924. /**
  32925. * Sets the current performance log level
  32926. */
  32927. static PerformanceLogLevel: number;
  32928. private static _StartPerformanceCounterDisabled;
  32929. private static _EndPerformanceCounterDisabled;
  32930. private static _StartUserMark;
  32931. private static _EndUserMark;
  32932. private static _StartPerformanceConsole;
  32933. private static _EndPerformanceConsole;
  32934. /**
  32935. * Starts a performance counter
  32936. */
  32937. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32938. /**
  32939. * Ends a specific performance coutner
  32940. */
  32941. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32942. /**
  32943. * Gets either window.performance.now() if supported or Date.now() else
  32944. */
  32945. static readonly Now: number;
  32946. /**
  32947. * This method will return the name of the class used to create the instance of the given object.
  32948. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32949. * @param object the object to get the class name from
  32950. * @param isType defines if the object is actually a type
  32951. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32952. */
  32953. static GetClassName(object: any, isType?: boolean): string;
  32954. /**
  32955. * Gets the first element of an array satisfying a given predicate
  32956. * @param array defines the array to browse
  32957. * @param predicate defines the predicate to use
  32958. * @returns null if not found or the element
  32959. */
  32960. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32961. /**
  32962. * This method will return the name of the full name of the class, including its owning module (if any).
  32963. * 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).
  32964. * @param object the object to get the class name from
  32965. * @param isType defines if the object is actually a type
  32966. * @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.
  32967. * @ignorenaming
  32968. */
  32969. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32970. /**
  32971. * Returns a promise that resolves after the given amount of time.
  32972. * @param delay Number of milliseconds to delay
  32973. * @returns Promise that resolves after the given amount of time
  32974. */
  32975. static DelayAsync(delay: number): Promise<void>;
  32976. }
  32977. /**
  32978. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32979. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32980. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32981. * @param name The name of the class, case should be preserved
  32982. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32983. */
  32984. export function className(name: string, module?: string): (target: Object) => void;
  32985. /**
  32986. * An implementation of a loop for asynchronous functions.
  32987. */
  32988. export class AsyncLoop {
  32989. /**
  32990. * Defines the number of iterations for the loop
  32991. */
  32992. iterations: number;
  32993. /**
  32994. * Defines the current index of the loop.
  32995. */
  32996. index: number;
  32997. private _done;
  32998. private _fn;
  32999. private _successCallback;
  33000. /**
  33001. * Constructor.
  33002. * @param iterations the number of iterations.
  33003. * @param func the function to run each iteration
  33004. * @param successCallback the callback that will be called upon succesful execution
  33005. * @param offset starting offset.
  33006. */
  33007. constructor(
  33008. /**
  33009. * Defines the number of iterations for the loop
  33010. */
  33011. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33012. /**
  33013. * Execute the next iteration. Must be called after the last iteration was finished.
  33014. */
  33015. executeNext(): void;
  33016. /**
  33017. * Break the loop and run the success callback.
  33018. */
  33019. breakLoop(): void;
  33020. /**
  33021. * Create and run an async loop.
  33022. * @param iterations the number of iterations.
  33023. * @param fn the function to run each iteration
  33024. * @param successCallback the callback that will be called upon succesful execution
  33025. * @param offset starting offset.
  33026. * @returns the created async loop object
  33027. */
  33028. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33029. /**
  33030. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33031. * @param iterations total number of iterations
  33032. * @param syncedIterations number of synchronous iterations in each async iteration.
  33033. * @param fn the function to call each iteration.
  33034. * @param callback a success call back that will be called when iterating stops.
  33035. * @param breakFunction a break condition (optional)
  33036. * @param timeout timeout settings for the setTimeout function. default - 0.
  33037. * @returns the created async loop object
  33038. */
  33039. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33040. }
  33041. }
  33042. declare module "babylonjs/Collisions/collisionCoordinator" {
  33043. import { Nullable } from "babylonjs/types";
  33044. import { Scene } from "babylonjs/scene";
  33045. import { Vector3 } from "babylonjs/Maths/math.vector";
  33046. import { Collider } from "babylonjs/Collisions/collider";
  33047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33048. /** @hidden */
  33049. export interface ICollisionCoordinator {
  33050. createCollider(): Collider;
  33051. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33052. init(scene: Scene): void;
  33053. }
  33054. /** @hidden */
  33055. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33056. private _scene;
  33057. private _scaledPosition;
  33058. private _scaledVelocity;
  33059. private _finalPosition;
  33060. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33061. createCollider(): Collider;
  33062. init(scene: Scene): void;
  33063. private _collideWithWorld;
  33064. }
  33065. }
  33066. declare module "babylonjs/Inputs/scene.inputManager" {
  33067. import { Nullable } from "babylonjs/types";
  33068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33069. import { Vector2 } from "babylonjs/Maths/math.vector";
  33070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33071. import { Scene } from "babylonjs/scene";
  33072. /**
  33073. * Class used to manage all inputs for the scene.
  33074. */
  33075. export class InputManager {
  33076. /** The distance in pixel that you have to move to prevent some events */
  33077. static DragMovementThreshold: number;
  33078. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33079. static LongPressDelay: number;
  33080. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33081. static DoubleClickDelay: number;
  33082. /** If you need to check double click without raising a single click at first click, enable this flag */
  33083. static ExclusiveDoubleClickMode: boolean;
  33084. private _wheelEventName;
  33085. private _onPointerMove;
  33086. private _onPointerDown;
  33087. private _onPointerUp;
  33088. private _initClickEvent;
  33089. private _initActionManager;
  33090. private _delayedSimpleClick;
  33091. private _delayedSimpleClickTimeout;
  33092. private _previousDelayedSimpleClickTimeout;
  33093. private _meshPickProceed;
  33094. private _previousButtonPressed;
  33095. private _currentPickResult;
  33096. private _previousPickResult;
  33097. private _totalPointersPressed;
  33098. private _doubleClickOccured;
  33099. private _pointerOverMesh;
  33100. private _pickedDownMesh;
  33101. private _pickedUpMesh;
  33102. private _pointerX;
  33103. private _pointerY;
  33104. private _unTranslatedPointerX;
  33105. private _unTranslatedPointerY;
  33106. private _startingPointerPosition;
  33107. private _previousStartingPointerPosition;
  33108. private _startingPointerTime;
  33109. private _previousStartingPointerTime;
  33110. private _pointerCaptures;
  33111. private _onKeyDown;
  33112. private _onKeyUp;
  33113. private _onCanvasFocusObserver;
  33114. private _onCanvasBlurObserver;
  33115. private _scene;
  33116. /**
  33117. * Creates a new InputManager
  33118. * @param scene defines the hosting scene
  33119. */
  33120. constructor(scene: Scene);
  33121. /**
  33122. * Gets the mesh that is currently under the pointer
  33123. */
  33124. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33125. /**
  33126. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33127. */
  33128. readonly unTranslatedPointer: Vector2;
  33129. /**
  33130. * Gets or sets the current on-screen X position of the pointer
  33131. */
  33132. pointerX: number;
  33133. /**
  33134. * Gets or sets the current on-screen Y position of the pointer
  33135. */
  33136. pointerY: number;
  33137. private _updatePointerPosition;
  33138. private _processPointerMove;
  33139. private _setRayOnPointerInfo;
  33140. private _checkPrePointerObservable;
  33141. /**
  33142. * Use this method to simulate a pointer move on a mesh
  33143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33146. */
  33147. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33148. /**
  33149. * Use this method to simulate a pointer down on a mesh
  33150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33153. */
  33154. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33155. private _processPointerDown;
  33156. /** @hidden */
  33157. _isPointerSwiping(): boolean;
  33158. /**
  33159. * Use this method to simulate a pointer up on a mesh
  33160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33163. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33164. */
  33165. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33166. private _processPointerUp;
  33167. /**
  33168. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33169. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33170. * @returns true if the pointer was captured
  33171. */
  33172. isPointerCaptured(pointerId?: number): boolean;
  33173. /**
  33174. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33175. * @param attachUp defines if you want to attach events to pointerup
  33176. * @param attachDown defines if you want to attach events to pointerdown
  33177. * @param attachMove defines if you want to attach events to pointermove
  33178. */
  33179. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33180. /**
  33181. * Detaches all event handlers
  33182. */
  33183. detachControl(): void;
  33184. /**
  33185. * Force the value of meshUnderPointer
  33186. * @param mesh defines the mesh to use
  33187. */
  33188. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33189. /**
  33190. * Gets the mesh under the pointer
  33191. * @returns a Mesh or null if no mesh is under the pointer
  33192. */
  33193. getPointerOverMesh(): Nullable<AbstractMesh>;
  33194. }
  33195. }
  33196. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33197. /**
  33198. * Helper class used to generate session unique ID
  33199. */
  33200. export class UniqueIdGenerator {
  33201. private static _UniqueIdCounter;
  33202. /**
  33203. * Gets an unique (relatively to the current scene) Id
  33204. */
  33205. static readonly UniqueId: number;
  33206. }
  33207. }
  33208. declare module "babylonjs/Animations/animationGroup" {
  33209. import { Animatable } from "babylonjs/Animations/animatable";
  33210. import { Animation } from "babylonjs/Animations/animation";
  33211. import { Scene, IDisposable } from "babylonjs/scene";
  33212. import { Observable } from "babylonjs/Misc/observable";
  33213. import { Nullable } from "babylonjs/types";
  33214. import "babylonjs/Animations/animatable";
  33215. /**
  33216. * This class defines the direct association between an animation and a target
  33217. */
  33218. export class TargetedAnimation {
  33219. /**
  33220. * Animation to perform
  33221. */
  33222. animation: Animation;
  33223. /**
  33224. * Target to animate
  33225. */
  33226. target: any;
  33227. /**
  33228. * Serialize the object
  33229. * @returns the JSON object representing the current entity
  33230. */
  33231. serialize(): any;
  33232. }
  33233. /**
  33234. * Use this class to create coordinated animations on multiple targets
  33235. */
  33236. export class AnimationGroup implements IDisposable {
  33237. /** The name of the animation group */
  33238. name: string;
  33239. private _scene;
  33240. private _targetedAnimations;
  33241. private _animatables;
  33242. private _from;
  33243. private _to;
  33244. private _isStarted;
  33245. private _isPaused;
  33246. private _speedRatio;
  33247. private _loopAnimation;
  33248. /**
  33249. * Gets or sets the unique id of the node
  33250. */
  33251. uniqueId: number;
  33252. /**
  33253. * This observable will notify when one animation have ended
  33254. */
  33255. onAnimationEndObservable: Observable<TargetedAnimation>;
  33256. /**
  33257. * Observer raised when one animation loops
  33258. */
  33259. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33260. /**
  33261. * This observable will notify when all animations have ended.
  33262. */
  33263. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33264. /**
  33265. * This observable will notify when all animations have paused.
  33266. */
  33267. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33268. /**
  33269. * This observable will notify when all animations are playing.
  33270. */
  33271. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33272. /**
  33273. * Gets the first frame
  33274. */
  33275. readonly from: number;
  33276. /**
  33277. * Gets the last frame
  33278. */
  33279. readonly to: number;
  33280. /**
  33281. * Define if the animations are started
  33282. */
  33283. readonly isStarted: boolean;
  33284. /**
  33285. * Gets a value indicating that the current group is playing
  33286. */
  33287. readonly isPlaying: boolean;
  33288. /**
  33289. * Gets or sets the speed ratio to use for all animations
  33290. */
  33291. /**
  33292. * Gets or sets the speed ratio to use for all animations
  33293. */
  33294. speedRatio: number;
  33295. /**
  33296. * Gets or sets if all animations should loop or not
  33297. */
  33298. loopAnimation: boolean;
  33299. /**
  33300. * Gets the targeted animations for this animation group
  33301. */
  33302. readonly targetedAnimations: Array<TargetedAnimation>;
  33303. /**
  33304. * returning the list of animatables controlled by this animation group.
  33305. */
  33306. readonly animatables: Array<Animatable>;
  33307. /**
  33308. * Instantiates a new Animation Group.
  33309. * This helps managing several animations at once.
  33310. * @see http://doc.babylonjs.com/how_to/group
  33311. * @param name Defines the name of the group
  33312. * @param scene Defines the scene the group belongs to
  33313. */
  33314. constructor(
  33315. /** The name of the animation group */
  33316. name: string, scene?: Nullable<Scene>);
  33317. /**
  33318. * Add an animation (with its target) in the group
  33319. * @param animation defines the animation we want to add
  33320. * @param target defines the target of the animation
  33321. * @returns the TargetedAnimation object
  33322. */
  33323. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33324. /**
  33325. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33326. * It can add constant keys at begin or end
  33327. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33328. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33329. * @returns the animation group
  33330. */
  33331. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33332. /**
  33333. * Start all animations on given targets
  33334. * @param loop defines if animations must loop
  33335. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33336. * @param from defines the from key (optional)
  33337. * @param to defines the to key (optional)
  33338. * @returns the current animation group
  33339. */
  33340. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33341. /**
  33342. * Pause all animations
  33343. * @returns the animation group
  33344. */
  33345. pause(): AnimationGroup;
  33346. /**
  33347. * Play all animations to initial state
  33348. * This function will start() the animations if they were not started or will restart() them if they were paused
  33349. * @param loop defines if animations must loop
  33350. * @returns the animation group
  33351. */
  33352. play(loop?: boolean): AnimationGroup;
  33353. /**
  33354. * Reset all animations to initial state
  33355. * @returns the animation group
  33356. */
  33357. reset(): AnimationGroup;
  33358. /**
  33359. * Restart animations from key 0
  33360. * @returns the animation group
  33361. */
  33362. restart(): AnimationGroup;
  33363. /**
  33364. * Stop all animations
  33365. * @returns the animation group
  33366. */
  33367. stop(): AnimationGroup;
  33368. /**
  33369. * Set animation weight for all animatables
  33370. * @param weight defines the weight to use
  33371. * @return the animationGroup
  33372. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33373. */
  33374. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33375. /**
  33376. * Synchronize and normalize all animatables with a source animatable
  33377. * @param root defines the root animatable to synchronize with
  33378. * @return the animationGroup
  33379. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33380. */
  33381. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33382. /**
  33383. * Goes to a specific frame in this animation group
  33384. * @param frame the frame number to go to
  33385. * @return the animationGroup
  33386. */
  33387. goToFrame(frame: number): AnimationGroup;
  33388. /**
  33389. * Dispose all associated resources
  33390. */
  33391. dispose(): void;
  33392. private _checkAnimationGroupEnded;
  33393. /**
  33394. * Clone the current animation group and returns a copy
  33395. * @param newName defines the name of the new group
  33396. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33397. * @returns the new aniamtion group
  33398. */
  33399. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33400. /**
  33401. * Serializes the animationGroup to an object
  33402. * @returns Serialized object
  33403. */
  33404. serialize(): any;
  33405. /**
  33406. * Returns a new AnimationGroup object parsed from the source provided.
  33407. * @param parsedAnimationGroup defines the source
  33408. * @param scene defines the scene that will receive the animationGroup
  33409. * @returns a new AnimationGroup
  33410. */
  33411. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33412. /**
  33413. * Returns the string "AnimationGroup"
  33414. * @returns "AnimationGroup"
  33415. */
  33416. getClassName(): string;
  33417. /**
  33418. * Creates a detailled string about the object
  33419. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33420. * @returns a string representing the object
  33421. */
  33422. toString(fullDetails?: boolean): string;
  33423. }
  33424. }
  33425. declare module "babylonjs/scene" {
  33426. import { Nullable } from "babylonjs/types";
  33427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33428. import { Observable } from "babylonjs/Misc/observable";
  33429. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33430. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33431. import { Geometry } from "babylonjs/Meshes/geometry";
  33432. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33435. import { Mesh } from "babylonjs/Meshes/mesh";
  33436. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33437. import { Bone } from "babylonjs/Bones/bone";
  33438. import { Skeleton } from "babylonjs/Bones/skeleton";
  33439. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33440. import { Camera } from "babylonjs/Cameras/camera";
  33441. import { AbstractScene } from "babylonjs/abstractScene";
  33442. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33443. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33444. import { Material } from "babylonjs/Materials/material";
  33445. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33446. import { Effect } from "babylonjs/Materials/effect";
  33447. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33448. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33449. import { Light } from "babylonjs/Lights/light";
  33450. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33451. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33452. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33453. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33454. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33455. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33456. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33457. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33458. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33459. import { Engine } from "babylonjs/Engines/engine";
  33460. import { Node } from "babylonjs/node";
  33461. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33462. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33463. import { WebRequest } from "babylonjs/Misc/webRequest";
  33464. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33465. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33467. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33468. import { Plane } from "babylonjs/Maths/math.plane";
  33469. import { Ray } from "babylonjs/Culling/ray";
  33470. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33471. import { Animation } from "babylonjs/Animations/animation";
  33472. import { Animatable } from "babylonjs/Animations/animatable";
  33473. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33474. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33475. import { Collider } from "babylonjs/Collisions/collider";
  33476. /**
  33477. * Define an interface for all classes that will hold resources
  33478. */
  33479. export interface IDisposable {
  33480. /**
  33481. * Releases all held resources
  33482. */
  33483. dispose(): void;
  33484. }
  33485. /** Interface defining initialization parameters for Scene class */
  33486. export interface SceneOptions {
  33487. /**
  33488. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33489. * It will improve performance when the number of geometries becomes important.
  33490. */
  33491. useGeometryUniqueIdsMap?: boolean;
  33492. /**
  33493. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33494. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33495. */
  33496. useMaterialMeshMap?: boolean;
  33497. /**
  33498. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33499. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33500. */
  33501. useClonedMeshhMap?: boolean;
  33502. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33503. virtual?: boolean;
  33504. }
  33505. /**
  33506. * Represents a scene to be rendered by the engine.
  33507. * @see http://doc.babylonjs.com/features/scene
  33508. */
  33509. export class Scene extends AbstractScene implements IAnimatable {
  33510. /** The fog is deactivated */
  33511. static readonly FOGMODE_NONE: number;
  33512. /** The fog density is following an exponential function */
  33513. static readonly FOGMODE_EXP: number;
  33514. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33515. static readonly FOGMODE_EXP2: number;
  33516. /** The fog density is following a linear function. */
  33517. static readonly FOGMODE_LINEAR: number;
  33518. /**
  33519. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33520. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33521. */
  33522. static MinDeltaTime: number;
  33523. /**
  33524. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33525. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33526. */
  33527. static MaxDeltaTime: number;
  33528. /**
  33529. * Factory used to create the default material.
  33530. * @param name The name of the material to create
  33531. * @param scene The scene to create the material for
  33532. * @returns The default material
  33533. */
  33534. static DefaultMaterialFactory(scene: Scene): Material;
  33535. /**
  33536. * Factory used to create the a collision coordinator.
  33537. * @returns The collision coordinator
  33538. */
  33539. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33540. /** @hidden */
  33541. _inputManager: InputManager;
  33542. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33543. cameraToUseForPointers: Nullable<Camera>;
  33544. /** @hidden */
  33545. readonly _isScene: boolean;
  33546. /**
  33547. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33548. */
  33549. autoClear: boolean;
  33550. /**
  33551. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33552. */
  33553. autoClearDepthAndStencil: boolean;
  33554. /**
  33555. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33556. */
  33557. clearColor: Color4;
  33558. /**
  33559. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33560. */
  33561. ambientColor: Color3;
  33562. /**
  33563. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33564. * It should only be one of the following (if not the default embedded one):
  33565. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33566. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33567. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33568. * The material properties need to be setup according to the type of texture in use.
  33569. */
  33570. environmentBRDFTexture: BaseTexture;
  33571. /** @hidden */
  33572. protected _environmentTexture: Nullable<BaseTexture>;
  33573. /**
  33574. * Texture used in all pbr material as the reflection texture.
  33575. * As in the majority of the scene they are the same (exception for multi room and so on),
  33576. * this is easier to reference from here than from all the materials.
  33577. */
  33578. /**
  33579. * Texture used in all pbr material as the reflection texture.
  33580. * As in the majority of the scene they are the same (exception for multi room and so on),
  33581. * this is easier to set here than in all the materials.
  33582. */
  33583. environmentTexture: Nullable<BaseTexture>;
  33584. /** @hidden */
  33585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33586. /**
  33587. * Default image processing configuration used either in the rendering
  33588. * Forward main pass or through the imageProcessingPostProcess if present.
  33589. * As in the majority of the scene they are the same (exception for multi camera),
  33590. * this is easier to reference from here than from all the materials and post process.
  33591. *
  33592. * No setter as we it is a shared configuration, you can set the values instead.
  33593. */
  33594. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33595. private _forceWireframe;
  33596. /**
  33597. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33598. */
  33599. forceWireframe: boolean;
  33600. private _forcePointsCloud;
  33601. /**
  33602. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33603. */
  33604. forcePointsCloud: boolean;
  33605. /**
  33606. * Gets or sets the active clipplane 1
  33607. */
  33608. clipPlane: Nullable<Plane>;
  33609. /**
  33610. * Gets or sets the active clipplane 2
  33611. */
  33612. clipPlane2: Nullable<Plane>;
  33613. /**
  33614. * Gets or sets the active clipplane 3
  33615. */
  33616. clipPlane3: Nullable<Plane>;
  33617. /**
  33618. * Gets or sets the active clipplane 4
  33619. */
  33620. clipPlane4: Nullable<Plane>;
  33621. /**
  33622. * Gets or sets a boolean indicating if animations are enabled
  33623. */
  33624. animationsEnabled: boolean;
  33625. private _animationPropertiesOverride;
  33626. /**
  33627. * Gets or sets the animation properties override
  33628. */
  33629. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33630. /**
  33631. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33632. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33633. */
  33634. useConstantAnimationDeltaTime: boolean;
  33635. /**
  33636. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33637. * Please note that it requires to run a ray cast through the scene on every frame
  33638. */
  33639. constantlyUpdateMeshUnderPointer: boolean;
  33640. /**
  33641. * Defines the HTML cursor to use when hovering over interactive elements
  33642. */
  33643. hoverCursor: string;
  33644. /**
  33645. * Defines the HTML default cursor to use (empty by default)
  33646. */
  33647. defaultCursor: string;
  33648. /**
  33649. * This is used to call preventDefault() on pointer down
  33650. * in order to block unwanted artifacts like system double clicks
  33651. */
  33652. preventDefaultOnPointerDown: boolean;
  33653. /**
  33654. * This is used to call preventDefault() on pointer up
  33655. * in order to block unwanted artifacts like system double clicks
  33656. */
  33657. preventDefaultOnPointerUp: boolean;
  33658. /**
  33659. * Gets or sets user defined metadata
  33660. */
  33661. metadata: any;
  33662. /**
  33663. * For internal use only. Please do not use.
  33664. */
  33665. reservedDataStore: any;
  33666. /**
  33667. * Gets the name of the plugin used to load this scene (null by default)
  33668. */
  33669. loadingPluginName: string;
  33670. /**
  33671. * Use this array to add regular expressions used to disable offline support for specific urls
  33672. */
  33673. disableOfflineSupportExceptionRules: RegExp[];
  33674. /**
  33675. * An event triggered when the scene is disposed.
  33676. */
  33677. onDisposeObservable: Observable<Scene>;
  33678. private _onDisposeObserver;
  33679. /** Sets a function to be executed when this scene is disposed. */
  33680. onDispose: () => void;
  33681. /**
  33682. * An event triggered before rendering the scene (right after animations and physics)
  33683. */
  33684. onBeforeRenderObservable: Observable<Scene>;
  33685. private _onBeforeRenderObserver;
  33686. /** Sets a function to be executed before rendering this scene */
  33687. beforeRender: Nullable<() => void>;
  33688. /**
  33689. * An event triggered after rendering the scene
  33690. */
  33691. onAfterRenderObservable: Observable<Scene>;
  33692. /**
  33693. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33694. */
  33695. onAfterRenderCameraObservable: Observable<Camera>;
  33696. private _onAfterRenderObserver;
  33697. /** Sets a function to be executed after rendering this scene */
  33698. afterRender: Nullable<() => void>;
  33699. /**
  33700. * An event triggered before animating the scene
  33701. */
  33702. onBeforeAnimationsObservable: Observable<Scene>;
  33703. /**
  33704. * An event triggered after animations processing
  33705. */
  33706. onAfterAnimationsObservable: Observable<Scene>;
  33707. /**
  33708. * An event triggered before draw calls are ready to be sent
  33709. */
  33710. onBeforeDrawPhaseObservable: Observable<Scene>;
  33711. /**
  33712. * An event triggered after draw calls have been sent
  33713. */
  33714. onAfterDrawPhaseObservable: Observable<Scene>;
  33715. /**
  33716. * An event triggered when the scene is ready
  33717. */
  33718. onReadyObservable: Observable<Scene>;
  33719. /**
  33720. * An event triggered before rendering a camera
  33721. */
  33722. onBeforeCameraRenderObservable: Observable<Camera>;
  33723. private _onBeforeCameraRenderObserver;
  33724. /** Sets a function to be executed before rendering a camera*/
  33725. beforeCameraRender: () => void;
  33726. /**
  33727. * An event triggered after rendering a camera
  33728. */
  33729. onAfterCameraRenderObservable: Observable<Camera>;
  33730. private _onAfterCameraRenderObserver;
  33731. /** Sets a function to be executed after rendering a camera*/
  33732. afterCameraRender: () => void;
  33733. /**
  33734. * An event triggered when active meshes evaluation is about to start
  33735. */
  33736. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33737. /**
  33738. * An event triggered when active meshes evaluation is done
  33739. */
  33740. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33741. /**
  33742. * An event triggered when particles rendering is about to start
  33743. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33744. */
  33745. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33746. /**
  33747. * An event triggered when particles rendering is done
  33748. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33749. */
  33750. onAfterParticlesRenderingObservable: Observable<Scene>;
  33751. /**
  33752. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33753. */
  33754. onDataLoadedObservable: Observable<Scene>;
  33755. /**
  33756. * An event triggered when a camera is created
  33757. */
  33758. onNewCameraAddedObservable: Observable<Camera>;
  33759. /**
  33760. * An event triggered when a camera is removed
  33761. */
  33762. onCameraRemovedObservable: Observable<Camera>;
  33763. /**
  33764. * An event triggered when a light is created
  33765. */
  33766. onNewLightAddedObservable: Observable<Light>;
  33767. /**
  33768. * An event triggered when a light is removed
  33769. */
  33770. onLightRemovedObservable: Observable<Light>;
  33771. /**
  33772. * An event triggered when a geometry is created
  33773. */
  33774. onNewGeometryAddedObservable: Observable<Geometry>;
  33775. /**
  33776. * An event triggered when a geometry is removed
  33777. */
  33778. onGeometryRemovedObservable: Observable<Geometry>;
  33779. /**
  33780. * An event triggered when a transform node is created
  33781. */
  33782. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33783. /**
  33784. * An event triggered when a transform node is removed
  33785. */
  33786. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33787. /**
  33788. * An event triggered when a mesh is created
  33789. */
  33790. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33791. /**
  33792. * An event triggered when a mesh is removed
  33793. */
  33794. onMeshRemovedObservable: Observable<AbstractMesh>;
  33795. /**
  33796. * An event triggered when a skeleton is created
  33797. */
  33798. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33799. /**
  33800. * An event triggered when a skeleton is removed
  33801. */
  33802. onSkeletonRemovedObservable: Observable<Skeleton>;
  33803. /**
  33804. * An event triggered when a material is created
  33805. */
  33806. onNewMaterialAddedObservable: Observable<Material>;
  33807. /**
  33808. * An event triggered when a material is removed
  33809. */
  33810. onMaterialRemovedObservable: Observable<Material>;
  33811. /**
  33812. * An event triggered when a texture is created
  33813. */
  33814. onNewTextureAddedObservable: Observable<BaseTexture>;
  33815. /**
  33816. * An event triggered when a texture is removed
  33817. */
  33818. onTextureRemovedObservable: Observable<BaseTexture>;
  33819. /**
  33820. * An event triggered when render targets are about to be rendered
  33821. * Can happen multiple times per frame.
  33822. */
  33823. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33824. /**
  33825. * An event triggered when render targets were rendered.
  33826. * Can happen multiple times per frame.
  33827. */
  33828. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33829. /**
  33830. * An event triggered before calculating deterministic simulation step
  33831. */
  33832. onBeforeStepObservable: Observable<Scene>;
  33833. /**
  33834. * An event triggered after calculating deterministic simulation step
  33835. */
  33836. onAfterStepObservable: Observable<Scene>;
  33837. /**
  33838. * An event triggered when the activeCamera property is updated
  33839. */
  33840. onActiveCameraChanged: Observable<Scene>;
  33841. /**
  33842. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33843. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33844. * 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)
  33845. */
  33846. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33847. /**
  33848. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33849. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33850. * 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)
  33851. */
  33852. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33853. /**
  33854. * This Observable will when a mesh has been imported into the scene.
  33855. */
  33856. onMeshImportedObservable: Observable<AbstractMesh>;
  33857. /**
  33858. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33859. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33860. */
  33861. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33862. /** @hidden */
  33863. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33864. /**
  33865. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33866. */
  33867. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33868. /**
  33869. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33870. */
  33871. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33872. /**
  33873. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33874. */
  33875. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33876. /** Callback called when a pointer move is detected */
  33877. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33878. /** Callback called when a pointer down is detected */
  33879. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33880. /** Callback called when a pointer up is detected */
  33881. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33882. /** Callback called when a pointer pick is detected */
  33883. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33884. /**
  33885. * 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).
  33886. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33887. */
  33888. onPrePointerObservable: Observable<PointerInfoPre>;
  33889. /**
  33890. * Observable event triggered each time an input event is received from the rendering canvas
  33891. */
  33892. onPointerObservable: Observable<PointerInfo>;
  33893. /**
  33894. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33895. */
  33896. readonly unTranslatedPointer: Vector2;
  33897. /**
  33898. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33899. */
  33900. static DragMovementThreshold: number;
  33901. /**
  33902. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33903. */
  33904. static LongPressDelay: number;
  33905. /**
  33906. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33907. */
  33908. static DoubleClickDelay: number;
  33909. /** If you need to check double click without raising a single click at first click, enable this flag */
  33910. static ExclusiveDoubleClickMode: boolean;
  33911. /** @hidden */
  33912. _mirroredCameraPosition: Nullable<Vector3>;
  33913. /**
  33914. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33915. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33916. */
  33917. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33918. /**
  33919. * Observable event triggered each time an keyboard event is received from the hosting window
  33920. */
  33921. onKeyboardObservable: Observable<KeyboardInfo>;
  33922. private _useRightHandedSystem;
  33923. /**
  33924. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33925. */
  33926. useRightHandedSystem: boolean;
  33927. private _timeAccumulator;
  33928. private _currentStepId;
  33929. private _currentInternalStep;
  33930. /**
  33931. * Sets the step Id used by deterministic lock step
  33932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33933. * @param newStepId defines the step Id
  33934. */
  33935. setStepId(newStepId: number): void;
  33936. /**
  33937. * Gets the step Id used by deterministic lock step
  33938. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33939. * @returns the step Id
  33940. */
  33941. getStepId(): number;
  33942. /**
  33943. * Gets the internal step used by deterministic lock step
  33944. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33945. * @returns the internal step
  33946. */
  33947. getInternalStep(): number;
  33948. private _fogEnabled;
  33949. /**
  33950. * Gets or sets a boolean indicating if fog is enabled on this scene
  33951. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33952. * (Default is true)
  33953. */
  33954. fogEnabled: boolean;
  33955. private _fogMode;
  33956. /**
  33957. * Gets or sets the fog mode to use
  33958. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33959. * | mode | value |
  33960. * | --- | --- |
  33961. * | FOGMODE_NONE | 0 |
  33962. * | FOGMODE_EXP | 1 |
  33963. * | FOGMODE_EXP2 | 2 |
  33964. * | FOGMODE_LINEAR | 3 |
  33965. */
  33966. fogMode: number;
  33967. /**
  33968. * Gets or sets the fog color to use
  33969. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33970. * (Default is Color3(0.2, 0.2, 0.3))
  33971. */
  33972. fogColor: Color3;
  33973. /**
  33974. * Gets or sets the fog density to use
  33975. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33976. * (Default is 0.1)
  33977. */
  33978. fogDensity: number;
  33979. /**
  33980. * Gets or sets the fog start distance to use
  33981. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33982. * (Default is 0)
  33983. */
  33984. fogStart: number;
  33985. /**
  33986. * Gets or sets the fog end distance to use
  33987. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33988. * (Default is 1000)
  33989. */
  33990. fogEnd: number;
  33991. private _shadowsEnabled;
  33992. /**
  33993. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33994. */
  33995. shadowsEnabled: boolean;
  33996. private _lightsEnabled;
  33997. /**
  33998. * Gets or sets a boolean indicating if lights are enabled on this scene
  33999. */
  34000. lightsEnabled: boolean;
  34001. /** All of the active cameras added to this scene. */
  34002. activeCameras: Camera[];
  34003. /** @hidden */
  34004. _activeCamera: Nullable<Camera>;
  34005. /** Gets or sets the current active camera */
  34006. activeCamera: Nullable<Camera>;
  34007. private _defaultMaterial;
  34008. /** The default material used on meshes when no material is affected */
  34009. /** The default material used on meshes when no material is affected */
  34010. defaultMaterial: Material;
  34011. private _texturesEnabled;
  34012. /**
  34013. * Gets or sets a boolean indicating if textures are enabled on this scene
  34014. */
  34015. texturesEnabled: boolean;
  34016. /**
  34017. * Gets or sets a boolean indicating if particles are enabled on this scene
  34018. */
  34019. particlesEnabled: boolean;
  34020. /**
  34021. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34022. */
  34023. spritesEnabled: boolean;
  34024. private _skeletonsEnabled;
  34025. /**
  34026. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34027. */
  34028. skeletonsEnabled: boolean;
  34029. /**
  34030. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34031. */
  34032. lensFlaresEnabled: boolean;
  34033. /**
  34034. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34036. */
  34037. collisionsEnabled: boolean;
  34038. private _collisionCoordinator;
  34039. /** @hidden */
  34040. readonly collisionCoordinator: ICollisionCoordinator;
  34041. /**
  34042. * Defines the gravity applied to this scene (used only for collisions)
  34043. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34044. */
  34045. gravity: Vector3;
  34046. /**
  34047. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34048. */
  34049. postProcessesEnabled: boolean;
  34050. /**
  34051. * The list of postprocesses added to the scene
  34052. */
  34053. postProcesses: PostProcess[];
  34054. /**
  34055. * Gets the current postprocess manager
  34056. */
  34057. postProcessManager: PostProcessManager;
  34058. /**
  34059. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34060. */
  34061. renderTargetsEnabled: boolean;
  34062. /**
  34063. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34064. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34065. */
  34066. dumpNextRenderTargets: boolean;
  34067. /**
  34068. * The list of user defined render targets added to the scene
  34069. */
  34070. customRenderTargets: RenderTargetTexture[];
  34071. /**
  34072. * Defines if texture loading must be delayed
  34073. * If true, textures will only be loaded when they need to be rendered
  34074. */
  34075. useDelayedTextureLoading: boolean;
  34076. /**
  34077. * Gets the list of meshes imported to the scene through SceneLoader
  34078. */
  34079. importedMeshesFiles: String[];
  34080. /**
  34081. * Gets or sets a boolean indicating if probes are enabled on this scene
  34082. */
  34083. probesEnabled: boolean;
  34084. /**
  34085. * Gets or sets the current offline provider to use to store scene data
  34086. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34087. */
  34088. offlineProvider: IOfflineProvider;
  34089. /**
  34090. * Gets or sets the action manager associated with the scene
  34091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34092. */
  34093. actionManager: AbstractActionManager;
  34094. private _meshesForIntersections;
  34095. /**
  34096. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34097. */
  34098. proceduralTexturesEnabled: boolean;
  34099. private _engine;
  34100. private _totalVertices;
  34101. /** @hidden */
  34102. _activeIndices: PerfCounter;
  34103. /** @hidden */
  34104. _activeParticles: PerfCounter;
  34105. /** @hidden */
  34106. _activeBones: PerfCounter;
  34107. private _animationRatio;
  34108. /** @hidden */
  34109. _animationTimeLast: number;
  34110. /** @hidden */
  34111. _animationTime: number;
  34112. /**
  34113. * Gets or sets a general scale for animation speed
  34114. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34115. */
  34116. animationTimeScale: number;
  34117. /** @hidden */
  34118. _cachedMaterial: Nullable<Material>;
  34119. /** @hidden */
  34120. _cachedEffect: Nullable<Effect>;
  34121. /** @hidden */
  34122. _cachedVisibility: Nullable<number>;
  34123. private _renderId;
  34124. private _frameId;
  34125. private _executeWhenReadyTimeoutId;
  34126. private _intermediateRendering;
  34127. private _viewUpdateFlag;
  34128. private _projectionUpdateFlag;
  34129. /** @hidden */
  34130. _toBeDisposed: Nullable<IDisposable>[];
  34131. private _activeRequests;
  34132. /** @hidden */
  34133. _pendingData: any[];
  34134. private _isDisposed;
  34135. /**
  34136. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34137. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34138. */
  34139. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34140. private _activeMeshes;
  34141. private _processedMaterials;
  34142. private _renderTargets;
  34143. /** @hidden */
  34144. _activeParticleSystems: SmartArray<IParticleSystem>;
  34145. private _activeSkeletons;
  34146. private _softwareSkinnedMeshes;
  34147. private _renderingManager;
  34148. /** @hidden */
  34149. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34150. private _transformMatrix;
  34151. private _sceneUbo;
  34152. /** @hidden */
  34153. _viewMatrix: Matrix;
  34154. private _projectionMatrix;
  34155. /** @hidden */
  34156. _forcedViewPosition: Nullable<Vector3>;
  34157. /** @hidden */
  34158. _frustumPlanes: Plane[];
  34159. /**
  34160. * Gets the list of frustum planes (built from the active camera)
  34161. */
  34162. readonly frustumPlanes: Plane[];
  34163. /**
  34164. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34165. * This is useful if there are more lights that the maximum simulteanous authorized
  34166. */
  34167. requireLightSorting: boolean;
  34168. /** @hidden */
  34169. readonly useMaterialMeshMap: boolean;
  34170. /** @hidden */
  34171. readonly useClonedMeshhMap: boolean;
  34172. private _externalData;
  34173. private _uid;
  34174. /**
  34175. * @hidden
  34176. * Backing store of defined scene components.
  34177. */
  34178. _components: ISceneComponent[];
  34179. /**
  34180. * @hidden
  34181. * Backing store of defined scene components.
  34182. */
  34183. _serializableComponents: ISceneSerializableComponent[];
  34184. /**
  34185. * List of components to register on the next registration step.
  34186. */
  34187. private _transientComponents;
  34188. /**
  34189. * Registers the transient components if needed.
  34190. */
  34191. private _registerTransientComponents;
  34192. /**
  34193. * @hidden
  34194. * Add a component to the scene.
  34195. * Note that the ccomponent could be registered on th next frame if this is called after
  34196. * the register component stage.
  34197. * @param component Defines the component to add to the scene
  34198. */
  34199. _addComponent(component: ISceneComponent): void;
  34200. /**
  34201. * @hidden
  34202. * Gets a component from the scene.
  34203. * @param name defines the name of the component to retrieve
  34204. * @returns the component or null if not present
  34205. */
  34206. _getComponent(name: string): Nullable<ISceneComponent>;
  34207. /**
  34208. * @hidden
  34209. * Defines the actions happening before camera updates.
  34210. */
  34211. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34212. /**
  34213. * @hidden
  34214. * Defines the actions happening before clear the canvas.
  34215. */
  34216. _beforeClearStage: Stage<SimpleStageAction>;
  34217. /**
  34218. * @hidden
  34219. * Defines the actions when collecting render targets for the frame.
  34220. */
  34221. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34222. /**
  34223. * @hidden
  34224. * Defines the actions happening for one camera in the frame.
  34225. */
  34226. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34227. /**
  34228. * @hidden
  34229. * Defines the actions happening during the per mesh ready checks.
  34230. */
  34231. _isReadyForMeshStage: Stage<MeshStageAction>;
  34232. /**
  34233. * @hidden
  34234. * Defines the actions happening before evaluate active mesh checks.
  34235. */
  34236. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34237. /**
  34238. * @hidden
  34239. * Defines the actions happening during the evaluate sub mesh checks.
  34240. */
  34241. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34242. /**
  34243. * @hidden
  34244. * Defines the actions happening during the active mesh stage.
  34245. */
  34246. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34247. /**
  34248. * @hidden
  34249. * Defines the actions happening during the per camera render target step.
  34250. */
  34251. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34252. /**
  34253. * @hidden
  34254. * Defines the actions happening just before the active camera is drawing.
  34255. */
  34256. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34257. /**
  34258. * @hidden
  34259. * Defines the actions happening just before a render target is drawing.
  34260. */
  34261. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34262. /**
  34263. * @hidden
  34264. * Defines the actions happening just before a rendering group is drawing.
  34265. */
  34266. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34267. /**
  34268. * @hidden
  34269. * Defines the actions happening just before a mesh is drawing.
  34270. */
  34271. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34272. /**
  34273. * @hidden
  34274. * Defines the actions happening just after a mesh has been drawn.
  34275. */
  34276. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34277. /**
  34278. * @hidden
  34279. * Defines the actions happening just after a rendering group has been drawn.
  34280. */
  34281. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34282. /**
  34283. * @hidden
  34284. * Defines the actions happening just after the active camera has been drawn.
  34285. */
  34286. _afterCameraDrawStage: Stage<CameraStageAction>;
  34287. /**
  34288. * @hidden
  34289. * Defines the actions happening just after a render target has been drawn.
  34290. */
  34291. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34292. /**
  34293. * @hidden
  34294. * Defines the actions happening just after rendering all cameras and computing intersections.
  34295. */
  34296. _afterRenderStage: Stage<SimpleStageAction>;
  34297. /**
  34298. * @hidden
  34299. * Defines the actions happening when a pointer move event happens.
  34300. */
  34301. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34302. /**
  34303. * @hidden
  34304. * Defines the actions happening when a pointer down event happens.
  34305. */
  34306. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34307. /**
  34308. * @hidden
  34309. * Defines the actions happening when a pointer up event happens.
  34310. */
  34311. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34312. /**
  34313. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34314. */
  34315. private geometriesByUniqueId;
  34316. /**
  34317. * Creates a new Scene
  34318. * @param engine defines the engine to use to render this scene
  34319. * @param options defines the scene options
  34320. */
  34321. constructor(engine: Engine, options?: SceneOptions);
  34322. /**
  34323. * Gets a string idenfifying the name of the class
  34324. * @returns "Scene" string
  34325. */
  34326. getClassName(): string;
  34327. private _defaultMeshCandidates;
  34328. /**
  34329. * @hidden
  34330. */
  34331. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34332. private _defaultSubMeshCandidates;
  34333. /**
  34334. * @hidden
  34335. */
  34336. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34337. /**
  34338. * Sets the default candidate providers for the scene.
  34339. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34340. * and getCollidingSubMeshCandidates to their default function
  34341. */
  34342. setDefaultCandidateProviders(): void;
  34343. /**
  34344. * Gets the mesh that is currently under the pointer
  34345. */
  34346. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34347. /**
  34348. * Gets or sets the current on-screen X position of the pointer
  34349. */
  34350. pointerX: number;
  34351. /**
  34352. * Gets or sets the current on-screen Y position of the pointer
  34353. */
  34354. pointerY: number;
  34355. /**
  34356. * Gets the cached material (ie. the latest rendered one)
  34357. * @returns the cached material
  34358. */
  34359. getCachedMaterial(): Nullable<Material>;
  34360. /**
  34361. * Gets the cached effect (ie. the latest rendered one)
  34362. * @returns the cached effect
  34363. */
  34364. getCachedEffect(): Nullable<Effect>;
  34365. /**
  34366. * Gets the cached visibility state (ie. the latest rendered one)
  34367. * @returns the cached visibility state
  34368. */
  34369. getCachedVisibility(): Nullable<number>;
  34370. /**
  34371. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34372. * @param material defines the current material
  34373. * @param effect defines the current effect
  34374. * @param visibility defines the current visibility state
  34375. * @returns true if one parameter is not cached
  34376. */
  34377. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34378. /**
  34379. * Gets the engine associated with the scene
  34380. * @returns an Engine
  34381. */
  34382. getEngine(): Engine;
  34383. /**
  34384. * Gets the total number of vertices rendered per frame
  34385. * @returns the total number of vertices rendered per frame
  34386. */
  34387. getTotalVertices(): number;
  34388. /**
  34389. * Gets the performance counter for total vertices
  34390. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34391. */
  34392. readonly totalVerticesPerfCounter: PerfCounter;
  34393. /**
  34394. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34395. * @returns the total number of active indices rendered per frame
  34396. */
  34397. getActiveIndices(): number;
  34398. /**
  34399. * Gets the performance counter for active indices
  34400. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34401. */
  34402. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34403. /**
  34404. * Gets the total number of active particles rendered per frame
  34405. * @returns the total number of active particles rendered per frame
  34406. */
  34407. getActiveParticles(): number;
  34408. /**
  34409. * Gets the performance counter for active particles
  34410. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34411. */
  34412. readonly activeParticlesPerfCounter: PerfCounter;
  34413. /**
  34414. * Gets the total number of active bones rendered per frame
  34415. * @returns the total number of active bones rendered per frame
  34416. */
  34417. getActiveBones(): number;
  34418. /**
  34419. * Gets the performance counter for active bones
  34420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34421. */
  34422. readonly activeBonesPerfCounter: PerfCounter;
  34423. /**
  34424. * Gets the array of active meshes
  34425. * @returns an array of AbstractMesh
  34426. */
  34427. getActiveMeshes(): SmartArray<AbstractMesh>;
  34428. /**
  34429. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34430. * @returns a number
  34431. */
  34432. getAnimationRatio(): number;
  34433. /**
  34434. * Gets an unique Id for the current render phase
  34435. * @returns a number
  34436. */
  34437. getRenderId(): number;
  34438. /**
  34439. * Gets an unique Id for the current frame
  34440. * @returns a number
  34441. */
  34442. getFrameId(): number;
  34443. /** Call this function if you want to manually increment the render Id*/
  34444. incrementRenderId(): void;
  34445. private _createUbo;
  34446. /**
  34447. * Use this method to simulate a pointer move on a mesh
  34448. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34449. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34450. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34451. * @returns the current scene
  34452. */
  34453. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34454. /**
  34455. * Use this method to simulate a pointer down on a mesh
  34456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34459. * @returns the current scene
  34460. */
  34461. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34462. /**
  34463. * Use this method to simulate a pointer up on a mesh
  34464. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34465. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34466. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34467. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34468. * @returns the current scene
  34469. */
  34470. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34471. /**
  34472. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34473. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34474. * @returns true if the pointer was captured
  34475. */
  34476. isPointerCaptured(pointerId?: number): boolean;
  34477. /**
  34478. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34479. * @param attachUp defines if you want to attach events to pointerup
  34480. * @param attachDown defines if you want to attach events to pointerdown
  34481. * @param attachMove defines if you want to attach events to pointermove
  34482. */
  34483. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34484. /** Detaches all event handlers*/
  34485. detachControl(): void;
  34486. /**
  34487. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34488. * Delay loaded resources are not taking in account
  34489. * @return true if all required resources are ready
  34490. */
  34491. isReady(): boolean;
  34492. /** Resets all cached information relative to material (including effect and visibility) */
  34493. resetCachedMaterial(): void;
  34494. /**
  34495. * Registers a function to be called before every frame render
  34496. * @param func defines the function to register
  34497. */
  34498. registerBeforeRender(func: () => void): void;
  34499. /**
  34500. * Unregisters a function called before every frame render
  34501. * @param func defines the function to unregister
  34502. */
  34503. unregisterBeforeRender(func: () => void): void;
  34504. /**
  34505. * Registers a function to be called after every frame render
  34506. * @param func defines the function to register
  34507. */
  34508. registerAfterRender(func: () => void): void;
  34509. /**
  34510. * Unregisters a function called after every frame render
  34511. * @param func defines the function to unregister
  34512. */
  34513. unregisterAfterRender(func: () => void): void;
  34514. private _executeOnceBeforeRender;
  34515. /**
  34516. * The provided function will run before render once and will be disposed afterwards.
  34517. * A timeout delay can be provided so that the function will be executed in N ms.
  34518. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34519. * @param func The function to be executed.
  34520. * @param timeout optional delay in ms
  34521. */
  34522. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34523. /** @hidden */
  34524. _addPendingData(data: any): void;
  34525. /** @hidden */
  34526. _removePendingData(data: any): void;
  34527. /**
  34528. * Returns the number of items waiting to be loaded
  34529. * @returns the number of items waiting to be loaded
  34530. */
  34531. getWaitingItemsCount(): number;
  34532. /**
  34533. * Returns a boolean indicating if the scene is still loading data
  34534. */
  34535. readonly isLoading: boolean;
  34536. /**
  34537. * Registers a function to be executed when the scene is ready
  34538. * @param {Function} func - the function to be executed
  34539. */
  34540. executeWhenReady(func: () => void): void;
  34541. /**
  34542. * Returns a promise that resolves when the scene is ready
  34543. * @returns A promise that resolves when the scene is ready
  34544. */
  34545. whenReadyAsync(): Promise<void>;
  34546. /** @hidden */
  34547. _checkIsReady(): void;
  34548. /**
  34549. * Gets all animatable attached to the scene
  34550. */
  34551. readonly animatables: Animatable[];
  34552. /**
  34553. * Resets the last animation time frame.
  34554. * Useful to override when animations start running when loading a scene for the first time.
  34555. */
  34556. resetLastAnimationTimeFrame(): void;
  34557. /**
  34558. * Gets the current view matrix
  34559. * @returns a Matrix
  34560. */
  34561. getViewMatrix(): Matrix;
  34562. /**
  34563. * Gets the current projection matrix
  34564. * @returns a Matrix
  34565. */
  34566. getProjectionMatrix(): Matrix;
  34567. /**
  34568. * Gets the current transform matrix
  34569. * @returns a Matrix made of View * Projection
  34570. */
  34571. getTransformMatrix(): Matrix;
  34572. /**
  34573. * Sets the current transform matrix
  34574. * @param viewL defines the View matrix to use
  34575. * @param projectionL defines the Projection matrix to use
  34576. * @param viewR defines the right View matrix to use (if provided)
  34577. * @param projectionR defines the right Projection matrix to use (if provided)
  34578. */
  34579. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34580. /**
  34581. * Gets the uniform buffer used to store scene data
  34582. * @returns a UniformBuffer
  34583. */
  34584. getSceneUniformBuffer(): UniformBuffer;
  34585. /**
  34586. * Gets an unique (relatively to the current scene) Id
  34587. * @returns an unique number for the scene
  34588. */
  34589. getUniqueId(): number;
  34590. /**
  34591. * Add a mesh to the list of scene's meshes
  34592. * @param newMesh defines the mesh to add
  34593. * @param recursive if all child meshes should also be added to the scene
  34594. */
  34595. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34596. /**
  34597. * Remove a mesh for the list of scene's meshes
  34598. * @param toRemove defines the mesh to remove
  34599. * @param recursive if all child meshes should also be removed from the scene
  34600. * @returns the index where the mesh was in the mesh list
  34601. */
  34602. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34603. /**
  34604. * Add a transform node to the list of scene's transform nodes
  34605. * @param newTransformNode defines the transform node to add
  34606. */
  34607. addTransformNode(newTransformNode: TransformNode): void;
  34608. /**
  34609. * Remove a transform node for the list of scene's transform nodes
  34610. * @param toRemove defines the transform node to remove
  34611. * @returns the index where the transform node was in the transform node list
  34612. */
  34613. removeTransformNode(toRemove: TransformNode): number;
  34614. /**
  34615. * Remove a skeleton for the list of scene's skeletons
  34616. * @param toRemove defines the skeleton to remove
  34617. * @returns the index where the skeleton was in the skeleton list
  34618. */
  34619. removeSkeleton(toRemove: Skeleton): number;
  34620. /**
  34621. * Remove a morph target for the list of scene's morph targets
  34622. * @param toRemove defines the morph target to remove
  34623. * @returns the index where the morph target was in the morph target list
  34624. */
  34625. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34626. /**
  34627. * Remove a light for the list of scene's lights
  34628. * @param toRemove defines the light to remove
  34629. * @returns the index where the light was in the light list
  34630. */
  34631. removeLight(toRemove: Light): number;
  34632. /**
  34633. * Remove a camera for the list of scene's cameras
  34634. * @param toRemove defines the camera to remove
  34635. * @returns the index where the camera was in the camera list
  34636. */
  34637. removeCamera(toRemove: Camera): number;
  34638. /**
  34639. * Remove a particle system for the list of scene's particle systems
  34640. * @param toRemove defines the particle system to remove
  34641. * @returns the index where the particle system was in the particle system list
  34642. */
  34643. removeParticleSystem(toRemove: IParticleSystem): number;
  34644. /**
  34645. * Remove a animation for the list of scene's animations
  34646. * @param toRemove defines the animation to remove
  34647. * @returns the index where the animation was in the animation list
  34648. */
  34649. removeAnimation(toRemove: Animation): number;
  34650. /**
  34651. * Will stop the animation of the given target
  34652. * @param target - the target
  34653. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34654. * @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)
  34655. */
  34656. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34657. /**
  34658. * Removes the given animation group from this scene.
  34659. * @param toRemove The animation group to remove
  34660. * @returns The index of the removed animation group
  34661. */
  34662. removeAnimationGroup(toRemove: AnimationGroup): number;
  34663. /**
  34664. * Removes the given multi-material from this scene.
  34665. * @param toRemove The multi-material to remove
  34666. * @returns The index of the removed multi-material
  34667. */
  34668. removeMultiMaterial(toRemove: MultiMaterial): number;
  34669. /**
  34670. * Removes the given material from this scene.
  34671. * @param toRemove The material to remove
  34672. * @returns The index of the removed material
  34673. */
  34674. removeMaterial(toRemove: Material): number;
  34675. /**
  34676. * Removes the given action manager from this scene.
  34677. * @param toRemove The action manager to remove
  34678. * @returns The index of the removed action manager
  34679. */
  34680. removeActionManager(toRemove: AbstractActionManager): number;
  34681. /**
  34682. * Removes the given texture from this scene.
  34683. * @param toRemove The texture to remove
  34684. * @returns The index of the removed texture
  34685. */
  34686. removeTexture(toRemove: BaseTexture): number;
  34687. /**
  34688. * Adds the given light to this scene
  34689. * @param newLight The light to add
  34690. */
  34691. addLight(newLight: Light): void;
  34692. /**
  34693. * Sorts the list list based on light priorities
  34694. */
  34695. sortLightsByPriority(): void;
  34696. /**
  34697. * Adds the given camera to this scene
  34698. * @param newCamera The camera to add
  34699. */
  34700. addCamera(newCamera: Camera): void;
  34701. /**
  34702. * Adds the given skeleton to this scene
  34703. * @param newSkeleton The skeleton to add
  34704. */
  34705. addSkeleton(newSkeleton: Skeleton): void;
  34706. /**
  34707. * Adds the given particle system to this scene
  34708. * @param newParticleSystem The particle system to add
  34709. */
  34710. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34711. /**
  34712. * Adds the given animation to this scene
  34713. * @param newAnimation The animation to add
  34714. */
  34715. addAnimation(newAnimation: Animation): void;
  34716. /**
  34717. * Adds the given animation group to this scene.
  34718. * @param newAnimationGroup The animation group to add
  34719. */
  34720. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34721. /**
  34722. * Adds the given multi-material to this scene
  34723. * @param newMultiMaterial The multi-material to add
  34724. */
  34725. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34726. /**
  34727. * Adds the given material to this scene
  34728. * @param newMaterial The material to add
  34729. */
  34730. addMaterial(newMaterial: Material): void;
  34731. /**
  34732. * Adds the given morph target to this scene
  34733. * @param newMorphTargetManager The morph target to add
  34734. */
  34735. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34736. /**
  34737. * Adds the given geometry to this scene
  34738. * @param newGeometry The geometry to add
  34739. */
  34740. addGeometry(newGeometry: Geometry): void;
  34741. /**
  34742. * Adds the given action manager to this scene
  34743. * @param newActionManager The action manager to add
  34744. */
  34745. addActionManager(newActionManager: AbstractActionManager): void;
  34746. /**
  34747. * Adds the given texture to this scene.
  34748. * @param newTexture The texture to add
  34749. */
  34750. addTexture(newTexture: BaseTexture): void;
  34751. /**
  34752. * Switch active camera
  34753. * @param newCamera defines the new active camera
  34754. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34755. */
  34756. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34757. /**
  34758. * sets the active camera of the scene using its ID
  34759. * @param id defines the camera's ID
  34760. * @return the new active camera or null if none found.
  34761. */
  34762. setActiveCameraByID(id: string): Nullable<Camera>;
  34763. /**
  34764. * sets the active camera of the scene using its name
  34765. * @param name defines the camera's name
  34766. * @returns the new active camera or null if none found.
  34767. */
  34768. setActiveCameraByName(name: string): Nullable<Camera>;
  34769. /**
  34770. * get an animation group using its name
  34771. * @param name defines the material's name
  34772. * @return the animation group or null if none found.
  34773. */
  34774. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34775. /**
  34776. * Get a material using its unique id
  34777. * @param uniqueId defines the material's unique id
  34778. * @return the material or null if none found.
  34779. */
  34780. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34781. /**
  34782. * get a material using its id
  34783. * @param id defines the material's ID
  34784. * @return the material or null if none found.
  34785. */
  34786. getMaterialByID(id: string): Nullable<Material>;
  34787. /**
  34788. * Gets a the last added material using a given id
  34789. * @param id defines the material's ID
  34790. * @return the last material with the given id or null if none found.
  34791. */
  34792. getLastMaterialByID(id: string): Nullable<Material>;
  34793. /**
  34794. * Gets a material using its name
  34795. * @param name defines the material's name
  34796. * @return the material or null if none found.
  34797. */
  34798. getMaterialByName(name: string): Nullable<Material>;
  34799. /**
  34800. * Gets a camera using its id
  34801. * @param id defines the id to look for
  34802. * @returns the camera or null if not found
  34803. */
  34804. getCameraByID(id: string): Nullable<Camera>;
  34805. /**
  34806. * Gets a camera using its unique id
  34807. * @param uniqueId defines the unique id to look for
  34808. * @returns the camera or null if not found
  34809. */
  34810. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34811. /**
  34812. * Gets a camera using its name
  34813. * @param name defines the camera's name
  34814. * @return the camera or null if none found.
  34815. */
  34816. getCameraByName(name: string): Nullable<Camera>;
  34817. /**
  34818. * Gets a bone using its id
  34819. * @param id defines the bone's id
  34820. * @return the bone or null if not found
  34821. */
  34822. getBoneByID(id: string): Nullable<Bone>;
  34823. /**
  34824. * Gets a bone using its id
  34825. * @param name defines the bone's name
  34826. * @return the bone or null if not found
  34827. */
  34828. getBoneByName(name: string): Nullable<Bone>;
  34829. /**
  34830. * Gets a light node using its name
  34831. * @param name defines the the light's name
  34832. * @return the light or null if none found.
  34833. */
  34834. getLightByName(name: string): Nullable<Light>;
  34835. /**
  34836. * Gets a light node using its id
  34837. * @param id defines the light's id
  34838. * @return the light or null if none found.
  34839. */
  34840. getLightByID(id: string): Nullable<Light>;
  34841. /**
  34842. * Gets a light node using its scene-generated unique ID
  34843. * @param uniqueId defines the light's unique id
  34844. * @return the light or null if none found.
  34845. */
  34846. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34847. /**
  34848. * Gets a particle system by id
  34849. * @param id defines the particle system id
  34850. * @return the corresponding system or null if none found
  34851. */
  34852. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34853. /**
  34854. * Gets a geometry using its ID
  34855. * @param id defines the geometry's id
  34856. * @return the geometry or null if none found.
  34857. */
  34858. getGeometryByID(id: string): Nullable<Geometry>;
  34859. private _getGeometryByUniqueID;
  34860. /**
  34861. * Add a new geometry to this scene
  34862. * @param geometry defines the geometry to be added to the scene.
  34863. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34864. * @return a boolean defining if the geometry was added or not
  34865. */
  34866. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34867. /**
  34868. * Removes an existing geometry
  34869. * @param geometry defines the geometry to be removed from the scene
  34870. * @return a boolean defining if the geometry was removed or not
  34871. */
  34872. removeGeometry(geometry: Geometry): boolean;
  34873. /**
  34874. * Gets the list of geometries attached to the scene
  34875. * @returns an array of Geometry
  34876. */
  34877. getGeometries(): Geometry[];
  34878. /**
  34879. * Gets the first added mesh found of a given ID
  34880. * @param id defines the id to search for
  34881. * @return the mesh found or null if not found at all
  34882. */
  34883. getMeshByID(id: string): Nullable<AbstractMesh>;
  34884. /**
  34885. * Gets a list of meshes using their id
  34886. * @param id defines the id to search for
  34887. * @returns a list of meshes
  34888. */
  34889. getMeshesByID(id: string): Array<AbstractMesh>;
  34890. /**
  34891. * Gets the first added transform node found of a given ID
  34892. * @param id defines the id to search for
  34893. * @return the found transform node or null if not found at all.
  34894. */
  34895. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34896. /**
  34897. * Gets a transform node with its auto-generated unique id
  34898. * @param uniqueId efines the unique id to search for
  34899. * @return the found transform node or null if not found at all.
  34900. */
  34901. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34902. /**
  34903. * Gets a list of transform nodes using their id
  34904. * @param id defines the id to search for
  34905. * @returns a list of transform nodes
  34906. */
  34907. getTransformNodesByID(id: string): Array<TransformNode>;
  34908. /**
  34909. * Gets a mesh with its auto-generated unique id
  34910. * @param uniqueId defines the unique id to search for
  34911. * @return the found mesh or null if not found at all.
  34912. */
  34913. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34914. /**
  34915. * Gets a the last added mesh using a given id
  34916. * @param id defines the id to search for
  34917. * @return the found mesh or null if not found at all.
  34918. */
  34919. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34920. /**
  34921. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34922. * @param id defines the id to search for
  34923. * @return the found node or null if not found at all
  34924. */
  34925. getLastEntryByID(id: string): Nullable<Node>;
  34926. /**
  34927. * Gets a node (Mesh, Camera, Light) using a given id
  34928. * @param id defines the id to search for
  34929. * @return the found node or null if not found at all
  34930. */
  34931. getNodeByID(id: string): Nullable<Node>;
  34932. /**
  34933. * Gets a node (Mesh, Camera, Light) using a given name
  34934. * @param name defines the name to search for
  34935. * @return the found node or null if not found at all.
  34936. */
  34937. getNodeByName(name: string): Nullable<Node>;
  34938. /**
  34939. * Gets a mesh using a given name
  34940. * @param name defines the name to search for
  34941. * @return the found mesh or null if not found at all.
  34942. */
  34943. getMeshByName(name: string): Nullable<AbstractMesh>;
  34944. /**
  34945. * Gets a transform node using a given name
  34946. * @param name defines the name to search for
  34947. * @return the found transform node or null if not found at all.
  34948. */
  34949. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34950. /**
  34951. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34952. * @param id defines the id to search for
  34953. * @return the found skeleton or null if not found at all.
  34954. */
  34955. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34956. /**
  34957. * Gets a skeleton using a given auto generated unique id
  34958. * @param uniqueId defines the unique id to search for
  34959. * @return the found skeleton or null if not found at all.
  34960. */
  34961. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34962. /**
  34963. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34964. * @param id defines the id to search for
  34965. * @return the found skeleton or null if not found at all.
  34966. */
  34967. getSkeletonById(id: string): Nullable<Skeleton>;
  34968. /**
  34969. * Gets a skeleton using a given name
  34970. * @param name defines the name to search for
  34971. * @return the found skeleton or null if not found at all.
  34972. */
  34973. getSkeletonByName(name: string): Nullable<Skeleton>;
  34974. /**
  34975. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34976. * @param id defines the id to search for
  34977. * @return the found morph target manager or null if not found at all.
  34978. */
  34979. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34980. /**
  34981. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34982. * @param id defines the id to search for
  34983. * @return the found morph target or null if not found at all.
  34984. */
  34985. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34986. /**
  34987. * Gets a boolean indicating if the given mesh is active
  34988. * @param mesh defines the mesh to look for
  34989. * @returns true if the mesh is in the active list
  34990. */
  34991. isActiveMesh(mesh: AbstractMesh): boolean;
  34992. /**
  34993. * Return a unique id as a string which can serve as an identifier for the scene
  34994. */
  34995. readonly uid: string;
  34996. /**
  34997. * Add an externaly attached data from its key.
  34998. * This method call will fail and return false, if such key already exists.
  34999. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35000. * @param key the unique key that identifies the data
  35001. * @param data the data object to associate to the key for this Engine instance
  35002. * @return true if no such key were already present and the data was added successfully, false otherwise
  35003. */
  35004. addExternalData<T>(key: string, data: T): boolean;
  35005. /**
  35006. * Get an externaly attached data from its key
  35007. * @param key the unique key that identifies the data
  35008. * @return the associated data, if present (can be null), or undefined if not present
  35009. */
  35010. getExternalData<T>(key: string): Nullable<T>;
  35011. /**
  35012. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35013. * @param key the unique key that identifies the data
  35014. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35015. * @return the associated data, can be null if the factory returned null.
  35016. */
  35017. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35018. /**
  35019. * Remove an externaly attached data from the Engine instance
  35020. * @param key the unique key that identifies the data
  35021. * @return true if the data was successfully removed, false if it doesn't exist
  35022. */
  35023. removeExternalData(key: string): boolean;
  35024. private _evaluateSubMesh;
  35025. /**
  35026. * Clear the processed materials smart array preventing retention point in material dispose.
  35027. */
  35028. freeProcessedMaterials(): void;
  35029. private _preventFreeActiveMeshesAndRenderingGroups;
  35030. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35031. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35032. * when disposing several meshes in a row or a hierarchy of meshes.
  35033. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35034. */
  35035. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35036. /**
  35037. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35038. */
  35039. freeActiveMeshes(): void;
  35040. /**
  35041. * Clear the info related to rendering groups preventing retention points during dispose.
  35042. */
  35043. freeRenderingGroups(): void;
  35044. /** @hidden */
  35045. _isInIntermediateRendering(): boolean;
  35046. /**
  35047. * Lambda returning the list of potentially active meshes.
  35048. */
  35049. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35050. /**
  35051. * Lambda returning the list of potentially active sub meshes.
  35052. */
  35053. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35054. /**
  35055. * Lambda returning the list of potentially intersecting sub meshes.
  35056. */
  35057. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35058. /**
  35059. * Lambda returning the list of potentially colliding sub meshes.
  35060. */
  35061. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35062. private _activeMeshesFrozen;
  35063. /**
  35064. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35065. * @returns the current scene
  35066. */
  35067. freezeActiveMeshes(): Scene;
  35068. /**
  35069. * Use this function to restart evaluating active meshes on every frame
  35070. * @returns the current scene
  35071. */
  35072. unfreezeActiveMeshes(): Scene;
  35073. private _evaluateActiveMeshes;
  35074. private _activeMesh;
  35075. /**
  35076. * Update the transform matrix to update from the current active camera
  35077. * @param force defines a boolean used to force the update even if cache is up to date
  35078. */
  35079. updateTransformMatrix(force?: boolean): void;
  35080. private _bindFrameBuffer;
  35081. /** @hidden */
  35082. _allowPostProcessClearColor: boolean;
  35083. /** @hidden */
  35084. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35085. private _processSubCameras;
  35086. private _checkIntersections;
  35087. /** @hidden */
  35088. _advancePhysicsEngineStep(step: number): void;
  35089. /**
  35090. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35091. */
  35092. getDeterministicFrameTime: () => number;
  35093. /** @hidden */
  35094. _animate(): void;
  35095. /** Execute all animations (for a frame) */
  35096. animate(): void;
  35097. /**
  35098. * Render the scene
  35099. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35100. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35101. */
  35102. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35103. /**
  35104. * Freeze all materials
  35105. * A frozen material will not be updatable but should be faster to render
  35106. */
  35107. freezeMaterials(): void;
  35108. /**
  35109. * Unfreeze all materials
  35110. * A frozen material will not be updatable but should be faster to render
  35111. */
  35112. unfreezeMaterials(): void;
  35113. /**
  35114. * Releases all held ressources
  35115. */
  35116. dispose(): void;
  35117. /**
  35118. * Gets if the scene is already disposed
  35119. */
  35120. readonly isDisposed: boolean;
  35121. /**
  35122. * Call this function to reduce memory footprint of the scene.
  35123. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35124. */
  35125. clearCachedVertexData(): void;
  35126. /**
  35127. * This function will remove the local cached buffer data from texture.
  35128. * It will save memory but will prevent the texture from being rebuilt
  35129. */
  35130. cleanCachedTextureBuffer(): void;
  35131. /**
  35132. * Get the world extend vectors with an optional filter
  35133. *
  35134. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35135. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35136. */
  35137. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35138. min: Vector3;
  35139. max: Vector3;
  35140. };
  35141. /**
  35142. * Creates a ray that can be used to pick in the scene
  35143. * @param x defines the x coordinate of the origin (on-screen)
  35144. * @param y defines the y coordinate of the origin (on-screen)
  35145. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35146. * @param camera defines the camera to use for the picking
  35147. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35148. * @returns a Ray
  35149. */
  35150. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35151. /**
  35152. * Creates a ray that can be used to pick in the scene
  35153. * @param x defines the x coordinate of the origin (on-screen)
  35154. * @param y defines the y coordinate of the origin (on-screen)
  35155. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35156. * @param result defines the ray where to store the picking ray
  35157. * @param camera defines the camera to use for the picking
  35158. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35159. * @returns the current scene
  35160. */
  35161. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35162. /**
  35163. * Creates a ray that can be used to pick in the scene
  35164. * @param x defines the x coordinate of the origin (on-screen)
  35165. * @param y defines the y coordinate of the origin (on-screen)
  35166. * @param camera defines the camera to use for the picking
  35167. * @returns a Ray
  35168. */
  35169. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35170. /**
  35171. * Creates a ray that can be used to pick in the scene
  35172. * @param x defines the x coordinate of the origin (on-screen)
  35173. * @param y defines the y coordinate of the origin (on-screen)
  35174. * @param result defines the ray where to store the picking ray
  35175. * @param camera defines the camera to use for the picking
  35176. * @returns the current scene
  35177. */
  35178. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35179. /** Launch a ray to try to pick a mesh in the scene
  35180. * @param x position on screen
  35181. * @param y position on screen
  35182. * @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
  35183. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35184. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35185. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35186. * @returns a PickingInfo
  35187. */
  35188. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35189. /** Use the given ray to pick a mesh in the scene
  35190. * @param ray The ray to use to pick meshes
  35191. * @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
  35192. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35193. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35194. * @returns a PickingInfo
  35195. */
  35196. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35197. /**
  35198. * Launch a ray to try to pick a mesh in the scene
  35199. * @param x X position on screen
  35200. * @param y Y position on screen
  35201. * @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
  35202. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35203. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35204. * @returns an array of PickingInfo
  35205. */
  35206. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35207. /**
  35208. * Launch a ray to try to pick a mesh in the scene
  35209. * @param ray Ray to use
  35210. * @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
  35211. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35212. * @returns an array of PickingInfo
  35213. */
  35214. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35215. /**
  35216. * Force the value of meshUnderPointer
  35217. * @param mesh defines the mesh to use
  35218. */
  35219. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35220. /**
  35221. * Gets the mesh under the pointer
  35222. * @returns a Mesh or null if no mesh is under the pointer
  35223. */
  35224. getPointerOverMesh(): Nullable<AbstractMesh>;
  35225. /** @hidden */
  35226. _rebuildGeometries(): void;
  35227. /** @hidden */
  35228. _rebuildTextures(): void;
  35229. private _getByTags;
  35230. /**
  35231. * Get a list of meshes by tags
  35232. * @param tagsQuery defines the tags query to use
  35233. * @param forEach defines a predicate used to filter results
  35234. * @returns an array of Mesh
  35235. */
  35236. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35237. /**
  35238. * Get a list of cameras by tags
  35239. * @param tagsQuery defines the tags query to use
  35240. * @param forEach defines a predicate used to filter results
  35241. * @returns an array of Camera
  35242. */
  35243. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35244. /**
  35245. * Get a list of lights by tags
  35246. * @param tagsQuery defines the tags query to use
  35247. * @param forEach defines a predicate used to filter results
  35248. * @returns an array of Light
  35249. */
  35250. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35251. /**
  35252. * Get a list of materials by tags
  35253. * @param tagsQuery defines the tags query to use
  35254. * @param forEach defines a predicate used to filter results
  35255. * @returns an array of Material
  35256. */
  35257. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35258. /**
  35259. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35260. * This allowed control for front to back rendering or reversly depending of the special needs.
  35261. *
  35262. * @param renderingGroupId The rendering group id corresponding to its index
  35263. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35264. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35265. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35266. */
  35267. 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;
  35268. /**
  35269. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35270. *
  35271. * @param renderingGroupId The rendering group id corresponding to its index
  35272. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35273. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35274. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35275. */
  35276. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35277. /**
  35278. * Gets the current auto clear configuration for one rendering group of the rendering
  35279. * manager.
  35280. * @param index the rendering group index to get the information for
  35281. * @returns The auto clear setup for the requested rendering group
  35282. */
  35283. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35284. private _blockMaterialDirtyMechanism;
  35285. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35286. blockMaterialDirtyMechanism: boolean;
  35287. /**
  35288. * Will flag all materials as dirty to trigger new shader compilation
  35289. * @param flag defines the flag used to specify which material part must be marked as dirty
  35290. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35291. */
  35292. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35293. /** @hidden */
  35294. _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;
  35295. /** @hidden */
  35296. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35297. }
  35298. }
  35299. declare module "babylonjs/assetContainer" {
  35300. import { AbstractScene } from "babylonjs/abstractScene";
  35301. import { Scene } from "babylonjs/scene";
  35302. import { Mesh } from "babylonjs/Meshes/mesh";
  35303. /**
  35304. * Set of assets to keep when moving a scene into an asset container.
  35305. */
  35306. export class KeepAssets extends AbstractScene {
  35307. }
  35308. /**
  35309. * Container with a set of assets that can be added or removed from a scene.
  35310. */
  35311. export class AssetContainer extends AbstractScene {
  35312. /**
  35313. * The scene the AssetContainer belongs to.
  35314. */
  35315. scene: Scene;
  35316. /**
  35317. * Instantiates an AssetContainer.
  35318. * @param scene The scene the AssetContainer belongs to.
  35319. */
  35320. constructor(scene: Scene);
  35321. /**
  35322. * Adds all the assets from the container to the scene.
  35323. */
  35324. addAllToScene(): void;
  35325. /**
  35326. * Removes all the assets in the container from the scene
  35327. */
  35328. removeAllFromScene(): void;
  35329. /**
  35330. * Disposes all the assets in the container
  35331. */
  35332. dispose(): void;
  35333. private _moveAssets;
  35334. /**
  35335. * Removes all the assets contained in the scene and adds them to the container.
  35336. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35337. */
  35338. moveAllFromScene(keepAssets?: KeepAssets): void;
  35339. /**
  35340. * 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.
  35341. * @returns the root mesh
  35342. */
  35343. createRootMesh(): Mesh;
  35344. }
  35345. }
  35346. declare module "babylonjs/abstractScene" {
  35347. import { Scene } from "babylonjs/scene";
  35348. import { Nullable } from "babylonjs/types";
  35349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35351. import { Geometry } from "babylonjs/Meshes/geometry";
  35352. import { Skeleton } from "babylonjs/Bones/skeleton";
  35353. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35354. import { AssetContainer } from "babylonjs/assetContainer";
  35355. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35356. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35357. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35358. import { Material } from "babylonjs/Materials/material";
  35359. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35360. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35361. import { Camera } from "babylonjs/Cameras/camera";
  35362. import { Light } from "babylonjs/Lights/light";
  35363. import { Node } from "babylonjs/node";
  35364. import { Animation } from "babylonjs/Animations/animation";
  35365. /**
  35366. * Defines how the parser contract is defined.
  35367. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35368. */
  35369. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35370. /**
  35371. * Defines how the individual parser contract is defined.
  35372. * These parser can parse an individual asset
  35373. */
  35374. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35375. /**
  35376. * Base class of the scene acting as a container for the different elements composing a scene.
  35377. * This class is dynamically extended by the different components of the scene increasing
  35378. * flexibility and reducing coupling
  35379. */
  35380. export abstract class AbstractScene {
  35381. /**
  35382. * Stores the list of available parsers in the application.
  35383. */
  35384. private static _BabylonFileParsers;
  35385. /**
  35386. * Stores the list of available individual parsers in the application.
  35387. */
  35388. private static _IndividualBabylonFileParsers;
  35389. /**
  35390. * Adds a parser in the list of available ones
  35391. * @param name Defines the name of the parser
  35392. * @param parser Defines the parser to add
  35393. */
  35394. static AddParser(name: string, parser: BabylonFileParser): void;
  35395. /**
  35396. * Gets a general parser from the list of avaialble ones
  35397. * @param name Defines the name of the parser
  35398. * @returns the requested parser or null
  35399. */
  35400. static GetParser(name: string): Nullable<BabylonFileParser>;
  35401. /**
  35402. * Adds n individual parser in the list of available ones
  35403. * @param name Defines the name of the parser
  35404. * @param parser Defines the parser to add
  35405. */
  35406. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35407. /**
  35408. * Gets an individual parser from the list of avaialble ones
  35409. * @param name Defines the name of the parser
  35410. * @returns the requested parser or null
  35411. */
  35412. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35413. /**
  35414. * Parser json data and populate both a scene and its associated container object
  35415. * @param jsonData Defines the data to parse
  35416. * @param scene Defines the scene to parse the data for
  35417. * @param container Defines the container attached to the parsing sequence
  35418. * @param rootUrl Defines the root url of the data
  35419. */
  35420. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35421. /**
  35422. * Gets the list of root nodes (ie. nodes with no parent)
  35423. */
  35424. rootNodes: Node[];
  35425. /** All of the cameras added to this scene
  35426. * @see http://doc.babylonjs.com/babylon101/cameras
  35427. */
  35428. cameras: Camera[];
  35429. /**
  35430. * All of the lights added to this scene
  35431. * @see http://doc.babylonjs.com/babylon101/lights
  35432. */
  35433. lights: Light[];
  35434. /**
  35435. * All of the (abstract) meshes added to this scene
  35436. */
  35437. meshes: AbstractMesh[];
  35438. /**
  35439. * The list of skeletons added to the scene
  35440. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35441. */
  35442. skeletons: Skeleton[];
  35443. /**
  35444. * All of the particle systems added to this scene
  35445. * @see http://doc.babylonjs.com/babylon101/particles
  35446. */
  35447. particleSystems: IParticleSystem[];
  35448. /**
  35449. * Gets a list of Animations associated with the scene
  35450. */
  35451. animations: Animation[];
  35452. /**
  35453. * All of the animation groups added to this scene
  35454. * @see http://doc.babylonjs.com/how_to/group
  35455. */
  35456. animationGroups: AnimationGroup[];
  35457. /**
  35458. * All of the multi-materials added to this scene
  35459. * @see http://doc.babylonjs.com/how_to/multi_materials
  35460. */
  35461. multiMaterials: MultiMaterial[];
  35462. /**
  35463. * All of the materials added to this scene
  35464. * In the context of a Scene, it is not supposed to be modified manually.
  35465. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35466. * Note also that the order of the Material wihin the array is not significant and might change.
  35467. * @see http://doc.babylonjs.com/babylon101/materials
  35468. */
  35469. materials: Material[];
  35470. /**
  35471. * The list of morph target managers added to the scene
  35472. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35473. */
  35474. morphTargetManagers: MorphTargetManager[];
  35475. /**
  35476. * The list of geometries used in the scene.
  35477. */
  35478. geometries: Geometry[];
  35479. /**
  35480. * All of the tranform nodes added to this scene
  35481. * In the context of a Scene, it is not supposed to be modified manually.
  35482. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35483. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35484. * @see http://doc.babylonjs.com/how_to/transformnode
  35485. */
  35486. transformNodes: TransformNode[];
  35487. /**
  35488. * ActionManagers available on the scene.
  35489. */
  35490. actionManagers: AbstractActionManager[];
  35491. /**
  35492. * Textures to keep.
  35493. */
  35494. textures: BaseTexture[];
  35495. /**
  35496. * Environment texture for the scene
  35497. */
  35498. environmentTexture: Nullable<BaseTexture>;
  35499. }
  35500. }
  35501. declare module "babylonjs/Audio/sound" {
  35502. import { Observable } from "babylonjs/Misc/observable";
  35503. import { Vector3 } from "babylonjs/Maths/math.vector";
  35504. import { Nullable } from "babylonjs/types";
  35505. import { Scene } from "babylonjs/scene";
  35506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35507. /**
  35508. * Interface used to define options for Sound class
  35509. */
  35510. export interface ISoundOptions {
  35511. /**
  35512. * Does the sound autoplay once loaded.
  35513. */
  35514. autoplay?: boolean;
  35515. /**
  35516. * Does the sound loop after it finishes playing once.
  35517. */
  35518. loop?: boolean;
  35519. /**
  35520. * Sound's volume
  35521. */
  35522. volume?: number;
  35523. /**
  35524. * Is it a spatial sound?
  35525. */
  35526. spatialSound?: boolean;
  35527. /**
  35528. * Maximum distance to hear that sound
  35529. */
  35530. maxDistance?: number;
  35531. /**
  35532. * Uses user defined attenuation function
  35533. */
  35534. useCustomAttenuation?: boolean;
  35535. /**
  35536. * Define the roll off factor of spatial sounds.
  35537. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35538. */
  35539. rolloffFactor?: number;
  35540. /**
  35541. * Define the reference distance the sound should be heard perfectly.
  35542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35543. */
  35544. refDistance?: number;
  35545. /**
  35546. * Define the distance attenuation model the sound will follow.
  35547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35548. */
  35549. distanceModel?: string;
  35550. /**
  35551. * Defines the playback speed (1 by default)
  35552. */
  35553. playbackRate?: number;
  35554. /**
  35555. * Defines if the sound is from a streaming source
  35556. */
  35557. streaming?: boolean;
  35558. /**
  35559. * Defines an optional length (in seconds) inside the sound file
  35560. */
  35561. length?: number;
  35562. /**
  35563. * Defines an optional offset (in seconds) inside the sound file
  35564. */
  35565. offset?: number;
  35566. /**
  35567. * If true, URLs will not be required to state the audio file codec to use.
  35568. */
  35569. skipCodecCheck?: boolean;
  35570. }
  35571. /**
  35572. * Defines a sound that can be played in the application.
  35573. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35575. */
  35576. export class Sound {
  35577. /**
  35578. * The name of the sound in the scene.
  35579. */
  35580. name: string;
  35581. /**
  35582. * Does the sound autoplay once loaded.
  35583. */
  35584. autoplay: boolean;
  35585. /**
  35586. * Does the sound loop after it finishes playing once.
  35587. */
  35588. loop: boolean;
  35589. /**
  35590. * Does the sound use a custom attenuation curve to simulate the falloff
  35591. * happening when the source gets further away from the camera.
  35592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35593. */
  35594. useCustomAttenuation: boolean;
  35595. /**
  35596. * The sound track id this sound belongs to.
  35597. */
  35598. soundTrackId: number;
  35599. /**
  35600. * Is this sound currently played.
  35601. */
  35602. isPlaying: boolean;
  35603. /**
  35604. * Is this sound currently paused.
  35605. */
  35606. isPaused: boolean;
  35607. /**
  35608. * Does this sound enables spatial sound.
  35609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35610. */
  35611. spatialSound: boolean;
  35612. /**
  35613. * Define the reference distance the sound should be heard perfectly.
  35614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35615. */
  35616. refDistance: number;
  35617. /**
  35618. * Define the roll off factor of spatial sounds.
  35619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35620. */
  35621. rolloffFactor: number;
  35622. /**
  35623. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35625. */
  35626. maxDistance: number;
  35627. /**
  35628. * Define the distance attenuation model the sound will follow.
  35629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35630. */
  35631. distanceModel: string;
  35632. /**
  35633. * @hidden
  35634. * Back Compat
  35635. **/
  35636. onended: () => any;
  35637. /**
  35638. * Observable event when the current playing sound finishes.
  35639. */
  35640. onEndedObservable: Observable<Sound>;
  35641. private _panningModel;
  35642. private _playbackRate;
  35643. private _streaming;
  35644. private _startTime;
  35645. private _startOffset;
  35646. private _position;
  35647. /** @hidden */
  35648. _positionInEmitterSpace: boolean;
  35649. private _localDirection;
  35650. private _volume;
  35651. private _isReadyToPlay;
  35652. private _isDirectional;
  35653. private _readyToPlayCallback;
  35654. private _audioBuffer;
  35655. private _soundSource;
  35656. private _streamingSource;
  35657. private _soundPanner;
  35658. private _soundGain;
  35659. private _inputAudioNode;
  35660. private _outputAudioNode;
  35661. private _coneInnerAngle;
  35662. private _coneOuterAngle;
  35663. private _coneOuterGain;
  35664. private _scene;
  35665. private _connectedTransformNode;
  35666. private _customAttenuationFunction;
  35667. private _registerFunc;
  35668. private _isOutputConnected;
  35669. private _htmlAudioElement;
  35670. private _urlType;
  35671. private _length?;
  35672. private _offset?;
  35673. /** @hidden */
  35674. static _SceneComponentInitialization: (scene: Scene) => void;
  35675. /**
  35676. * Create a sound and attach it to a scene
  35677. * @param name Name of your sound
  35678. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35679. * @param scene defines the scene the sound belongs to
  35680. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35681. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35682. */
  35683. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35684. /**
  35685. * Release the sound and its associated resources
  35686. */
  35687. dispose(): void;
  35688. /**
  35689. * Gets if the sounds is ready to be played or not.
  35690. * @returns true if ready, otherwise false
  35691. */
  35692. isReady(): boolean;
  35693. private _soundLoaded;
  35694. /**
  35695. * Sets the data of the sound from an audiobuffer
  35696. * @param audioBuffer The audioBuffer containing the data
  35697. */
  35698. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35699. /**
  35700. * Updates the current sounds options such as maxdistance, loop...
  35701. * @param options A JSON object containing values named as the object properties
  35702. */
  35703. updateOptions(options: ISoundOptions): void;
  35704. private _createSpatialParameters;
  35705. private _updateSpatialParameters;
  35706. /**
  35707. * Switch the panning model to HRTF:
  35708. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35710. */
  35711. switchPanningModelToHRTF(): void;
  35712. /**
  35713. * Switch the panning model to Equal Power:
  35714. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35716. */
  35717. switchPanningModelToEqualPower(): void;
  35718. private _switchPanningModel;
  35719. /**
  35720. * Connect this sound to a sound track audio node like gain...
  35721. * @param soundTrackAudioNode the sound track audio node to connect to
  35722. */
  35723. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35724. /**
  35725. * Transform this sound into a directional source
  35726. * @param coneInnerAngle Size of the inner cone in degree
  35727. * @param coneOuterAngle Size of the outer cone in degree
  35728. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35729. */
  35730. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35731. /**
  35732. * Gets or sets the inner angle for the directional cone.
  35733. */
  35734. /**
  35735. * Gets or sets the inner angle for the directional cone.
  35736. */
  35737. directionalConeInnerAngle: number;
  35738. /**
  35739. * Gets or sets the outer angle for the directional cone.
  35740. */
  35741. /**
  35742. * Gets or sets the outer angle for the directional cone.
  35743. */
  35744. directionalConeOuterAngle: number;
  35745. /**
  35746. * Sets the position of the emitter if spatial sound is enabled
  35747. * @param newPosition Defines the new posisiton
  35748. */
  35749. setPosition(newPosition: Vector3): void;
  35750. /**
  35751. * Sets the local direction of the emitter if spatial sound is enabled
  35752. * @param newLocalDirection Defines the new local direction
  35753. */
  35754. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35755. private _updateDirection;
  35756. /** @hidden */
  35757. updateDistanceFromListener(): void;
  35758. /**
  35759. * Sets a new custom attenuation function for the sound.
  35760. * @param callback Defines the function used for the attenuation
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35762. */
  35763. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35764. /**
  35765. * Play the sound
  35766. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35767. * @param offset (optional) Start the sound at a specific time in seconds
  35768. * @param length (optional) Sound duration (in seconds)
  35769. */
  35770. play(time?: number, offset?: number, length?: number): void;
  35771. private _onended;
  35772. /**
  35773. * Stop the sound
  35774. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35775. */
  35776. stop(time?: number): void;
  35777. /**
  35778. * Put the sound in pause
  35779. */
  35780. pause(): void;
  35781. /**
  35782. * Sets a dedicated volume for this sounds
  35783. * @param newVolume Define the new volume of the sound
  35784. * @param time Define time for gradual change to new volume
  35785. */
  35786. setVolume(newVolume: number, time?: number): void;
  35787. /**
  35788. * Set the sound play back rate
  35789. * @param newPlaybackRate Define the playback rate the sound should be played at
  35790. */
  35791. setPlaybackRate(newPlaybackRate: number): void;
  35792. /**
  35793. * Gets the volume of the sound.
  35794. * @returns the volume of the sound
  35795. */
  35796. getVolume(): number;
  35797. /**
  35798. * Attach the sound to a dedicated mesh
  35799. * @param transformNode The transform node to connect the sound with
  35800. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35801. */
  35802. attachToMesh(transformNode: TransformNode): void;
  35803. /**
  35804. * Detach the sound from the previously attached mesh
  35805. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35806. */
  35807. detachFromMesh(): void;
  35808. private _onRegisterAfterWorldMatrixUpdate;
  35809. /**
  35810. * Clone the current sound in the scene.
  35811. * @returns the new sound clone
  35812. */
  35813. clone(): Nullable<Sound>;
  35814. /**
  35815. * Gets the current underlying audio buffer containing the data
  35816. * @returns the audio buffer
  35817. */
  35818. getAudioBuffer(): Nullable<AudioBuffer>;
  35819. /**
  35820. * Serializes the Sound in a JSON representation
  35821. * @returns the JSON representation of the sound
  35822. */
  35823. serialize(): any;
  35824. /**
  35825. * Parse a JSON representation of a sound to innstantiate in a given scene
  35826. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35827. * @param scene Define the scene the new parsed sound should be created in
  35828. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35829. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35830. * @returns the newly parsed sound
  35831. */
  35832. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35833. }
  35834. }
  35835. declare module "babylonjs/Actions/directAudioActions" {
  35836. import { Action } from "babylonjs/Actions/action";
  35837. import { Condition } from "babylonjs/Actions/condition";
  35838. import { Sound } from "babylonjs/Audio/sound";
  35839. /**
  35840. * This defines an action helpful to play a defined sound on a triggered action.
  35841. */
  35842. export class PlaySoundAction extends Action {
  35843. private _sound;
  35844. /**
  35845. * Instantiate the action
  35846. * @param triggerOptions defines the trigger options
  35847. * @param sound defines the sound to play
  35848. * @param condition defines the trigger related conditions
  35849. */
  35850. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35851. /** @hidden */
  35852. _prepare(): void;
  35853. /**
  35854. * Execute the action and play the sound.
  35855. */
  35856. execute(): void;
  35857. /**
  35858. * Serializes the actions and its related information.
  35859. * @param parent defines the object to serialize in
  35860. * @returns the serialized object
  35861. */
  35862. serialize(parent: any): any;
  35863. }
  35864. /**
  35865. * This defines an action helpful to stop a defined sound on a triggered action.
  35866. */
  35867. export class StopSoundAction extends Action {
  35868. private _sound;
  35869. /**
  35870. * Instantiate the action
  35871. * @param triggerOptions defines the trigger options
  35872. * @param sound defines the sound to stop
  35873. * @param condition defines the trigger related conditions
  35874. */
  35875. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35876. /** @hidden */
  35877. _prepare(): void;
  35878. /**
  35879. * Execute the action and stop the sound.
  35880. */
  35881. execute(): void;
  35882. /**
  35883. * Serializes the actions and its related information.
  35884. * @param parent defines the object to serialize in
  35885. * @returns the serialized object
  35886. */
  35887. serialize(parent: any): any;
  35888. }
  35889. }
  35890. declare module "babylonjs/Actions/interpolateValueAction" {
  35891. import { Action } from "babylonjs/Actions/action";
  35892. import { Condition } from "babylonjs/Actions/condition";
  35893. import { Observable } from "babylonjs/Misc/observable";
  35894. /**
  35895. * This defines an action responsible to change the value of a property
  35896. * by interpolating between its current value and the newly set one once triggered.
  35897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35898. */
  35899. export class InterpolateValueAction extends Action {
  35900. /**
  35901. * Defines the path of the property where the value should be interpolated
  35902. */
  35903. propertyPath: string;
  35904. /**
  35905. * Defines the target value at the end of the interpolation.
  35906. */
  35907. value: any;
  35908. /**
  35909. * Defines the time it will take for the property to interpolate to the value.
  35910. */
  35911. duration: number;
  35912. /**
  35913. * Defines if the other scene animations should be stopped when the action has been triggered
  35914. */
  35915. stopOtherAnimations?: boolean;
  35916. /**
  35917. * Defines a callback raised once the interpolation animation has been done.
  35918. */
  35919. onInterpolationDone?: () => void;
  35920. /**
  35921. * Observable triggered once the interpolation animation has been done.
  35922. */
  35923. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35924. private _target;
  35925. private _effectiveTarget;
  35926. private _property;
  35927. /**
  35928. * Instantiate the action
  35929. * @param triggerOptions defines the trigger options
  35930. * @param target defines the object containing the value to interpolate
  35931. * @param propertyPath defines the path to the property in the target object
  35932. * @param value defines the target value at the end of the interpolation
  35933. * @param duration deines the time it will take for the property to interpolate to the value.
  35934. * @param condition defines the trigger related conditions
  35935. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35936. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35937. */
  35938. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35939. /** @hidden */
  35940. _prepare(): void;
  35941. /**
  35942. * Execute the action starts the value interpolation.
  35943. */
  35944. execute(): void;
  35945. /**
  35946. * Serializes the actions and its related information.
  35947. * @param parent defines the object to serialize in
  35948. * @returns the serialized object
  35949. */
  35950. serialize(parent: any): any;
  35951. }
  35952. }
  35953. declare module "babylonjs/Actions/index" {
  35954. export * from "babylonjs/Actions/action";
  35955. export * from "babylonjs/Actions/actionEvent";
  35956. export * from "babylonjs/Actions/actionManager";
  35957. export * from "babylonjs/Actions/condition";
  35958. export * from "babylonjs/Actions/directActions";
  35959. export * from "babylonjs/Actions/directAudioActions";
  35960. export * from "babylonjs/Actions/interpolateValueAction";
  35961. }
  35962. declare module "babylonjs/Animations/index" {
  35963. export * from "babylonjs/Animations/animatable";
  35964. export * from "babylonjs/Animations/animation";
  35965. export * from "babylonjs/Animations/animationGroup";
  35966. export * from "babylonjs/Animations/animationPropertiesOverride";
  35967. export * from "babylonjs/Animations/easing";
  35968. export * from "babylonjs/Animations/runtimeAnimation";
  35969. export * from "babylonjs/Animations/animationEvent";
  35970. export * from "babylonjs/Animations/animationGroup";
  35971. export * from "babylonjs/Animations/animationKey";
  35972. export * from "babylonjs/Animations/animationRange";
  35973. export * from "babylonjs/Animations/animatable.interface";
  35974. }
  35975. declare module "babylonjs/Audio/soundTrack" {
  35976. import { Sound } from "babylonjs/Audio/sound";
  35977. import { Analyser } from "babylonjs/Audio/analyser";
  35978. import { Scene } from "babylonjs/scene";
  35979. /**
  35980. * Options allowed during the creation of a sound track.
  35981. */
  35982. export interface ISoundTrackOptions {
  35983. /**
  35984. * The volume the sound track should take during creation
  35985. */
  35986. volume?: number;
  35987. /**
  35988. * Define if the sound track is the main sound track of the scene
  35989. */
  35990. mainTrack?: boolean;
  35991. }
  35992. /**
  35993. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35994. * It will be also used in a future release to apply effects on a specific track.
  35995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35996. */
  35997. export class SoundTrack {
  35998. /**
  35999. * The unique identifier of the sound track in the scene.
  36000. */
  36001. id: number;
  36002. /**
  36003. * The list of sounds included in the sound track.
  36004. */
  36005. soundCollection: Array<Sound>;
  36006. private _outputAudioNode;
  36007. private _scene;
  36008. private _isMainTrack;
  36009. private _connectedAnalyser;
  36010. private _options;
  36011. private _isInitialized;
  36012. /**
  36013. * Creates a new sound track.
  36014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36015. * @param scene Define the scene the sound track belongs to
  36016. * @param options
  36017. */
  36018. constructor(scene: Scene, options?: ISoundTrackOptions);
  36019. private _initializeSoundTrackAudioGraph;
  36020. /**
  36021. * Release the sound track and its associated resources
  36022. */
  36023. dispose(): void;
  36024. /**
  36025. * Adds a sound to this sound track
  36026. * @param sound define the cound to add
  36027. * @ignoreNaming
  36028. */
  36029. AddSound(sound: Sound): void;
  36030. /**
  36031. * Removes a sound to this sound track
  36032. * @param sound define the cound to remove
  36033. * @ignoreNaming
  36034. */
  36035. RemoveSound(sound: Sound): void;
  36036. /**
  36037. * Set a global volume for the full sound track.
  36038. * @param newVolume Define the new volume of the sound track
  36039. */
  36040. setVolume(newVolume: number): void;
  36041. /**
  36042. * Switch the panning model to HRTF:
  36043. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36045. */
  36046. switchPanningModelToHRTF(): void;
  36047. /**
  36048. * Switch the panning model to Equal Power:
  36049. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36050. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36051. */
  36052. switchPanningModelToEqualPower(): void;
  36053. /**
  36054. * Connect the sound track to an audio analyser allowing some amazing
  36055. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36057. * @param analyser The analyser to connect to the engine
  36058. */
  36059. connectToAnalyser(analyser: Analyser): void;
  36060. }
  36061. }
  36062. declare module "babylonjs/Audio/audioSceneComponent" {
  36063. import { Sound } from "babylonjs/Audio/sound";
  36064. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36065. import { Nullable } from "babylonjs/types";
  36066. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36067. import { Scene } from "babylonjs/scene";
  36068. import { AbstractScene } from "babylonjs/abstractScene";
  36069. module "babylonjs/abstractScene" {
  36070. interface AbstractScene {
  36071. /**
  36072. * The list of sounds used in the scene.
  36073. */
  36074. sounds: Nullable<Array<Sound>>;
  36075. }
  36076. }
  36077. module "babylonjs/scene" {
  36078. interface Scene {
  36079. /**
  36080. * @hidden
  36081. * Backing field
  36082. */
  36083. _mainSoundTrack: SoundTrack;
  36084. /**
  36085. * The main sound track played by the scene.
  36086. * It cotains your primary collection of sounds.
  36087. */
  36088. mainSoundTrack: SoundTrack;
  36089. /**
  36090. * The list of sound tracks added to the scene
  36091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36092. */
  36093. soundTracks: Nullable<Array<SoundTrack>>;
  36094. /**
  36095. * Gets a sound using a given name
  36096. * @param name defines the name to search for
  36097. * @return the found sound or null if not found at all.
  36098. */
  36099. getSoundByName(name: string): Nullable<Sound>;
  36100. /**
  36101. * Gets or sets if audio support is enabled
  36102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36103. */
  36104. audioEnabled: boolean;
  36105. /**
  36106. * Gets or sets if audio will be output to headphones
  36107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36108. */
  36109. headphone: boolean;
  36110. }
  36111. }
  36112. /**
  36113. * Defines the sound scene component responsible to manage any sounds
  36114. * in a given scene.
  36115. */
  36116. export class AudioSceneComponent implements ISceneSerializableComponent {
  36117. /**
  36118. * The component name helpfull to identify the component in the list of scene components.
  36119. */
  36120. readonly name: string;
  36121. /**
  36122. * The scene the component belongs to.
  36123. */
  36124. scene: Scene;
  36125. private _audioEnabled;
  36126. /**
  36127. * Gets whether audio is enabled or not.
  36128. * Please use related enable/disable method to switch state.
  36129. */
  36130. readonly audioEnabled: boolean;
  36131. private _headphone;
  36132. /**
  36133. * Gets whether audio is outputing to headphone or not.
  36134. * Please use the according Switch methods to change output.
  36135. */
  36136. readonly headphone: boolean;
  36137. /**
  36138. * Creates a new instance of the component for the given scene
  36139. * @param scene Defines the scene to register the component in
  36140. */
  36141. constructor(scene: Scene);
  36142. /**
  36143. * Registers the component in a given scene
  36144. */
  36145. register(): void;
  36146. /**
  36147. * Rebuilds the elements related to this component in case of
  36148. * context lost for instance.
  36149. */
  36150. rebuild(): void;
  36151. /**
  36152. * Serializes the component data to the specified json object
  36153. * @param serializationObject The object to serialize to
  36154. */
  36155. serialize(serializationObject: any): void;
  36156. /**
  36157. * Adds all the elements from the container to the scene
  36158. * @param container the container holding the elements
  36159. */
  36160. addFromContainer(container: AbstractScene): void;
  36161. /**
  36162. * Removes all the elements in the container from the scene
  36163. * @param container contains the elements to remove
  36164. * @param dispose if the removed element should be disposed (default: false)
  36165. */
  36166. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36167. /**
  36168. * Disposes the component and the associated ressources.
  36169. */
  36170. dispose(): void;
  36171. /**
  36172. * Disables audio in the associated scene.
  36173. */
  36174. disableAudio(): void;
  36175. /**
  36176. * Enables audio in the associated scene.
  36177. */
  36178. enableAudio(): void;
  36179. /**
  36180. * Switch audio to headphone output.
  36181. */
  36182. switchAudioModeForHeadphones(): void;
  36183. /**
  36184. * Switch audio to normal speakers.
  36185. */
  36186. switchAudioModeForNormalSpeakers(): void;
  36187. private _afterRender;
  36188. }
  36189. }
  36190. declare module "babylonjs/Audio/weightedsound" {
  36191. import { Sound } from "babylonjs/Audio/sound";
  36192. /**
  36193. * Wraps one or more Sound objects and selects one with random weight for playback.
  36194. */
  36195. export class WeightedSound {
  36196. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36197. loop: boolean;
  36198. private _coneInnerAngle;
  36199. private _coneOuterAngle;
  36200. private _volume;
  36201. /** A Sound is currently playing. */
  36202. isPlaying: boolean;
  36203. /** A Sound is currently paused. */
  36204. isPaused: boolean;
  36205. private _sounds;
  36206. private _weights;
  36207. private _currentIndex?;
  36208. /**
  36209. * Creates a new WeightedSound from the list of sounds given.
  36210. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36211. * @param sounds Array of Sounds that will be selected from.
  36212. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36213. */
  36214. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36215. /**
  36216. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36217. */
  36218. /**
  36219. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36220. */
  36221. directionalConeInnerAngle: number;
  36222. /**
  36223. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36224. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36225. */
  36226. /**
  36227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36229. */
  36230. directionalConeOuterAngle: number;
  36231. /**
  36232. * Playback volume.
  36233. */
  36234. /**
  36235. * Playback volume.
  36236. */
  36237. volume: number;
  36238. private _onended;
  36239. /**
  36240. * Suspend playback
  36241. */
  36242. pause(): void;
  36243. /**
  36244. * Stop playback
  36245. */
  36246. stop(): void;
  36247. /**
  36248. * Start playback.
  36249. * @param startOffset Position the clip head at a specific time in seconds.
  36250. */
  36251. play(startOffset?: number): void;
  36252. }
  36253. }
  36254. declare module "babylonjs/Audio/index" {
  36255. export * from "babylonjs/Audio/analyser";
  36256. export * from "babylonjs/Audio/audioEngine";
  36257. export * from "babylonjs/Audio/audioSceneComponent";
  36258. export * from "babylonjs/Audio/sound";
  36259. export * from "babylonjs/Audio/soundTrack";
  36260. export * from "babylonjs/Audio/weightedsound";
  36261. }
  36262. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36263. import { Behavior } from "babylonjs/Behaviors/behavior";
  36264. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36265. import { BackEase } from "babylonjs/Animations/easing";
  36266. /**
  36267. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36269. */
  36270. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36271. /**
  36272. * Gets the name of the behavior.
  36273. */
  36274. readonly name: string;
  36275. /**
  36276. * The easing function used by animations
  36277. */
  36278. static EasingFunction: BackEase;
  36279. /**
  36280. * The easing mode used by animations
  36281. */
  36282. static EasingMode: number;
  36283. /**
  36284. * The duration of the animation, in milliseconds
  36285. */
  36286. transitionDuration: number;
  36287. /**
  36288. * Length of the distance animated by the transition when lower radius is reached
  36289. */
  36290. lowerRadiusTransitionRange: number;
  36291. /**
  36292. * Length of the distance animated by the transition when upper radius is reached
  36293. */
  36294. upperRadiusTransitionRange: number;
  36295. private _autoTransitionRange;
  36296. /**
  36297. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36298. */
  36299. /**
  36300. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36301. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36302. */
  36303. autoTransitionRange: boolean;
  36304. private _attachedCamera;
  36305. private _onAfterCheckInputsObserver;
  36306. private _onMeshTargetChangedObserver;
  36307. /**
  36308. * Initializes the behavior.
  36309. */
  36310. init(): void;
  36311. /**
  36312. * Attaches the behavior to its arc rotate camera.
  36313. * @param camera Defines the camera to attach the behavior to
  36314. */
  36315. attach(camera: ArcRotateCamera): void;
  36316. /**
  36317. * Detaches the behavior from its current arc rotate camera.
  36318. */
  36319. detach(): void;
  36320. private _radiusIsAnimating;
  36321. private _radiusBounceTransition;
  36322. private _animatables;
  36323. private _cachedWheelPrecision;
  36324. /**
  36325. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36326. * @param radiusLimit The limit to check against.
  36327. * @return Bool to indicate if at limit.
  36328. */
  36329. private _isRadiusAtLimit;
  36330. /**
  36331. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36332. * @param radiusDelta The delta by which to animate to. Can be negative.
  36333. */
  36334. private _applyBoundRadiusAnimation;
  36335. /**
  36336. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36337. */
  36338. protected _clearAnimationLocks(): void;
  36339. /**
  36340. * Stops and removes all animations that have been applied to the camera
  36341. */
  36342. stopAllAnimations(): void;
  36343. }
  36344. }
  36345. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36346. import { Behavior } from "babylonjs/Behaviors/behavior";
  36347. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36348. import { ExponentialEase } from "babylonjs/Animations/easing";
  36349. import { Nullable } from "babylonjs/types";
  36350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36351. import { Vector3 } from "babylonjs/Maths/math.vector";
  36352. /**
  36353. * 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.
  36354. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36355. */
  36356. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36357. /**
  36358. * Gets the name of the behavior.
  36359. */
  36360. readonly name: string;
  36361. private _mode;
  36362. private _radiusScale;
  36363. private _positionScale;
  36364. private _defaultElevation;
  36365. private _elevationReturnTime;
  36366. private _elevationReturnWaitTime;
  36367. private _zoomStopsAnimation;
  36368. private _framingTime;
  36369. /**
  36370. * The easing function used by animations
  36371. */
  36372. static EasingFunction: ExponentialEase;
  36373. /**
  36374. * The easing mode used by animations
  36375. */
  36376. static EasingMode: number;
  36377. /**
  36378. * Sets the current mode used by the behavior
  36379. */
  36380. /**
  36381. * Gets current mode used by the behavior.
  36382. */
  36383. mode: number;
  36384. /**
  36385. * Sets the scale applied to the radius (1 by default)
  36386. */
  36387. /**
  36388. * Gets the scale applied to the radius
  36389. */
  36390. radiusScale: number;
  36391. /**
  36392. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36393. */
  36394. /**
  36395. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36396. */
  36397. positionScale: number;
  36398. /**
  36399. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36400. * behaviour is triggered, in radians.
  36401. */
  36402. /**
  36403. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36404. * behaviour is triggered, in radians.
  36405. */
  36406. defaultElevation: number;
  36407. /**
  36408. * Sets the time (in milliseconds) taken to return to the default beta position.
  36409. * Negative value indicates camera should not return to default.
  36410. */
  36411. /**
  36412. * Gets the time (in milliseconds) taken to return to the default beta position.
  36413. * Negative value indicates camera should not return to default.
  36414. */
  36415. elevationReturnTime: number;
  36416. /**
  36417. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36418. */
  36419. /**
  36420. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36421. */
  36422. elevationReturnWaitTime: number;
  36423. /**
  36424. * Sets the flag that indicates if user zooming should stop animation.
  36425. */
  36426. /**
  36427. * Gets the flag that indicates if user zooming should stop animation.
  36428. */
  36429. zoomStopsAnimation: boolean;
  36430. /**
  36431. * Sets the transition time when framing the mesh, in milliseconds
  36432. */
  36433. /**
  36434. * Gets the transition time when framing the mesh, in milliseconds
  36435. */
  36436. framingTime: number;
  36437. /**
  36438. * Define if the behavior should automatically change the configured
  36439. * camera limits and sensibilities.
  36440. */
  36441. autoCorrectCameraLimitsAndSensibility: boolean;
  36442. private _onPrePointerObservableObserver;
  36443. private _onAfterCheckInputsObserver;
  36444. private _onMeshTargetChangedObserver;
  36445. private _attachedCamera;
  36446. private _isPointerDown;
  36447. private _lastInteractionTime;
  36448. /**
  36449. * Initializes the behavior.
  36450. */
  36451. init(): void;
  36452. /**
  36453. * Attaches the behavior to its arc rotate camera.
  36454. * @param camera Defines the camera to attach the behavior to
  36455. */
  36456. attach(camera: ArcRotateCamera): void;
  36457. /**
  36458. * Detaches the behavior from its current arc rotate camera.
  36459. */
  36460. detach(): void;
  36461. private _animatables;
  36462. private _betaIsAnimating;
  36463. private _betaTransition;
  36464. private _radiusTransition;
  36465. private _vectorTransition;
  36466. /**
  36467. * Targets the given mesh and updates zoom level accordingly.
  36468. * @param mesh The mesh to target.
  36469. * @param radius Optional. If a cached radius position already exists, overrides default.
  36470. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36473. */
  36474. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36475. /**
  36476. * Targets the given mesh with its children and updates zoom level accordingly.
  36477. * @param mesh The mesh to target.
  36478. * @param radius Optional. If a cached radius position already exists, overrides default.
  36479. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36482. */
  36483. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36484. /**
  36485. * Targets the given meshes with their children and updates zoom level accordingly.
  36486. * @param meshes The mesh to target.
  36487. * @param radius Optional. If a cached radius position already exists, overrides default.
  36488. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36491. */
  36492. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36493. /**
  36494. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36495. * @param minimumWorld Determines the smaller position of the bounding box extend
  36496. * @param maximumWorld Determines the bigger position of the bounding box extend
  36497. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36498. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36499. */
  36500. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36501. /**
  36502. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36503. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36504. * frustum width.
  36505. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36506. * to fully enclose the mesh in the viewing frustum.
  36507. */
  36508. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36509. /**
  36510. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36511. * is automatically returned to its default position (expected to be above ground plane).
  36512. */
  36513. private _maintainCameraAboveGround;
  36514. /**
  36515. * Returns the frustum slope based on the canvas ratio and camera FOV
  36516. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36517. */
  36518. private _getFrustumSlope;
  36519. /**
  36520. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36521. */
  36522. private _clearAnimationLocks;
  36523. /**
  36524. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36525. */
  36526. private _applyUserInteraction;
  36527. /**
  36528. * Stops and removes all animations that have been applied to the camera
  36529. */
  36530. stopAllAnimations(): void;
  36531. /**
  36532. * Gets a value indicating if the user is moving the camera
  36533. */
  36534. readonly isUserIsMoving: boolean;
  36535. /**
  36536. * The camera can move all the way towards the mesh.
  36537. */
  36538. static IgnoreBoundsSizeMode: number;
  36539. /**
  36540. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36541. */
  36542. static FitFrustumSidesMode: number;
  36543. }
  36544. }
  36545. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36546. import { Nullable } from "babylonjs/types";
  36547. import { Camera } from "babylonjs/Cameras/camera";
  36548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36549. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36550. /**
  36551. * Base class for Camera Pointer Inputs.
  36552. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36553. * for example usage.
  36554. */
  36555. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36556. /**
  36557. * Defines the camera the input is attached to.
  36558. */
  36559. abstract camera: Camera;
  36560. /**
  36561. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36562. */
  36563. protected _altKey: boolean;
  36564. protected _ctrlKey: boolean;
  36565. protected _metaKey: boolean;
  36566. protected _shiftKey: boolean;
  36567. /**
  36568. * Which mouse buttons were pressed at time of last mouse event.
  36569. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36570. */
  36571. protected _buttonsPressed: number;
  36572. /**
  36573. * Defines the buttons associated with the input to handle camera move.
  36574. */
  36575. buttons: number[];
  36576. /**
  36577. * Attach the input controls to a specific dom element to get the input from.
  36578. * @param element Defines the element the controls should be listened from
  36579. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36580. */
  36581. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36582. /**
  36583. * Detach the current controls from the specified dom element.
  36584. * @param element Defines the element to stop listening the inputs from
  36585. */
  36586. detachControl(element: Nullable<HTMLElement>): void;
  36587. /**
  36588. * Gets the class name of the current input.
  36589. * @returns the class name
  36590. */
  36591. getClassName(): string;
  36592. /**
  36593. * Get the friendly name associated with the input class.
  36594. * @returns the input friendly name
  36595. */
  36596. getSimpleName(): string;
  36597. /**
  36598. * Called on pointer POINTERDOUBLETAP event.
  36599. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36600. */
  36601. protected onDoubleTap(type: string): void;
  36602. /**
  36603. * Called on pointer POINTERMOVE event if only a single touch is active.
  36604. * Override this method to provide functionality.
  36605. */
  36606. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36607. /**
  36608. * Called on pointer POINTERMOVE event if multiple touches are active.
  36609. * Override this method to provide functionality.
  36610. */
  36611. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36612. /**
  36613. * Called on JS contextmenu event.
  36614. * Override this method to provide functionality.
  36615. */
  36616. protected onContextMenu(evt: PointerEvent): void;
  36617. /**
  36618. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36619. * press.
  36620. * Override this method to provide functionality.
  36621. */
  36622. protected onButtonDown(evt: PointerEvent): void;
  36623. /**
  36624. * Called each time a new POINTERUP event occurs. Ie, for each button
  36625. * release.
  36626. * Override this method to provide functionality.
  36627. */
  36628. protected onButtonUp(evt: PointerEvent): void;
  36629. /**
  36630. * Called when window becomes inactive.
  36631. * Override this method to provide functionality.
  36632. */
  36633. protected onLostFocus(): void;
  36634. private _pointerInput;
  36635. private _observer;
  36636. private _onLostFocus;
  36637. private pointA;
  36638. private pointB;
  36639. }
  36640. }
  36641. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36642. import { Nullable } from "babylonjs/types";
  36643. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36644. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36645. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36646. /**
  36647. * Manage the pointers inputs to control an arc rotate camera.
  36648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36649. */
  36650. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36651. /**
  36652. * Defines the camera the input is attached to.
  36653. */
  36654. camera: ArcRotateCamera;
  36655. /**
  36656. * Gets the class name of the current input.
  36657. * @returns the class name
  36658. */
  36659. getClassName(): string;
  36660. /**
  36661. * Defines the buttons associated with the input to handle camera move.
  36662. */
  36663. buttons: number[];
  36664. /**
  36665. * Defines the pointer angular sensibility along the X axis or how fast is
  36666. * the camera rotating.
  36667. */
  36668. angularSensibilityX: number;
  36669. /**
  36670. * Defines the pointer angular sensibility along the Y axis or how fast is
  36671. * the camera rotating.
  36672. */
  36673. angularSensibilityY: number;
  36674. /**
  36675. * Defines the pointer pinch precision or how fast is the camera zooming.
  36676. */
  36677. pinchPrecision: number;
  36678. /**
  36679. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36680. * from 0.
  36681. * It defines the percentage of current camera.radius to use as delta when
  36682. * pinch zoom is used.
  36683. */
  36684. pinchDeltaPercentage: number;
  36685. /**
  36686. * Defines the pointer panning sensibility or how fast is the camera moving.
  36687. */
  36688. panningSensibility: number;
  36689. /**
  36690. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36691. */
  36692. multiTouchPanning: boolean;
  36693. /**
  36694. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36695. * zoom (pinch) through multitouch.
  36696. */
  36697. multiTouchPanAndZoom: boolean;
  36698. /**
  36699. * Revers pinch action direction.
  36700. */
  36701. pinchInwards: boolean;
  36702. private _isPanClick;
  36703. private _twoFingerActivityCount;
  36704. private _isPinching;
  36705. /**
  36706. * Called on pointer POINTERMOVE event if only a single touch is active.
  36707. */
  36708. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36709. /**
  36710. * Called on pointer POINTERDOUBLETAP event.
  36711. */
  36712. protected onDoubleTap(type: string): void;
  36713. /**
  36714. * Called on pointer POINTERMOVE event if multiple touches are active.
  36715. */
  36716. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36717. /**
  36718. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36719. * press.
  36720. */
  36721. protected onButtonDown(evt: PointerEvent): void;
  36722. /**
  36723. * Called each time a new POINTERUP event occurs. Ie, for each button
  36724. * release.
  36725. */
  36726. protected onButtonUp(evt: PointerEvent): void;
  36727. /**
  36728. * Called when window becomes inactive.
  36729. */
  36730. protected onLostFocus(): void;
  36731. }
  36732. }
  36733. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36734. import { Nullable } from "babylonjs/types";
  36735. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36736. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36737. /**
  36738. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36740. */
  36741. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36742. /**
  36743. * Defines the camera the input is attached to.
  36744. */
  36745. camera: ArcRotateCamera;
  36746. /**
  36747. * Defines the list of key codes associated with the up action (increase alpha)
  36748. */
  36749. keysUp: number[];
  36750. /**
  36751. * Defines the list of key codes associated with the down action (decrease alpha)
  36752. */
  36753. keysDown: number[];
  36754. /**
  36755. * Defines the list of key codes associated with the left action (increase beta)
  36756. */
  36757. keysLeft: number[];
  36758. /**
  36759. * Defines the list of key codes associated with the right action (decrease beta)
  36760. */
  36761. keysRight: number[];
  36762. /**
  36763. * Defines the list of key codes associated with the reset action.
  36764. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36765. */
  36766. keysReset: number[];
  36767. /**
  36768. * Defines the panning sensibility of the inputs.
  36769. * (How fast is the camera paning)
  36770. */
  36771. panningSensibility: number;
  36772. /**
  36773. * Defines the zooming sensibility of the inputs.
  36774. * (How fast is the camera zooming)
  36775. */
  36776. zoomingSensibility: number;
  36777. /**
  36778. * Defines wether maintaining the alt key down switch the movement mode from
  36779. * orientation to zoom.
  36780. */
  36781. useAltToZoom: boolean;
  36782. /**
  36783. * Rotation speed of the camera
  36784. */
  36785. angularSpeed: number;
  36786. private _keys;
  36787. private _ctrlPressed;
  36788. private _altPressed;
  36789. private _onCanvasBlurObserver;
  36790. private _onKeyboardObserver;
  36791. private _engine;
  36792. private _scene;
  36793. /**
  36794. * Attach the input controls to a specific dom element to get the input from.
  36795. * @param element Defines the element the controls should be listened from
  36796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36797. */
  36798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36799. /**
  36800. * Detach the current controls from the specified dom element.
  36801. * @param element Defines the element to stop listening the inputs from
  36802. */
  36803. detachControl(element: Nullable<HTMLElement>): void;
  36804. /**
  36805. * Update the current camera state depending on the inputs that have been used this frame.
  36806. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36807. */
  36808. checkInputs(): void;
  36809. /**
  36810. * Gets the class name of the current intput.
  36811. * @returns the class name
  36812. */
  36813. getClassName(): string;
  36814. /**
  36815. * Get the friendly name associated with the input class.
  36816. * @returns the input friendly name
  36817. */
  36818. getSimpleName(): string;
  36819. }
  36820. }
  36821. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36822. import { Nullable } from "babylonjs/types";
  36823. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36824. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36825. /**
  36826. * Manage the mouse wheel inputs to control an arc rotate camera.
  36827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36828. */
  36829. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36830. /**
  36831. * Defines the camera the input is attached to.
  36832. */
  36833. camera: ArcRotateCamera;
  36834. /**
  36835. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36836. */
  36837. wheelPrecision: number;
  36838. /**
  36839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36841. */
  36842. wheelDeltaPercentage: number;
  36843. private _wheel;
  36844. private _observer;
  36845. private computeDeltaFromMouseWheelLegacyEvent;
  36846. /**
  36847. * Attach the input controls to a specific dom element to get the input from.
  36848. * @param element Defines the element the controls should be listened from
  36849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36850. */
  36851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36852. /**
  36853. * Detach the current controls from the specified dom element.
  36854. * @param element Defines the element to stop listening the inputs from
  36855. */
  36856. detachControl(element: Nullable<HTMLElement>): void;
  36857. /**
  36858. * Gets the class name of the current intput.
  36859. * @returns the class name
  36860. */
  36861. getClassName(): string;
  36862. /**
  36863. * Get the friendly name associated with the input class.
  36864. * @returns the input friendly name
  36865. */
  36866. getSimpleName(): string;
  36867. }
  36868. }
  36869. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36870. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36871. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36872. /**
  36873. * Default Inputs manager for the ArcRotateCamera.
  36874. * It groups all the default supported inputs for ease of use.
  36875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36876. */
  36877. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36878. /**
  36879. * Instantiates a new ArcRotateCameraInputsManager.
  36880. * @param camera Defines the camera the inputs belong to
  36881. */
  36882. constructor(camera: ArcRotateCamera);
  36883. /**
  36884. * Add mouse wheel input support to the input manager.
  36885. * @returns the current input manager
  36886. */
  36887. addMouseWheel(): ArcRotateCameraInputsManager;
  36888. /**
  36889. * Add pointers input support to the input manager.
  36890. * @returns the current input manager
  36891. */
  36892. addPointers(): ArcRotateCameraInputsManager;
  36893. /**
  36894. * Add keyboard input support to the input manager.
  36895. * @returns the current input manager
  36896. */
  36897. addKeyboard(): ArcRotateCameraInputsManager;
  36898. }
  36899. }
  36900. declare module "babylonjs/Cameras/arcRotateCamera" {
  36901. import { Observable } from "babylonjs/Misc/observable";
  36902. import { Nullable } from "babylonjs/types";
  36903. import { Scene } from "babylonjs/scene";
  36904. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36906. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36907. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36908. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36909. import { Camera } from "babylonjs/Cameras/camera";
  36910. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36911. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36912. import { Collider } from "babylonjs/Collisions/collider";
  36913. /**
  36914. * This represents an orbital type of camera.
  36915. *
  36916. * 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.
  36917. * 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.
  36918. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36919. */
  36920. export class ArcRotateCamera extends TargetCamera {
  36921. /**
  36922. * Defines the rotation angle of the camera along the longitudinal axis.
  36923. */
  36924. alpha: number;
  36925. /**
  36926. * Defines the rotation angle of the camera along the latitudinal axis.
  36927. */
  36928. beta: number;
  36929. /**
  36930. * Defines the radius of the camera from it s target point.
  36931. */
  36932. radius: number;
  36933. protected _target: Vector3;
  36934. protected _targetHost: Nullable<AbstractMesh>;
  36935. /**
  36936. * Defines the target point of the camera.
  36937. * The camera looks towards it form the radius distance.
  36938. */
  36939. target: Vector3;
  36940. /**
  36941. * Define the current local position of the camera in the scene
  36942. */
  36943. position: Vector3;
  36944. protected _upVector: Vector3;
  36945. protected _upToYMatrix: Matrix;
  36946. protected _YToUpMatrix: Matrix;
  36947. /**
  36948. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36949. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36950. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36951. */
  36952. upVector: Vector3;
  36953. /**
  36954. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36955. */
  36956. setMatUp(): void;
  36957. /**
  36958. * Current inertia value on the longitudinal axis.
  36959. * The bigger this number the longer it will take for the camera to stop.
  36960. */
  36961. inertialAlphaOffset: number;
  36962. /**
  36963. * Current inertia value on the latitudinal axis.
  36964. * The bigger this number the longer it will take for the camera to stop.
  36965. */
  36966. inertialBetaOffset: number;
  36967. /**
  36968. * Current inertia value on the radius axis.
  36969. * The bigger this number the longer it will take for the camera to stop.
  36970. */
  36971. inertialRadiusOffset: number;
  36972. /**
  36973. * Minimum allowed angle on the longitudinal axis.
  36974. * This can help limiting how the Camera is able to move in the scene.
  36975. */
  36976. lowerAlphaLimit: Nullable<number>;
  36977. /**
  36978. * Maximum allowed angle on the longitudinal axis.
  36979. * This can help limiting how the Camera is able to move in the scene.
  36980. */
  36981. upperAlphaLimit: Nullable<number>;
  36982. /**
  36983. * Minimum allowed angle on the latitudinal axis.
  36984. * This can help limiting how the Camera is able to move in the scene.
  36985. */
  36986. lowerBetaLimit: number;
  36987. /**
  36988. * Maximum allowed angle on the latitudinal axis.
  36989. * This can help limiting how the Camera is able to move in the scene.
  36990. */
  36991. upperBetaLimit: number;
  36992. /**
  36993. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36994. * This can help limiting how the Camera is able to move in the scene.
  36995. */
  36996. lowerRadiusLimit: Nullable<number>;
  36997. /**
  36998. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36999. * This can help limiting how the Camera is able to move in the scene.
  37000. */
  37001. upperRadiusLimit: Nullable<number>;
  37002. /**
  37003. * Defines the current inertia value used during panning of the camera along the X axis.
  37004. */
  37005. inertialPanningX: number;
  37006. /**
  37007. * Defines the current inertia value used during panning of the camera along the Y axis.
  37008. */
  37009. inertialPanningY: number;
  37010. /**
  37011. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37012. * Basically if your fingers moves away from more than this distance you will be considered
  37013. * in pinch mode.
  37014. */
  37015. pinchToPanMaxDistance: number;
  37016. /**
  37017. * Defines the maximum distance the camera can pan.
  37018. * This could help keeping the cammera always in your scene.
  37019. */
  37020. panningDistanceLimit: Nullable<number>;
  37021. /**
  37022. * Defines the target of the camera before paning.
  37023. */
  37024. panningOriginTarget: Vector3;
  37025. /**
  37026. * Defines the value of the inertia used during panning.
  37027. * 0 would mean stop inertia and one would mean no decelleration at all.
  37028. */
  37029. panningInertia: number;
  37030. /**
  37031. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37032. */
  37033. angularSensibilityX: number;
  37034. /**
  37035. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37036. */
  37037. angularSensibilityY: number;
  37038. /**
  37039. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37040. */
  37041. pinchPrecision: number;
  37042. /**
  37043. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37044. * It will be used instead of pinchDeltaPrecision if different from 0.
  37045. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37046. */
  37047. pinchDeltaPercentage: number;
  37048. /**
  37049. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37050. */
  37051. panningSensibility: number;
  37052. /**
  37053. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37054. */
  37055. keysUp: number[];
  37056. /**
  37057. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37058. */
  37059. keysDown: number[];
  37060. /**
  37061. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37062. */
  37063. keysLeft: number[];
  37064. /**
  37065. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37066. */
  37067. keysRight: number[];
  37068. /**
  37069. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37070. */
  37071. wheelPrecision: number;
  37072. /**
  37073. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37074. * It will be used instead of pinchDeltaPrecision if different from 0.
  37075. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37076. */
  37077. wheelDeltaPercentage: number;
  37078. /**
  37079. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37080. */
  37081. zoomOnFactor: number;
  37082. /**
  37083. * Defines a screen offset for the camera position.
  37084. */
  37085. targetScreenOffset: Vector2;
  37086. /**
  37087. * Allows the camera to be completely reversed.
  37088. * If false the camera can not arrive upside down.
  37089. */
  37090. allowUpsideDown: boolean;
  37091. /**
  37092. * Define if double tap/click is used to restore the previously saved state of the camera.
  37093. */
  37094. useInputToRestoreState: boolean;
  37095. /** @hidden */
  37096. _viewMatrix: Matrix;
  37097. /** @hidden */
  37098. _useCtrlForPanning: boolean;
  37099. /** @hidden */
  37100. _panningMouseButton: number;
  37101. /**
  37102. * Defines the input associated to the camera.
  37103. */
  37104. inputs: ArcRotateCameraInputsManager;
  37105. /** @hidden */
  37106. _reset: () => void;
  37107. /**
  37108. * Defines the allowed panning axis.
  37109. */
  37110. panningAxis: Vector3;
  37111. protected _localDirection: Vector3;
  37112. protected _transformedDirection: Vector3;
  37113. private _bouncingBehavior;
  37114. /**
  37115. * Gets the bouncing behavior of the camera if it has been enabled.
  37116. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37117. */
  37118. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37119. /**
  37120. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37121. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37122. */
  37123. useBouncingBehavior: boolean;
  37124. private _framingBehavior;
  37125. /**
  37126. * Gets the framing behavior of the camera if it has been enabled.
  37127. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37128. */
  37129. readonly framingBehavior: Nullable<FramingBehavior>;
  37130. /**
  37131. * Defines if the framing behavior of the camera is enabled on the camera.
  37132. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37133. */
  37134. useFramingBehavior: boolean;
  37135. private _autoRotationBehavior;
  37136. /**
  37137. * Gets the auto rotation behavior of the camera if it has been enabled.
  37138. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37139. */
  37140. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37141. /**
  37142. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37143. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37144. */
  37145. useAutoRotationBehavior: boolean;
  37146. /**
  37147. * Observable triggered when the mesh target has been changed on the camera.
  37148. */
  37149. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37150. /**
  37151. * Event raised when the camera is colliding with a mesh.
  37152. */
  37153. onCollide: (collidedMesh: AbstractMesh) => void;
  37154. /**
  37155. * Defines whether the camera should check collision with the objects oh the scene.
  37156. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37157. */
  37158. checkCollisions: boolean;
  37159. /**
  37160. * Defines the collision radius of the camera.
  37161. * This simulates a sphere around the camera.
  37162. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37163. */
  37164. collisionRadius: Vector3;
  37165. protected _collider: Collider;
  37166. protected _previousPosition: Vector3;
  37167. protected _collisionVelocity: Vector3;
  37168. protected _newPosition: Vector3;
  37169. protected _previousAlpha: number;
  37170. protected _previousBeta: number;
  37171. protected _previousRadius: number;
  37172. protected _collisionTriggered: boolean;
  37173. protected _targetBoundingCenter: Nullable<Vector3>;
  37174. private _computationVector;
  37175. /**
  37176. * Instantiates a new ArcRotateCamera in a given scene
  37177. * @param name Defines the name of the camera
  37178. * @param alpha Defines the camera rotation along the logitudinal axis
  37179. * @param beta Defines the camera rotation along the latitudinal axis
  37180. * @param radius Defines the camera distance from its target
  37181. * @param target Defines the camera target
  37182. * @param scene Defines the scene the camera belongs to
  37183. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37184. */
  37185. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37186. /** @hidden */
  37187. _initCache(): void;
  37188. /** @hidden */
  37189. _updateCache(ignoreParentClass?: boolean): void;
  37190. protected _getTargetPosition(): Vector3;
  37191. private _storedAlpha;
  37192. private _storedBeta;
  37193. private _storedRadius;
  37194. private _storedTarget;
  37195. /**
  37196. * Stores the current state of the camera (alpha, beta, radius and target)
  37197. * @returns the camera itself
  37198. */
  37199. storeState(): Camera;
  37200. /**
  37201. * @hidden
  37202. * Restored camera state. You must call storeState() first
  37203. */
  37204. _restoreStateValues(): boolean;
  37205. /** @hidden */
  37206. _isSynchronizedViewMatrix(): boolean;
  37207. /**
  37208. * Attached controls to the current camera.
  37209. * @param element Defines the element the controls should be listened from
  37210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37211. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37212. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37213. */
  37214. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37215. /**
  37216. * Detach the current controls from the camera.
  37217. * The camera will stop reacting to inputs.
  37218. * @param element Defines the element to stop listening the inputs from
  37219. */
  37220. detachControl(element: HTMLElement): void;
  37221. /** @hidden */
  37222. _checkInputs(): void;
  37223. protected _checkLimits(): void;
  37224. /**
  37225. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37226. */
  37227. rebuildAnglesAndRadius(): void;
  37228. /**
  37229. * Use a position to define the current camera related information like aplha, beta and radius
  37230. * @param position Defines the position to set the camera at
  37231. */
  37232. setPosition(position: Vector3): void;
  37233. /**
  37234. * Defines the target the camera should look at.
  37235. * This will automatically adapt alpha beta and radius to fit within the new target.
  37236. * @param target Defines the new target as a Vector or a mesh
  37237. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37238. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37239. */
  37240. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37241. /** @hidden */
  37242. _getViewMatrix(): Matrix;
  37243. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37244. /**
  37245. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37246. * @param meshes Defines the mesh to zoom on
  37247. * @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)
  37248. */
  37249. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37250. /**
  37251. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37252. * The target will be changed but the radius
  37253. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37254. * @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)
  37255. */
  37256. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37257. min: Vector3;
  37258. max: Vector3;
  37259. distance: number;
  37260. }, doNotUpdateMaxZ?: boolean): void;
  37261. /**
  37262. * @override
  37263. * Override Camera.createRigCamera
  37264. */
  37265. createRigCamera(name: string, cameraIndex: number): Camera;
  37266. /**
  37267. * @hidden
  37268. * @override
  37269. * Override Camera._updateRigCameras
  37270. */
  37271. _updateRigCameras(): void;
  37272. /**
  37273. * Destroy the camera and release the current resources hold by it.
  37274. */
  37275. dispose(): void;
  37276. /**
  37277. * Gets the current object class name.
  37278. * @return the class name
  37279. */
  37280. getClassName(): string;
  37281. }
  37282. }
  37283. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37284. import { Behavior } from "babylonjs/Behaviors/behavior";
  37285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37286. /**
  37287. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37288. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37289. */
  37290. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37291. /**
  37292. * Gets the name of the behavior.
  37293. */
  37294. readonly name: string;
  37295. private _zoomStopsAnimation;
  37296. private _idleRotationSpeed;
  37297. private _idleRotationWaitTime;
  37298. private _idleRotationSpinupTime;
  37299. /**
  37300. * Sets the flag that indicates if user zooming should stop animation.
  37301. */
  37302. /**
  37303. * Gets the flag that indicates if user zooming should stop animation.
  37304. */
  37305. zoomStopsAnimation: boolean;
  37306. /**
  37307. * Sets the default speed at which the camera rotates around the model.
  37308. */
  37309. /**
  37310. * Gets the default speed at which the camera rotates around the model.
  37311. */
  37312. idleRotationSpeed: number;
  37313. /**
  37314. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37315. */
  37316. /**
  37317. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37318. */
  37319. idleRotationWaitTime: number;
  37320. /**
  37321. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37322. */
  37323. /**
  37324. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37325. */
  37326. idleRotationSpinupTime: number;
  37327. /**
  37328. * Gets a value indicating if the camera is currently rotating because of this behavior
  37329. */
  37330. readonly rotationInProgress: boolean;
  37331. private _onPrePointerObservableObserver;
  37332. private _onAfterCheckInputsObserver;
  37333. private _attachedCamera;
  37334. private _isPointerDown;
  37335. private _lastFrameTime;
  37336. private _lastInteractionTime;
  37337. private _cameraRotationSpeed;
  37338. /**
  37339. * Initializes the behavior.
  37340. */
  37341. init(): void;
  37342. /**
  37343. * Attaches the behavior to its arc rotate camera.
  37344. * @param camera Defines the camera to attach the behavior to
  37345. */
  37346. attach(camera: ArcRotateCamera): void;
  37347. /**
  37348. * Detaches the behavior from its current arc rotate camera.
  37349. */
  37350. detach(): void;
  37351. /**
  37352. * Returns true if user is scrolling.
  37353. * @return true if user is scrolling.
  37354. */
  37355. private _userIsZooming;
  37356. private _lastFrameRadius;
  37357. private _shouldAnimationStopForInteraction;
  37358. /**
  37359. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37360. */
  37361. private _applyUserInteraction;
  37362. private _userIsMoving;
  37363. }
  37364. }
  37365. declare module "babylonjs/Behaviors/Cameras/index" {
  37366. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37367. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37368. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37369. }
  37370. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37371. import { Mesh } from "babylonjs/Meshes/mesh";
  37372. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37373. import { Behavior } from "babylonjs/Behaviors/behavior";
  37374. /**
  37375. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37376. */
  37377. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37378. private ui;
  37379. /**
  37380. * The name of the behavior
  37381. */
  37382. name: string;
  37383. /**
  37384. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37385. */
  37386. distanceAwayFromFace: number;
  37387. /**
  37388. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37389. */
  37390. distanceAwayFromBottomOfFace: number;
  37391. private _faceVectors;
  37392. private _target;
  37393. private _scene;
  37394. private _onRenderObserver;
  37395. private _tmpMatrix;
  37396. private _tmpVector;
  37397. /**
  37398. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37399. * @param ui The transform node that should be attched to the mesh
  37400. */
  37401. constructor(ui: TransformNode);
  37402. /**
  37403. * Initializes the behavior
  37404. */
  37405. init(): void;
  37406. private _closestFace;
  37407. private _zeroVector;
  37408. private _lookAtTmpMatrix;
  37409. private _lookAtToRef;
  37410. /**
  37411. * Attaches the AttachToBoxBehavior to the passed in mesh
  37412. * @param target The mesh that the specified node will be attached to
  37413. */
  37414. attach(target: Mesh): void;
  37415. /**
  37416. * Detaches the behavior from the mesh
  37417. */
  37418. detach(): void;
  37419. }
  37420. }
  37421. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37422. import { Behavior } from "babylonjs/Behaviors/behavior";
  37423. import { Mesh } from "babylonjs/Meshes/mesh";
  37424. /**
  37425. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37426. */
  37427. export class FadeInOutBehavior implements Behavior<Mesh> {
  37428. /**
  37429. * Time in milliseconds to delay before fading in (Default: 0)
  37430. */
  37431. delay: number;
  37432. /**
  37433. * Time in milliseconds for the mesh to fade in (Default: 300)
  37434. */
  37435. fadeInTime: number;
  37436. private _millisecondsPerFrame;
  37437. private _hovered;
  37438. private _hoverValue;
  37439. private _ownerNode;
  37440. /**
  37441. * Instatiates the FadeInOutBehavior
  37442. */
  37443. constructor();
  37444. /**
  37445. * The name of the behavior
  37446. */
  37447. readonly name: string;
  37448. /**
  37449. * Initializes the behavior
  37450. */
  37451. init(): void;
  37452. /**
  37453. * Attaches the fade behavior on the passed in mesh
  37454. * @param ownerNode The mesh that will be faded in/out once attached
  37455. */
  37456. attach(ownerNode: Mesh): void;
  37457. /**
  37458. * Detaches the behavior from the mesh
  37459. */
  37460. detach(): void;
  37461. /**
  37462. * Triggers the mesh to begin fading in or out
  37463. * @param value if the object should fade in or out (true to fade in)
  37464. */
  37465. fadeIn(value: boolean): void;
  37466. private _update;
  37467. private _setAllVisibility;
  37468. }
  37469. }
  37470. declare module "babylonjs/Misc/pivotTools" {
  37471. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37472. /**
  37473. * Class containing a set of static utilities functions for managing Pivots
  37474. * @hidden
  37475. */
  37476. export class PivotTools {
  37477. private static _PivotCached;
  37478. private static _OldPivotPoint;
  37479. private static _PivotTranslation;
  37480. private static _PivotTmpVector;
  37481. /** @hidden */
  37482. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37483. /** @hidden */
  37484. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37485. }
  37486. }
  37487. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37488. import { Scene } from "babylonjs/scene";
  37489. import { Vector4 } from "babylonjs/Maths/math.vector";
  37490. import { Mesh } from "babylonjs/Meshes/mesh";
  37491. import { Nullable } from "babylonjs/types";
  37492. import { Plane } from "babylonjs/Maths/math.plane";
  37493. /**
  37494. * Class containing static functions to help procedurally build meshes
  37495. */
  37496. export class PlaneBuilder {
  37497. /**
  37498. * Creates a plane mesh
  37499. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37500. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37501. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37505. * @param name defines the name of the mesh
  37506. * @param options defines the options used to create the mesh
  37507. * @param scene defines the hosting scene
  37508. * @returns the plane mesh
  37509. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37510. */
  37511. static CreatePlane(name: string, options: {
  37512. size?: number;
  37513. width?: number;
  37514. height?: number;
  37515. sideOrientation?: number;
  37516. frontUVs?: Vector4;
  37517. backUVs?: Vector4;
  37518. updatable?: boolean;
  37519. sourcePlane?: Plane;
  37520. }, scene?: Nullable<Scene>): Mesh;
  37521. }
  37522. }
  37523. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37524. import { Behavior } from "babylonjs/Behaviors/behavior";
  37525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37526. import { Observable } from "babylonjs/Misc/observable";
  37527. import { Vector3 } from "babylonjs/Maths/math.vector";
  37528. import { Ray } from "babylonjs/Culling/ray";
  37529. import "babylonjs/Meshes/Builders/planeBuilder";
  37530. /**
  37531. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37532. */
  37533. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37534. private static _AnyMouseID;
  37535. /**
  37536. * Abstract mesh the behavior is set on
  37537. */
  37538. attachedNode: AbstractMesh;
  37539. private _dragPlane;
  37540. private _scene;
  37541. private _pointerObserver;
  37542. private _beforeRenderObserver;
  37543. private static _planeScene;
  37544. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37545. /**
  37546. * 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)
  37547. */
  37548. maxDragAngle: number;
  37549. /**
  37550. * @hidden
  37551. */
  37552. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37553. /**
  37554. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37555. */
  37556. currentDraggingPointerID: number;
  37557. /**
  37558. * The last position where the pointer hit the drag plane in world space
  37559. */
  37560. lastDragPosition: Vector3;
  37561. /**
  37562. * If the behavior is currently in a dragging state
  37563. */
  37564. dragging: boolean;
  37565. /**
  37566. * 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)
  37567. */
  37568. dragDeltaRatio: number;
  37569. /**
  37570. * If the drag plane orientation should be updated during the dragging (Default: true)
  37571. */
  37572. updateDragPlane: boolean;
  37573. private _debugMode;
  37574. private _moving;
  37575. /**
  37576. * Fires each time the attached mesh is dragged with the pointer
  37577. * * delta between last drag position and current drag position in world space
  37578. * * dragDistance along the drag axis
  37579. * * dragPlaneNormal normal of the current drag plane used during the drag
  37580. * * dragPlanePoint in world space where the drag intersects the drag plane
  37581. */
  37582. onDragObservable: Observable<{
  37583. delta: Vector3;
  37584. dragPlanePoint: Vector3;
  37585. dragPlaneNormal: Vector3;
  37586. dragDistance: number;
  37587. pointerId: number;
  37588. }>;
  37589. /**
  37590. * Fires each time a drag begins (eg. mouse down on mesh)
  37591. */
  37592. onDragStartObservable: Observable<{
  37593. dragPlanePoint: Vector3;
  37594. pointerId: number;
  37595. }>;
  37596. /**
  37597. * Fires each time a drag ends (eg. mouse release after drag)
  37598. */
  37599. onDragEndObservable: Observable<{
  37600. dragPlanePoint: Vector3;
  37601. pointerId: number;
  37602. }>;
  37603. /**
  37604. * If the attached mesh should be moved when dragged
  37605. */
  37606. moveAttached: boolean;
  37607. /**
  37608. * If the drag behavior will react to drag events (Default: true)
  37609. */
  37610. enabled: boolean;
  37611. /**
  37612. * If pointer events should start and release the drag (Default: true)
  37613. */
  37614. startAndReleaseDragOnPointerEvents: boolean;
  37615. /**
  37616. * If camera controls should be detached during the drag
  37617. */
  37618. detachCameraControls: boolean;
  37619. /**
  37620. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37621. */
  37622. useObjectOrienationForDragging: boolean;
  37623. private _options;
  37624. /**
  37625. * Creates a pointer drag behavior that can be attached to a mesh
  37626. * @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)
  37627. */
  37628. constructor(options?: {
  37629. dragAxis?: Vector3;
  37630. dragPlaneNormal?: Vector3;
  37631. });
  37632. /**
  37633. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37634. */
  37635. validateDrag: (targetPosition: Vector3) => boolean;
  37636. /**
  37637. * The name of the behavior
  37638. */
  37639. readonly name: string;
  37640. /**
  37641. * Initializes the behavior
  37642. */
  37643. init(): void;
  37644. private _tmpVector;
  37645. private _alternatePickedPoint;
  37646. private _worldDragAxis;
  37647. private _targetPosition;
  37648. private _attachedElement;
  37649. /**
  37650. * Attaches the drag behavior the passed in mesh
  37651. * @param ownerNode The mesh that will be dragged around once attached
  37652. */
  37653. attach(ownerNode: AbstractMesh): void;
  37654. /**
  37655. * Force relase the drag action by code.
  37656. */
  37657. releaseDrag(): void;
  37658. private _startDragRay;
  37659. private _lastPointerRay;
  37660. /**
  37661. * Simulates the start of a pointer drag event on the behavior
  37662. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37663. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37664. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37665. */
  37666. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37667. private _startDrag;
  37668. private _dragDelta;
  37669. private _moveDrag;
  37670. private _pickWithRayOnDragPlane;
  37671. private _pointA;
  37672. private _pointB;
  37673. private _pointC;
  37674. private _lineA;
  37675. private _lineB;
  37676. private _localAxis;
  37677. private _lookAt;
  37678. private _updateDragPlanePosition;
  37679. /**
  37680. * Detaches the behavior from the mesh
  37681. */
  37682. detach(): void;
  37683. }
  37684. }
  37685. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37686. import { Mesh } from "babylonjs/Meshes/mesh";
  37687. import { Behavior } from "babylonjs/Behaviors/behavior";
  37688. /**
  37689. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37690. */
  37691. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37692. private _dragBehaviorA;
  37693. private _dragBehaviorB;
  37694. private _startDistance;
  37695. private _initialScale;
  37696. private _targetScale;
  37697. private _ownerNode;
  37698. private _sceneRenderObserver;
  37699. /**
  37700. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37701. */
  37702. constructor();
  37703. /**
  37704. * The name of the behavior
  37705. */
  37706. readonly name: string;
  37707. /**
  37708. * Initializes the behavior
  37709. */
  37710. init(): void;
  37711. private _getCurrentDistance;
  37712. /**
  37713. * Attaches the scale behavior the passed in mesh
  37714. * @param ownerNode The mesh that will be scaled around once attached
  37715. */
  37716. attach(ownerNode: Mesh): void;
  37717. /**
  37718. * Detaches the behavior from the mesh
  37719. */
  37720. detach(): void;
  37721. }
  37722. }
  37723. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37724. import { Behavior } from "babylonjs/Behaviors/behavior";
  37725. import { Mesh } from "babylonjs/Meshes/mesh";
  37726. import { Observable } from "babylonjs/Misc/observable";
  37727. /**
  37728. * 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
  37729. */
  37730. export class SixDofDragBehavior implements Behavior<Mesh> {
  37731. private static _virtualScene;
  37732. private _ownerNode;
  37733. private _sceneRenderObserver;
  37734. private _scene;
  37735. private _targetPosition;
  37736. private _virtualOriginMesh;
  37737. private _virtualDragMesh;
  37738. private _pointerObserver;
  37739. private _moving;
  37740. private _startingOrientation;
  37741. /**
  37742. * 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)
  37743. */
  37744. private zDragFactor;
  37745. /**
  37746. * If the object should rotate to face the drag origin
  37747. */
  37748. rotateDraggedObject: boolean;
  37749. /**
  37750. * If the behavior is currently in a dragging state
  37751. */
  37752. dragging: boolean;
  37753. /**
  37754. * 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)
  37755. */
  37756. dragDeltaRatio: number;
  37757. /**
  37758. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37759. */
  37760. currentDraggingPointerID: number;
  37761. /**
  37762. * If camera controls should be detached during the drag
  37763. */
  37764. detachCameraControls: boolean;
  37765. /**
  37766. * Fires each time a drag starts
  37767. */
  37768. onDragStartObservable: Observable<{}>;
  37769. /**
  37770. * Fires each time a drag ends (eg. mouse release after drag)
  37771. */
  37772. onDragEndObservable: Observable<{}>;
  37773. /**
  37774. * 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
  37775. */
  37776. constructor();
  37777. /**
  37778. * The name of the behavior
  37779. */
  37780. readonly name: string;
  37781. /**
  37782. * Initializes the behavior
  37783. */
  37784. init(): void;
  37785. /**
  37786. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37787. */
  37788. private readonly _pointerCamera;
  37789. /**
  37790. * Attaches the scale behavior the passed in mesh
  37791. * @param ownerNode The mesh that will be scaled around once attached
  37792. */
  37793. attach(ownerNode: Mesh): void;
  37794. /**
  37795. * Detaches the behavior from the mesh
  37796. */
  37797. detach(): void;
  37798. }
  37799. }
  37800. declare module "babylonjs/Behaviors/Meshes/index" {
  37801. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37802. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37803. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37804. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37805. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37806. }
  37807. declare module "babylonjs/Behaviors/index" {
  37808. export * from "babylonjs/Behaviors/behavior";
  37809. export * from "babylonjs/Behaviors/Cameras/index";
  37810. export * from "babylonjs/Behaviors/Meshes/index";
  37811. }
  37812. declare module "babylonjs/Bones/boneIKController" {
  37813. import { Bone } from "babylonjs/Bones/bone";
  37814. import { Vector3 } from "babylonjs/Maths/math.vector";
  37815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37816. import { Nullable } from "babylonjs/types";
  37817. /**
  37818. * Class used to apply inverse kinematics to bones
  37819. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37820. */
  37821. export class BoneIKController {
  37822. private static _tmpVecs;
  37823. private static _tmpQuat;
  37824. private static _tmpMats;
  37825. /**
  37826. * Gets or sets the target mesh
  37827. */
  37828. targetMesh: AbstractMesh;
  37829. /** Gets or sets the mesh used as pole */
  37830. poleTargetMesh: AbstractMesh;
  37831. /**
  37832. * Gets or sets the bone used as pole
  37833. */
  37834. poleTargetBone: Nullable<Bone>;
  37835. /**
  37836. * Gets or sets the target position
  37837. */
  37838. targetPosition: Vector3;
  37839. /**
  37840. * Gets or sets the pole target position
  37841. */
  37842. poleTargetPosition: Vector3;
  37843. /**
  37844. * Gets or sets the pole target local offset
  37845. */
  37846. poleTargetLocalOffset: Vector3;
  37847. /**
  37848. * Gets or sets the pole angle
  37849. */
  37850. poleAngle: number;
  37851. /**
  37852. * Gets or sets the mesh associated with the controller
  37853. */
  37854. mesh: AbstractMesh;
  37855. /**
  37856. * 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)
  37857. */
  37858. slerpAmount: number;
  37859. private _bone1Quat;
  37860. private _bone1Mat;
  37861. private _bone2Ang;
  37862. private _bone1;
  37863. private _bone2;
  37864. private _bone1Length;
  37865. private _bone2Length;
  37866. private _maxAngle;
  37867. private _maxReach;
  37868. private _rightHandedSystem;
  37869. private _bendAxis;
  37870. private _slerping;
  37871. private _adjustRoll;
  37872. /**
  37873. * Gets or sets maximum allowed angle
  37874. */
  37875. maxAngle: number;
  37876. /**
  37877. * Creates a new BoneIKController
  37878. * @param mesh defines the mesh to control
  37879. * @param bone defines the bone to control
  37880. * @param options defines options to set up the controller
  37881. */
  37882. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37883. targetMesh?: AbstractMesh;
  37884. poleTargetMesh?: AbstractMesh;
  37885. poleTargetBone?: Bone;
  37886. poleTargetLocalOffset?: Vector3;
  37887. poleAngle?: number;
  37888. bendAxis?: Vector3;
  37889. maxAngle?: number;
  37890. slerpAmount?: number;
  37891. });
  37892. private _setMaxAngle;
  37893. /**
  37894. * Force the controller to update the bones
  37895. */
  37896. update(): void;
  37897. }
  37898. }
  37899. declare module "babylonjs/Bones/boneLookController" {
  37900. import { Vector3 } from "babylonjs/Maths/math.vector";
  37901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37902. import { Bone } from "babylonjs/Bones/bone";
  37903. import { Space } from "babylonjs/Maths/math.axis";
  37904. /**
  37905. * Class used to make a bone look toward a point in space
  37906. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37907. */
  37908. export class BoneLookController {
  37909. private static _tmpVecs;
  37910. private static _tmpQuat;
  37911. private static _tmpMats;
  37912. /**
  37913. * The target Vector3 that the bone will look at
  37914. */
  37915. target: Vector3;
  37916. /**
  37917. * The mesh that the bone is attached to
  37918. */
  37919. mesh: AbstractMesh;
  37920. /**
  37921. * The bone that will be looking to the target
  37922. */
  37923. bone: Bone;
  37924. /**
  37925. * The up axis of the coordinate system that is used when the bone is rotated
  37926. */
  37927. upAxis: Vector3;
  37928. /**
  37929. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37930. */
  37931. upAxisSpace: Space;
  37932. /**
  37933. * Used to make an adjustment to the yaw of the bone
  37934. */
  37935. adjustYaw: number;
  37936. /**
  37937. * Used to make an adjustment to the pitch of the bone
  37938. */
  37939. adjustPitch: number;
  37940. /**
  37941. * Used to make an adjustment to the roll of the bone
  37942. */
  37943. adjustRoll: number;
  37944. /**
  37945. * 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)
  37946. */
  37947. slerpAmount: number;
  37948. private _minYaw;
  37949. private _maxYaw;
  37950. private _minPitch;
  37951. private _maxPitch;
  37952. private _minYawSin;
  37953. private _minYawCos;
  37954. private _maxYawSin;
  37955. private _maxYawCos;
  37956. private _midYawConstraint;
  37957. private _minPitchTan;
  37958. private _maxPitchTan;
  37959. private _boneQuat;
  37960. private _slerping;
  37961. private _transformYawPitch;
  37962. private _transformYawPitchInv;
  37963. private _firstFrameSkipped;
  37964. private _yawRange;
  37965. private _fowardAxis;
  37966. /**
  37967. * Gets or sets the minimum yaw angle that the bone can look to
  37968. */
  37969. minYaw: number;
  37970. /**
  37971. * Gets or sets the maximum yaw angle that the bone can look to
  37972. */
  37973. maxYaw: number;
  37974. /**
  37975. * Gets or sets the minimum pitch angle that the bone can look to
  37976. */
  37977. minPitch: number;
  37978. /**
  37979. * Gets or sets the maximum pitch angle that the bone can look to
  37980. */
  37981. maxPitch: number;
  37982. /**
  37983. * Create a BoneLookController
  37984. * @param mesh the mesh that the bone belongs to
  37985. * @param bone the bone that will be looking to the target
  37986. * @param target the target Vector3 to look at
  37987. * @param options optional settings:
  37988. * * maxYaw: the maximum angle the bone will yaw to
  37989. * * minYaw: the minimum angle the bone will yaw to
  37990. * * maxPitch: the maximum angle the bone will pitch to
  37991. * * minPitch: the minimum angle the bone will yaw to
  37992. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37993. * * upAxis: the up axis of the coordinate system
  37994. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37995. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37996. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37997. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37998. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37999. * * adjustRoll: used to make an adjustment to the roll of the bone
  38000. **/
  38001. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38002. maxYaw?: number;
  38003. minYaw?: number;
  38004. maxPitch?: number;
  38005. minPitch?: number;
  38006. slerpAmount?: number;
  38007. upAxis?: Vector3;
  38008. upAxisSpace?: Space;
  38009. yawAxis?: Vector3;
  38010. pitchAxis?: Vector3;
  38011. adjustYaw?: number;
  38012. adjustPitch?: number;
  38013. adjustRoll?: number;
  38014. });
  38015. /**
  38016. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38017. */
  38018. update(): void;
  38019. private _getAngleDiff;
  38020. private _getAngleBetween;
  38021. private _isAngleBetween;
  38022. }
  38023. }
  38024. declare module "babylonjs/Bones/index" {
  38025. export * from "babylonjs/Bones/bone";
  38026. export * from "babylonjs/Bones/boneIKController";
  38027. export * from "babylonjs/Bones/boneLookController";
  38028. export * from "babylonjs/Bones/skeleton";
  38029. }
  38030. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38031. import { Nullable } from "babylonjs/types";
  38032. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38033. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38034. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38035. /**
  38036. * Manage the gamepad inputs to control an arc rotate camera.
  38037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38038. */
  38039. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38040. /**
  38041. * Defines the camera the input is attached to.
  38042. */
  38043. camera: ArcRotateCamera;
  38044. /**
  38045. * Defines the gamepad the input is gathering event from.
  38046. */
  38047. gamepad: Nullable<Gamepad>;
  38048. /**
  38049. * Defines the gamepad rotation sensiblity.
  38050. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38051. */
  38052. gamepadRotationSensibility: number;
  38053. /**
  38054. * Defines the gamepad move sensiblity.
  38055. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38056. */
  38057. gamepadMoveSensibility: number;
  38058. private _onGamepadConnectedObserver;
  38059. private _onGamepadDisconnectedObserver;
  38060. /**
  38061. * Attach the input controls to a specific dom element to get the input from.
  38062. * @param element Defines the element the controls should be listened from
  38063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38064. */
  38065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38066. /**
  38067. * Detach the current controls from the specified dom element.
  38068. * @param element Defines the element to stop listening the inputs from
  38069. */
  38070. detachControl(element: Nullable<HTMLElement>): void;
  38071. /**
  38072. * Update the current camera state depending on the inputs that have been used this frame.
  38073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38074. */
  38075. checkInputs(): void;
  38076. /**
  38077. * Gets the class name of the current intput.
  38078. * @returns the class name
  38079. */
  38080. getClassName(): string;
  38081. /**
  38082. * Get the friendly name associated with the input class.
  38083. * @returns the input friendly name
  38084. */
  38085. getSimpleName(): string;
  38086. }
  38087. }
  38088. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38089. import { Nullable } from "babylonjs/types";
  38090. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38092. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38093. interface ArcRotateCameraInputsManager {
  38094. /**
  38095. * Add orientation input support to the input manager.
  38096. * @returns the current input manager
  38097. */
  38098. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38099. }
  38100. }
  38101. /**
  38102. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38103. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38104. */
  38105. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38106. /**
  38107. * Defines the camera the input is attached to.
  38108. */
  38109. camera: ArcRotateCamera;
  38110. /**
  38111. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38112. */
  38113. alphaCorrection: number;
  38114. /**
  38115. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38116. */
  38117. gammaCorrection: number;
  38118. private _alpha;
  38119. private _gamma;
  38120. private _dirty;
  38121. private _deviceOrientationHandler;
  38122. /**
  38123. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38124. */
  38125. constructor();
  38126. /**
  38127. * Attach the input controls to a specific dom element to get the input from.
  38128. * @param element Defines the element the controls should be listened from
  38129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38130. */
  38131. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38132. /** @hidden */
  38133. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38134. /**
  38135. * Update the current camera state depending on the inputs that have been used this frame.
  38136. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38137. */
  38138. checkInputs(): void;
  38139. /**
  38140. * Detach the current controls from the specified dom element.
  38141. * @param element Defines the element to stop listening the inputs from
  38142. */
  38143. detachControl(element: Nullable<HTMLElement>): void;
  38144. /**
  38145. * Gets the class name of the current intput.
  38146. * @returns the class name
  38147. */
  38148. getClassName(): string;
  38149. /**
  38150. * Get the friendly name associated with the input class.
  38151. * @returns the input friendly name
  38152. */
  38153. getSimpleName(): string;
  38154. }
  38155. }
  38156. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38157. import { Nullable } from "babylonjs/types";
  38158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38159. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38160. /**
  38161. * Listen to mouse events to control the camera.
  38162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38163. */
  38164. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38165. /**
  38166. * Defines the camera the input is attached to.
  38167. */
  38168. camera: FlyCamera;
  38169. /**
  38170. * Defines if touch is enabled. (Default is true.)
  38171. */
  38172. touchEnabled: boolean;
  38173. /**
  38174. * Defines the buttons associated with the input to handle camera rotation.
  38175. */
  38176. buttons: number[];
  38177. /**
  38178. * Assign buttons for Yaw control.
  38179. */
  38180. buttonsYaw: number[];
  38181. /**
  38182. * Assign buttons for Pitch control.
  38183. */
  38184. buttonsPitch: number[];
  38185. /**
  38186. * Assign buttons for Roll control.
  38187. */
  38188. buttonsRoll: number[];
  38189. /**
  38190. * Detect if any button is being pressed while mouse is moved.
  38191. * -1 = Mouse locked.
  38192. * 0 = Left button.
  38193. * 1 = Middle Button.
  38194. * 2 = Right Button.
  38195. */
  38196. activeButton: number;
  38197. /**
  38198. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38199. * Higher values reduce its sensitivity.
  38200. */
  38201. angularSensibility: number;
  38202. private _mousemoveCallback;
  38203. private _observer;
  38204. private _rollObserver;
  38205. private previousPosition;
  38206. private noPreventDefault;
  38207. private element;
  38208. /**
  38209. * Listen to mouse events to control the camera.
  38210. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38211. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38212. */
  38213. constructor(touchEnabled?: boolean);
  38214. /**
  38215. * Attach the mouse control to the HTML DOM element.
  38216. * @param element Defines the element that listens to the input events.
  38217. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38218. */
  38219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38220. /**
  38221. * Detach the current controls from the specified dom element.
  38222. * @param element Defines the element to stop listening the inputs from
  38223. */
  38224. detachControl(element: Nullable<HTMLElement>): void;
  38225. /**
  38226. * Gets the class name of the current input.
  38227. * @returns the class name.
  38228. */
  38229. getClassName(): string;
  38230. /**
  38231. * Get the friendly name associated with the input class.
  38232. * @returns the input's friendly name.
  38233. */
  38234. getSimpleName(): string;
  38235. private _pointerInput;
  38236. private _onMouseMove;
  38237. /**
  38238. * Rotate camera by mouse offset.
  38239. */
  38240. private rotateCamera;
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38244. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38245. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38246. /**
  38247. * Default Inputs manager for the FlyCamera.
  38248. * It groups all the default supported inputs for ease of use.
  38249. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38250. */
  38251. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38252. /**
  38253. * Instantiates a new FlyCameraInputsManager.
  38254. * @param camera Defines the camera the inputs belong to.
  38255. */
  38256. constructor(camera: FlyCamera);
  38257. /**
  38258. * Add keyboard input support to the input manager.
  38259. * @returns the new FlyCameraKeyboardMoveInput().
  38260. */
  38261. addKeyboard(): FlyCameraInputsManager;
  38262. /**
  38263. * Add mouse input support to the input manager.
  38264. * @param touchEnabled Enable touch screen support.
  38265. * @returns the new FlyCameraMouseInput().
  38266. */
  38267. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38268. }
  38269. }
  38270. declare module "babylonjs/Cameras/flyCamera" {
  38271. import { Scene } from "babylonjs/scene";
  38272. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38274. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38275. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38276. /**
  38277. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38278. * such as in a 3D Space Shooter or a Flight Simulator.
  38279. */
  38280. export class FlyCamera extends TargetCamera {
  38281. /**
  38282. * Define the collision ellipsoid of the camera.
  38283. * This is helpful for simulating a camera body, like a player's body.
  38284. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38285. */
  38286. ellipsoid: Vector3;
  38287. /**
  38288. * Define an offset for the position of the ellipsoid around the camera.
  38289. * This can be helpful if the camera is attached away from the player's body center,
  38290. * such as at its head.
  38291. */
  38292. ellipsoidOffset: Vector3;
  38293. /**
  38294. * Enable or disable collisions of the camera with the rest of the scene objects.
  38295. */
  38296. checkCollisions: boolean;
  38297. /**
  38298. * Enable or disable gravity on the camera.
  38299. */
  38300. applyGravity: boolean;
  38301. /**
  38302. * Define the current direction the camera is moving to.
  38303. */
  38304. cameraDirection: Vector3;
  38305. /**
  38306. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38307. * This overrides and empties cameraRotation.
  38308. */
  38309. rotationQuaternion: Quaternion;
  38310. /**
  38311. * Track Roll to maintain the wanted Rolling when looking around.
  38312. */
  38313. _trackRoll: number;
  38314. /**
  38315. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38316. */
  38317. rollCorrect: number;
  38318. /**
  38319. * Mimic a banked turn, Rolling the camera when Yawing.
  38320. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38321. */
  38322. bankedTurn: boolean;
  38323. /**
  38324. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38325. */
  38326. bankedTurnLimit: number;
  38327. /**
  38328. * Value of 0 disables the banked Roll.
  38329. * Value of 1 is equal to the Yaw angle in radians.
  38330. */
  38331. bankedTurnMultiplier: number;
  38332. /**
  38333. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38334. */
  38335. inputs: FlyCameraInputsManager;
  38336. /**
  38337. * Gets the input sensibility for mouse input.
  38338. * Higher values reduce sensitivity.
  38339. */
  38340. /**
  38341. * Sets the input sensibility for a mouse input.
  38342. * Higher values reduce sensitivity.
  38343. */
  38344. angularSensibility: number;
  38345. /**
  38346. * Get the keys for camera movement forward.
  38347. */
  38348. /**
  38349. * Set the keys for camera movement forward.
  38350. */
  38351. keysForward: number[];
  38352. /**
  38353. * Get the keys for camera movement backward.
  38354. */
  38355. keysBackward: number[];
  38356. /**
  38357. * Get the keys for camera movement up.
  38358. */
  38359. /**
  38360. * Set the keys for camera movement up.
  38361. */
  38362. keysUp: number[];
  38363. /**
  38364. * Get the keys for camera movement down.
  38365. */
  38366. /**
  38367. * Set the keys for camera movement down.
  38368. */
  38369. keysDown: number[];
  38370. /**
  38371. * Get the keys for camera movement left.
  38372. */
  38373. /**
  38374. * Set the keys for camera movement left.
  38375. */
  38376. keysLeft: number[];
  38377. /**
  38378. * Set the keys for camera movement right.
  38379. */
  38380. /**
  38381. * Set the keys for camera movement right.
  38382. */
  38383. keysRight: number[];
  38384. /**
  38385. * Event raised when the camera collides with a mesh in the scene.
  38386. */
  38387. onCollide: (collidedMesh: AbstractMesh) => void;
  38388. private _collider;
  38389. private _needMoveForGravity;
  38390. private _oldPosition;
  38391. private _diffPosition;
  38392. private _newPosition;
  38393. /** @hidden */
  38394. _localDirection: Vector3;
  38395. /** @hidden */
  38396. _transformedDirection: Vector3;
  38397. /**
  38398. * Instantiates a FlyCamera.
  38399. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38400. * such as in a 3D Space Shooter or a Flight Simulator.
  38401. * @param name Define the name of the camera in the scene.
  38402. * @param position Define the starting position of the camera in the scene.
  38403. * @param scene Define the scene the camera belongs to.
  38404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38405. */
  38406. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38407. /**
  38408. * Attach a control to the HTML DOM element.
  38409. * @param element Defines the element that listens to the input events.
  38410. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38411. */
  38412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38413. /**
  38414. * Detach a control from the HTML DOM element.
  38415. * The camera will stop reacting to that input.
  38416. * @param element Defines the element that listens to the input events.
  38417. */
  38418. detachControl(element: HTMLElement): void;
  38419. private _collisionMask;
  38420. /**
  38421. * Get the mask that the camera ignores in collision events.
  38422. */
  38423. /**
  38424. * Set the mask that the camera ignores in collision events.
  38425. */
  38426. collisionMask: number;
  38427. /** @hidden */
  38428. _collideWithWorld(displacement: Vector3): void;
  38429. /** @hidden */
  38430. private _onCollisionPositionChange;
  38431. /** @hidden */
  38432. _checkInputs(): void;
  38433. /** @hidden */
  38434. _decideIfNeedsToMove(): boolean;
  38435. /** @hidden */
  38436. _updatePosition(): void;
  38437. /**
  38438. * Restore the Roll to its target value at the rate specified.
  38439. * @param rate - Higher means slower restoring.
  38440. * @hidden
  38441. */
  38442. restoreRoll(rate: number): void;
  38443. /**
  38444. * Destroy the camera and release the current resources held by it.
  38445. */
  38446. dispose(): void;
  38447. /**
  38448. * Get the current object class name.
  38449. * @returns the class name.
  38450. */
  38451. getClassName(): string;
  38452. }
  38453. }
  38454. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38455. import { Nullable } from "babylonjs/types";
  38456. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38457. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38458. /**
  38459. * Listen to keyboard events to control the camera.
  38460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38461. */
  38462. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38463. /**
  38464. * Defines the camera the input is attached to.
  38465. */
  38466. camera: FlyCamera;
  38467. /**
  38468. * The list of keyboard keys used to control the forward move of the camera.
  38469. */
  38470. keysForward: number[];
  38471. /**
  38472. * The list of keyboard keys used to control the backward move of the camera.
  38473. */
  38474. keysBackward: number[];
  38475. /**
  38476. * The list of keyboard keys used to control the forward move of the camera.
  38477. */
  38478. keysUp: number[];
  38479. /**
  38480. * The list of keyboard keys used to control the backward move of the camera.
  38481. */
  38482. keysDown: number[];
  38483. /**
  38484. * The list of keyboard keys used to control the right strafe move of the camera.
  38485. */
  38486. keysRight: number[];
  38487. /**
  38488. * The list of keyboard keys used to control the left strafe move of the camera.
  38489. */
  38490. keysLeft: number[];
  38491. private _keys;
  38492. private _onCanvasBlurObserver;
  38493. private _onKeyboardObserver;
  38494. private _engine;
  38495. private _scene;
  38496. /**
  38497. * Attach the input controls to a specific dom element to get the input from.
  38498. * @param element Defines the element the controls should be listened from
  38499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38500. */
  38501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38502. /**
  38503. * Detach the current controls from the specified dom element.
  38504. * @param element Defines the element to stop listening the inputs from
  38505. */
  38506. detachControl(element: Nullable<HTMLElement>): void;
  38507. /**
  38508. * Gets the class name of the current intput.
  38509. * @returns the class name
  38510. */
  38511. getClassName(): string;
  38512. /** @hidden */
  38513. _onLostFocus(e: FocusEvent): void;
  38514. /**
  38515. * Get the friendly name associated with the input class.
  38516. * @returns the input friendly name
  38517. */
  38518. getSimpleName(): string;
  38519. /**
  38520. * Update the current camera state depending on the inputs that have been used this frame.
  38521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38522. */
  38523. checkInputs(): void;
  38524. }
  38525. }
  38526. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38527. import { Nullable } from "babylonjs/types";
  38528. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38529. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38530. /**
  38531. * Manage the mouse wheel inputs to control a follow camera.
  38532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38533. */
  38534. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38535. /**
  38536. * Defines the camera the input is attached to.
  38537. */
  38538. camera: FollowCamera;
  38539. /**
  38540. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38541. */
  38542. axisControlRadius: boolean;
  38543. /**
  38544. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38545. */
  38546. axisControlHeight: boolean;
  38547. /**
  38548. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38549. */
  38550. axisControlRotation: boolean;
  38551. /**
  38552. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38553. * relation to mouseWheel events.
  38554. */
  38555. wheelPrecision: number;
  38556. /**
  38557. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38558. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38559. */
  38560. wheelDeltaPercentage: number;
  38561. private _wheel;
  38562. private _observer;
  38563. /**
  38564. * Attach the input controls to a specific dom element to get the input from.
  38565. * @param element Defines the element the controls should be listened from
  38566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38567. */
  38568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38569. /**
  38570. * Detach the current controls from the specified dom element.
  38571. * @param element Defines the element to stop listening the inputs from
  38572. */
  38573. detachControl(element: Nullable<HTMLElement>): void;
  38574. /**
  38575. * Gets the class name of the current intput.
  38576. * @returns the class name
  38577. */
  38578. getClassName(): string;
  38579. /**
  38580. * Get the friendly name associated with the input class.
  38581. * @returns the input friendly name
  38582. */
  38583. getSimpleName(): string;
  38584. }
  38585. }
  38586. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38587. import { Nullable } from "babylonjs/types";
  38588. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38589. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38590. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38591. /**
  38592. * Manage the pointers inputs to control an follow camera.
  38593. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38594. */
  38595. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38596. /**
  38597. * Defines the camera the input is attached to.
  38598. */
  38599. camera: FollowCamera;
  38600. /**
  38601. * Gets the class name of the current input.
  38602. * @returns the class name
  38603. */
  38604. getClassName(): string;
  38605. /**
  38606. * Defines the pointer angular sensibility along the X axis or how fast is
  38607. * the camera rotating.
  38608. * A negative number will reverse the axis direction.
  38609. */
  38610. angularSensibilityX: number;
  38611. /**
  38612. * Defines the pointer angular sensibility along the Y axis or how fast is
  38613. * the camera rotating.
  38614. * A negative number will reverse the axis direction.
  38615. */
  38616. angularSensibilityY: number;
  38617. /**
  38618. * Defines the pointer pinch precision or how fast is the camera zooming.
  38619. * A negative number will reverse the axis direction.
  38620. */
  38621. pinchPrecision: number;
  38622. /**
  38623. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38624. * from 0.
  38625. * It defines the percentage of current camera.radius to use as delta when
  38626. * pinch zoom is used.
  38627. */
  38628. pinchDeltaPercentage: number;
  38629. /**
  38630. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38631. */
  38632. axisXControlRadius: boolean;
  38633. /**
  38634. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38635. */
  38636. axisXControlHeight: boolean;
  38637. /**
  38638. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38639. */
  38640. axisXControlRotation: boolean;
  38641. /**
  38642. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38643. */
  38644. axisYControlRadius: boolean;
  38645. /**
  38646. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38647. */
  38648. axisYControlHeight: boolean;
  38649. /**
  38650. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38651. */
  38652. axisYControlRotation: boolean;
  38653. /**
  38654. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38655. */
  38656. axisPinchControlRadius: boolean;
  38657. /**
  38658. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38659. */
  38660. axisPinchControlHeight: boolean;
  38661. /**
  38662. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38663. */
  38664. axisPinchControlRotation: boolean;
  38665. /**
  38666. * Log error messages if basic misconfiguration has occurred.
  38667. */
  38668. warningEnable: boolean;
  38669. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38670. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38671. private _warningCounter;
  38672. private _warning;
  38673. }
  38674. }
  38675. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38676. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38677. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38678. /**
  38679. * Default Inputs manager for the FollowCamera.
  38680. * It groups all the default supported inputs for ease of use.
  38681. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38682. */
  38683. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38684. /**
  38685. * Instantiates a new FollowCameraInputsManager.
  38686. * @param camera Defines the camera the inputs belong to
  38687. */
  38688. constructor(camera: FollowCamera);
  38689. /**
  38690. * Add keyboard input support to the input manager.
  38691. * @returns the current input manager
  38692. */
  38693. addKeyboard(): FollowCameraInputsManager;
  38694. /**
  38695. * Add mouse wheel input support to the input manager.
  38696. * @returns the current input manager
  38697. */
  38698. addMouseWheel(): FollowCameraInputsManager;
  38699. /**
  38700. * Add pointers input support to the input manager.
  38701. * @returns the current input manager
  38702. */
  38703. addPointers(): FollowCameraInputsManager;
  38704. /**
  38705. * Add orientation input support to the input manager.
  38706. * @returns the current input manager
  38707. */
  38708. addVRDeviceOrientation(): FollowCameraInputsManager;
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/followCamera" {
  38712. import { Nullable } from "babylonjs/types";
  38713. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38714. import { Scene } from "babylonjs/scene";
  38715. import { Vector3 } from "babylonjs/Maths/math.vector";
  38716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38717. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38718. /**
  38719. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38720. * an arc rotate version arcFollowCamera are available.
  38721. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38722. */
  38723. export class FollowCamera extends TargetCamera {
  38724. /**
  38725. * Distance the follow camera should follow an object at
  38726. */
  38727. radius: number;
  38728. /**
  38729. * Minimum allowed distance of the camera to the axis of rotation
  38730. * (The camera can not get closer).
  38731. * This can help limiting how the Camera is able to move in the scene.
  38732. */
  38733. lowerRadiusLimit: Nullable<number>;
  38734. /**
  38735. * Maximum allowed distance of the camera to the axis of rotation
  38736. * (The camera can not get further).
  38737. * This can help limiting how the Camera is able to move in the scene.
  38738. */
  38739. upperRadiusLimit: Nullable<number>;
  38740. /**
  38741. * Define a rotation offset between the camera and the object it follows
  38742. */
  38743. rotationOffset: number;
  38744. /**
  38745. * Minimum allowed angle to camera position relative to target object.
  38746. * This can help limiting how the Camera is able to move in the scene.
  38747. */
  38748. lowerRotationOffsetLimit: Nullable<number>;
  38749. /**
  38750. * Maximum allowed angle to camera position relative to target object.
  38751. * This can help limiting how the Camera is able to move in the scene.
  38752. */
  38753. upperRotationOffsetLimit: Nullable<number>;
  38754. /**
  38755. * Define a height offset between the camera and the object it follows.
  38756. * It can help following an object from the top (like a car chaing a plane)
  38757. */
  38758. heightOffset: number;
  38759. /**
  38760. * Minimum allowed height of camera position relative to target object.
  38761. * This can help limiting how the Camera is able to move in the scene.
  38762. */
  38763. lowerHeightOffsetLimit: Nullable<number>;
  38764. /**
  38765. * Maximum allowed height of camera position relative to target object.
  38766. * This can help limiting how the Camera is able to move in the scene.
  38767. */
  38768. upperHeightOffsetLimit: Nullable<number>;
  38769. /**
  38770. * Define how fast the camera can accelerate to follow it s target.
  38771. */
  38772. cameraAcceleration: number;
  38773. /**
  38774. * Define the speed limit of the camera following an object.
  38775. */
  38776. maxCameraSpeed: number;
  38777. /**
  38778. * Define the target of the camera.
  38779. */
  38780. lockedTarget: Nullable<AbstractMesh>;
  38781. /**
  38782. * Defines the input associated with the camera.
  38783. */
  38784. inputs: FollowCameraInputsManager;
  38785. /**
  38786. * Instantiates the follow camera.
  38787. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38788. * @param name Define the name of the camera in the scene
  38789. * @param position Define the position of the camera
  38790. * @param scene Define the scene the camera belong to
  38791. * @param lockedTarget Define the target of the camera
  38792. */
  38793. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38794. private _follow;
  38795. /**
  38796. * Attached controls to the current camera.
  38797. * @param element Defines the element the controls should be listened from
  38798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38799. */
  38800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38801. /**
  38802. * Detach the current controls from the camera.
  38803. * The camera will stop reacting to inputs.
  38804. * @param element Defines the element to stop listening the inputs from
  38805. */
  38806. detachControl(element: HTMLElement): void;
  38807. /** @hidden */
  38808. _checkInputs(): void;
  38809. private _checkLimits;
  38810. /**
  38811. * Gets the camera class name.
  38812. * @returns the class name
  38813. */
  38814. getClassName(): string;
  38815. }
  38816. /**
  38817. * Arc Rotate version of the follow camera.
  38818. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38819. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38820. */
  38821. export class ArcFollowCamera extends TargetCamera {
  38822. /** The longitudinal angle of the camera */
  38823. alpha: number;
  38824. /** The latitudinal angle of the camera */
  38825. beta: number;
  38826. /** The radius of the camera from its target */
  38827. radius: number;
  38828. /** Define the camera target (the messh it should follow) */
  38829. target: Nullable<AbstractMesh>;
  38830. private _cartesianCoordinates;
  38831. /**
  38832. * Instantiates a new ArcFollowCamera
  38833. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38834. * @param name Define the name of the camera
  38835. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38836. * @param beta Define the rotation angle of the camera around the elevation axis
  38837. * @param radius Define the radius of the camera from its target point
  38838. * @param target Define the target of the camera
  38839. * @param scene Define the scene the camera belongs to
  38840. */
  38841. constructor(name: string,
  38842. /** The longitudinal angle of the camera */
  38843. alpha: number,
  38844. /** The latitudinal angle of the camera */
  38845. beta: number,
  38846. /** The radius of the camera from its target */
  38847. radius: number,
  38848. /** Define the camera target (the messh it should follow) */
  38849. target: Nullable<AbstractMesh>, scene: Scene);
  38850. private _follow;
  38851. /** @hidden */
  38852. _checkInputs(): void;
  38853. /**
  38854. * Returns the class name of the object.
  38855. * It is mostly used internally for serialization purposes.
  38856. */
  38857. getClassName(): string;
  38858. }
  38859. }
  38860. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38862. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38863. import { Nullable } from "babylonjs/types";
  38864. /**
  38865. * Manage the keyboard inputs to control the movement of a follow camera.
  38866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38867. */
  38868. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38869. /**
  38870. * Defines the camera the input is attached to.
  38871. */
  38872. camera: FollowCamera;
  38873. /**
  38874. * Defines the list of key codes associated with the up action (increase heightOffset)
  38875. */
  38876. keysHeightOffsetIncr: number[];
  38877. /**
  38878. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38879. */
  38880. keysHeightOffsetDecr: number[];
  38881. /**
  38882. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38883. */
  38884. keysHeightOffsetModifierAlt: boolean;
  38885. /**
  38886. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38887. */
  38888. keysHeightOffsetModifierCtrl: boolean;
  38889. /**
  38890. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38891. */
  38892. keysHeightOffsetModifierShift: boolean;
  38893. /**
  38894. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38895. */
  38896. keysRotationOffsetIncr: number[];
  38897. /**
  38898. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38899. */
  38900. keysRotationOffsetDecr: number[];
  38901. /**
  38902. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38903. */
  38904. keysRotationOffsetModifierAlt: boolean;
  38905. /**
  38906. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38907. */
  38908. keysRotationOffsetModifierCtrl: boolean;
  38909. /**
  38910. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38911. */
  38912. keysRotationOffsetModifierShift: boolean;
  38913. /**
  38914. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38915. */
  38916. keysRadiusIncr: number[];
  38917. /**
  38918. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38919. */
  38920. keysRadiusDecr: number[];
  38921. /**
  38922. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38923. */
  38924. keysRadiusModifierAlt: boolean;
  38925. /**
  38926. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38927. */
  38928. keysRadiusModifierCtrl: boolean;
  38929. /**
  38930. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38931. */
  38932. keysRadiusModifierShift: boolean;
  38933. /**
  38934. * Defines the rate of change of heightOffset.
  38935. */
  38936. heightSensibility: number;
  38937. /**
  38938. * Defines the rate of change of rotationOffset.
  38939. */
  38940. rotationSensibility: number;
  38941. /**
  38942. * Defines the rate of change of radius.
  38943. */
  38944. radiusSensibility: number;
  38945. private _keys;
  38946. private _ctrlPressed;
  38947. private _altPressed;
  38948. private _shiftPressed;
  38949. private _onCanvasBlurObserver;
  38950. private _onKeyboardObserver;
  38951. private _engine;
  38952. private _scene;
  38953. /**
  38954. * Attach the input controls to a specific dom element to get the input from.
  38955. * @param element Defines the element the controls should be listened from
  38956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38957. */
  38958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38959. /**
  38960. * Detach the current controls from the specified dom element.
  38961. * @param element Defines the element to stop listening the inputs from
  38962. */
  38963. detachControl(element: Nullable<HTMLElement>): void;
  38964. /**
  38965. * Update the current camera state depending on the inputs that have been used this frame.
  38966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38967. */
  38968. checkInputs(): void;
  38969. /**
  38970. * Gets the class name of the current input.
  38971. * @returns the class name
  38972. */
  38973. getClassName(): string;
  38974. /**
  38975. * Get the friendly name associated with the input class.
  38976. * @returns the input friendly name
  38977. */
  38978. getSimpleName(): string;
  38979. /**
  38980. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38981. * allow modification of the heightOffset value.
  38982. */
  38983. private _modifierHeightOffset;
  38984. /**
  38985. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38986. * allow modification of the rotationOffset value.
  38987. */
  38988. private _modifierRotationOffset;
  38989. /**
  38990. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38991. * allow modification of the radius value.
  38992. */
  38993. private _modifierRadius;
  38994. }
  38995. }
  38996. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38997. import { Nullable } from "babylonjs/types";
  38998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38999. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39000. import { Observable } from "babylonjs/Misc/observable";
  39001. module "babylonjs/Cameras/freeCameraInputsManager" {
  39002. interface FreeCameraInputsManager {
  39003. /**
  39004. * @hidden
  39005. */
  39006. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39007. /**
  39008. * Add orientation input support to the input manager.
  39009. * @returns the current input manager
  39010. */
  39011. addDeviceOrientation(): FreeCameraInputsManager;
  39012. }
  39013. }
  39014. /**
  39015. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39016. * Screen rotation is taken into account.
  39017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39018. */
  39019. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39020. private _camera;
  39021. private _screenOrientationAngle;
  39022. private _constantTranform;
  39023. private _screenQuaternion;
  39024. private _alpha;
  39025. private _beta;
  39026. private _gamma;
  39027. /**
  39028. * Can be used to detect if a device orientation sensor is availible on a device
  39029. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39030. * @returns a promise that will resolve on orientation change
  39031. */
  39032. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39033. /**
  39034. * @hidden
  39035. */
  39036. _onDeviceOrientationChangedObservable: Observable<void>;
  39037. /**
  39038. * Instantiates a new input
  39039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39040. */
  39041. constructor();
  39042. /**
  39043. * Define the camera controlled by the input.
  39044. */
  39045. camera: FreeCamera;
  39046. /**
  39047. * Attach the input controls to a specific dom element to get the input from.
  39048. * @param element Defines the element the controls should be listened from
  39049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39050. */
  39051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39052. private _orientationChanged;
  39053. private _deviceOrientation;
  39054. /**
  39055. * Detach the current controls from the specified dom element.
  39056. * @param element Defines the element to stop listening the inputs from
  39057. */
  39058. detachControl(element: Nullable<HTMLElement>): void;
  39059. /**
  39060. * Update the current camera state depending on the inputs that have been used this frame.
  39061. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39062. */
  39063. checkInputs(): void;
  39064. /**
  39065. * Gets the class name of the current intput.
  39066. * @returns the class name
  39067. */
  39068. getClassName(): string;
  39069. /**
  39070. * Get the friendly name associated with the input class.
  39071. * @returns the input friendly name
  39072. */
  39073. getSimpleName(): string;
  39074. }
  39075. }
  39076. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39077. import { Nullable } from "babylonjs/types";
  39078. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39079. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39080. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39081. /**
  39082. * Manage the gamepad inputs to control a free camera.
  39083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39084. */
  39085. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39086. /**
  39087. * Define the camera the input is attached to.
  39088. */
  39089. camera: FreeCamera;
  39090. /**
  39091. * Define the Gamepad controlling the input
  39092. */
  39093. gamepad: Nullable<Gamepad>;
  39094. /**
  39095. * Defines the gamepad rotation sensiblity.
  39096. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39097. */
  39098. gamepadAngularSensibility: number;
  39099. /**
  39100. * Defines the gamepad move sensiblity.
  39101. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39102. */
  39103. gamepadMoveSensibility: number;
  39104. private _onGamepadConnectedObserver;
  39105. private _onGamepadDisconnectedObserver;
  39106. private _cameraTransform;
  39107. private _deltaTransform;
  39108. private _vector3;
  39109. private _vector2;
  39110. /**
  39111. * Attach the input controls to a specific dom element to get the input from.
  39112. * @param element Defines the element the controls should be listened from
  39113. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39114. */
  39115. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39116. /**
  39117. * Detach the current controls from the specified dom element.
  39118. * @param element Defines the element to stop listening the inputs from
  39119. */
  39120. detachControl(element: Nullable<HTMLElement>): void;
  39121. /**
  39122. * Update the current camera state depending on the inputs that have been used this frame.
  39123. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39124. */
  39125. checkInputs(): void;
  39126. /**
  39127. * Gets the class name of the current intput.
  39128. * @returns the class name
  39129. */
  39130. getClassName(): string;
  39131. /**
  39132. * Get the friendly name associated with the input class.
  39133. * @returns the input friendly name
  39134. */
  39135. getSimpleName(): string;
  39136. }
  39137. }
  39138. declare module "babylonjs/Misc/virtualJoystick" {
  39139. import { Nullable } from "babylonjs/types";
  39140. import { Vector3 } from "babylonjs/Maths/math.vector";
  39141. /**
  39142. * Defines the potential axis of a Joystick
  39143. */
  39144. export enum JoystickAxis {
  39145. /** X axis */
  39146. X = 0,
  39147. /** Y axis */
  39148. Y = 1,
  39149. /** Z axis */
  39150. Z = 2
  39151. }
  39152. /**
  39153. * Class used to define virtual joystick (used in touch mode)
  39154. */
  39155. export class VirtualJoystick {
  39156. /**
  39157. * Gets or sets a boolean indicating that left and right values must be inverted
  39158. */
  39159. reverseLeftRight: boolean;
  39160. /**
  39161. * Gets or sets a boolean indicating that up and down values must be inverted
  39162. */
  39163. reverseUpDown: boolean;
  39164. /**
  39165. * Gets the offset value for the position (ie. the change of the position value)
  39166. */
  39167. deltaPosition: Vector3;
  39168. /**
  39169. * Gets a boolean indicating if the virtual joystick was pressed
  39170. */
  39171. pressed: boolean;
  39172. /**
  39173. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39174. */
  39175. static Canvas: Nullable<HTMLCanvasElement>;
  39176. private static _globalJoystickIndex;
  39177. private static vjCanvasContext;
  39178. private static vjCanvasWidth;
  39179. private static vjCanvasHeight;
  39180. private static halfWidth;
  39181. private _action;
  39182. private _axisTargetedByLeftAndRight;
  39183. private _axisTargetedByUpAndDown;
  39184. private _joystickSensibility;
  39185. private _inversedSensibility;
  39186. private _joystickPointerID;
  39187. private _joystickColor;
  39188. private _joystickPointerPos;
  39189. private _joystickPreviousPointerPos;
  39190. private _joystickPointerStartPos;
  39191. private _deltaJoystickVector;
  39192. private _leftJoystick;
  39193. private _touches;
  39194. private _onPointerDownHandlerRef;
  39195. private _onPointerMoveHandlerRef;
  39196. private _onPointerUpHandlerRef;
  39197. private _onResize;
  39198. /**
  39199. * Creates a new virtual joystick
  39200. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39201. */
  39202. constructor(leftJoystick?: boolean);
  39203. /**
  39204. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39205. * @param newJoystickSensibility defines the new sensibility
  39206. */
  39207. setJoystickSensibility(newJoystickSensibility: number): void;
  39208. private _onPointerDown;
  39209. private _onPointerMove;
  39210. private _onPointerUp;
  39211. /**
  39212. * Change the color of the virtual joystick
  39213. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39214. */
  39215. setJoystickColor(newColor: string): void;
  39216. /**
  39217. * Defines a callback to call when the joystick is touched
  39218. * @param action defines the callback
  39219. */
  39220. setActionOnTouch(action: () => any): void;
  39221. /**
  39222. * Defines which axis you'd like to control for left & right
  39223. * @param axis defines the axis to use
  39224. */
  39225. setAxisForLeftRight(axis: JoystickAxis): void;
  39226. /**
  39227. * Defines which axis you'd like to control for up & down
  39228. * @param axis defines the axis to use
  39229. */
  39230. setAxisForUpDown(axis: JoystickAxis): void;
  39231. private _drawVirtualJoystick;
  39232. /**
  39233. * Release internal HTML canvas
  39234. */
  39235. releaseCanvas(): void;
  39236. }
  39237. }
  39238. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39239. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39240. import { Nullable } from "babylonjs/types";
  39241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39242. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39243. module "babylonjs/Cameras/freeCameraInputsManager" {
  39244. interface FreeCameraInputsManager {
  39245. /**
  39246. * Add virtual joystick input support to the input manager.
  39247. * @returns the current input manager
  39248. */
  39249. addVirtualJoystick(): FreeCameraInputsManager;
  39250. }
  39251. }
  39252. /**
  39253. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39255. */
  39256. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39257. /**
  39258. * Defines the camera the input is attached to.
  39259. */
  39260. camera: FreeCamera;
  39261. private _leftjoystick;
  39262. private _rightjoystick;
  39263. /**
  39264. * Gets the left stick of the virtual joystick.
  39265. * @returns The virtual Joystick
  39266. */
  39267. getLeftJoystick(): VirtualJoystick;
  39268. /**
  39269. * Gets the right stick of the virtual joystick.
  39270. * @returns The virtual Joystick
  39271. */
  39272. getRightJoystick(): VirtualJoystick;
  39273. /**
  39274. * Update the current camera state depending on the inputs that have been used this frame.
  39275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39276. */
  39277. checkInputs(): void;
  39278. /**
  39279. * Attach the input controls to a specific dom element to get the input from.
  39280. * @param element Defines the element the controls should be listened from
  39281. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39282. */
  39283. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39284. /**
  39285. * Detach the current controls from the specified dom element.
  39286. * @param element Defines the element to stop listening the inputs from
  39287. */
  39288. detachControl(element: Nullable<HTMLElement>): void;
  39289. /**
  39290. * Gets the class name of the current intput.
  39291. * @returns the class name
  39292. */
  39293. getClassName(): string;
  39294. /**
  39295. * Get the friendly name associated with the input class.
  39296. * @returns the input friendly name
  39297. */
  39298. getSimpleName(): string;
  39299. }
  39300. }
  39301. declare module "babylonjs/Cameras/Inputs/index" {
  39302. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39303. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39304. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39305. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39306. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39307. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39308. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39309. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39310. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39311. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39312. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39313. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39314. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39315. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39316. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39317. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39318. }
  39319. declare module "babylonjs/Cameras/touchCamera" {
  39320. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39321. import { Scene } from "babylonjs/scene";
  39322. import { Vector3 } from "babylonjs/Maths/math.vector";
  39323. /**
  39324. * This represents a FPS type of camera controlled by touch.
  39325. * This is like a universal camera minus the Gamepad controls.
  39326. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39327. */
  39328. export class TouchCamera extends FreeCamera {
  39329. /**
  39330. * Defines the touch sensibility for rotation.
  39331. * The higher the faster.
  39332. */
  39333. touchAngularSensibility: number;
  39334. /**
  39335. * Defines the touch sensibility for move.
  39336. * The higher the faster.
  39337. */
  39338. touchMoveSensibility: number;
  39339. /**
  39340. * Instantiates a new touch camera.
  39341. * This represents a FPS type of camera controlled by touch.
  39342. * This is like a universal camera minus the Gamepad controls.
  39343. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39344. * @param name Define the name of the camera in the scene
  39345. * @param position Define the start position of the camera in the scene
  39346. * @param scene Define the scene the camera belongs to
  39347. */
  39348. constructor(name: string, position: Vector3, scene: Scene);
  39349. /**
  39350. * Gets the current object class name.
  39351. * @return the class name
  39352. */
  39353. getClassName(): string;
  39354. /** @hidden */
  39355. _setupInputs(): void;
  39356. }
  39357. }
  39358. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39359. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39360. import { Scene } from "babylonjs/scene";
  39361. import { Vector3 } from "babylonjs/Maths/math.vector";
  39362. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39363. import { Axis } from "babylonjs/Maths/math.axis";
  39364. /**
  39365. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39366. * being tilted forward or back and left or right.
  39367. */
  39368. export class DeviceOrientationCamera extends FreeCamera {
  39369. private _initialQuaternion;
  39370. private _quaternionCache;
  39371. private _tmpDragQuaternion;
  39372. /**
  39373. * Creates a new device orientation camera
  39374. * @param name The name of the camera
  39375. * @param position The start position camera
  39376. * @param scene The scene the camera belongs to
  39377. */
  39378. constructor(name: string, position: Vector3, scene: Scene);
  39379. /**
  39380. * @hidden
  39381. * Disabled pointer input on first orientation sensor update (Default: true)
  39382. */
  39383. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39384. private _dragFactor;
  39385. /**
  39386. * Enabled turning on the y axis when the orientation sensor is active
  39387. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39388. */
  39389. enableHorizontalDragging(dragFactor?: number): void;
  39390. /**
  39391. * Gets the current instance class name ("DeviceOrientationCamera").
  39392. * This helps avoiding instanceof at run time.
  39393. * @returns the class name
  39394. */
  39395. getClassName(): string;
  39396. /**
  39397. * @hidden
  39398. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39399. */
  39400. _checkInputs(): void;
  39401. /**
  39402. * Reset the camera to its default orientation on the specified axis only.
  39403. * @param axis The axis to reset
  39404. */
  39405. resetToCurrentRotation(axis?: Axis): void;
  39406. }
  39407. }
  39408. declare module "babylonjs/Gamepads/xboxGamepad" {
  39409. import { Observable } from "babylonjs/Misc/observable";
  39410. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39411. /**
  39412. * Defines supported buttons for XBox360 compatible gamepads
  39413. */
  39414. export enum Xbox360Button {
  39415. /** A */
  39416. A = 0,
  39417. /** B */
  39418. B = 1,
  39419. /** X */
  39420. X = 2,
  39421. /** Y */
  39422. Y = 3,
  39423. /** Start */
  39424. Start = 4,
  39425. /** Back */
  39426. Back = 5,
  39427. /** Left button */
  39428. LB = 6,
  39429. /** Right button */
  39430. RB = 7,
  39431. /** Left stick */
  39432. LeftStick = 8,
  39433. /** Right stick */
  39434. RightStick = 9
  39435. }
  39436. /** Defines values for XBox360 DPad */
  39437. export enum Xbox360Dpad {
  39438. /** Up */
  39439. Up = 0,
  39440. /** Down */
  39441. Down = 1,
  39442. /** Left */
  39443. Left = 2,
  39444. /** Right */
  39445. Right = 3
  39446. }
  39447. /**
  39448. * Defines a XBox360 gamepad
  39449. */
  39450. export class Xbox360Pad extends Gamepad {
  39451. private _leftTrigger;
  39452. private _rightTrigger;
  39453. private _onlefttriggerchanged;
  39454. private _onrighttriggerchanged;
  39455. private _onbuttondown;
  39456. private _onbuttonup;
  39457. private _ondpaddown;
  39458. private _ondpadup;
  39459. /** Observable raised when a button is pressed */
  39460. onButtonDownObservable: Observable<Xbox360Button>;
  39461. /** Observable raised when a button is released */
  39462. onButtonUpObservable: Observable<Xbox360Button>;
  39463. /** Observable raised when a pad is pressed */
  39464. onPadDownObservable: Observable<Xbox360Dpad>;
  39465. /** Observable raised when a pad is released */
  39466. onPadUpObservable: Observable<Xbox360Dpad>;
  39467. private _buttonA;
  39468. private _buttonB;
  39469. private _buttonX;
  39470. private _buttonY;
  39471. private _buttonBack;
  39472. private _buttonStart;
  39473. private _buttonLB;
  39474. private _buttonRB;
  39475. private _buttonLeftStick;
  39476. private _buttonRightStick;
  39477. private _dPadUp;
  39478. private _dPadDown;
  39479. private _dPadLeft;
  39480. private _dPadRight;
  39481. private _isXboxOnePad;
  39482. /**
  39483. * Creates a new XBox360 gamepad object
  39484. * @param id defines the id of this gamepad
  39485. * @param index defines its index
  39486. * @param gamepad defines the internal HTML gamepad object
  39487. * @param xboxOne defines if it is a XBox One gamepad
  39488. */
  39489. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39490. /**
  39491. * Defines the callback to call when left trigger is pressed
  39492. * @param callback defines the callback to use
  39493. */
  39494. onlefttriggerchanged(callback: (value: number) => void): void;
  39495. /**
  39496. * Defines the callback to call when right trigger is pressed
  39497. * @param callback defines the callback to use
  39498. */
  39499. onrighttriggerchanged(callback: (value: number) => void): void;
  39500. /**
  39501. * Gets the left trigger value
  39502. */
  39503. /**
  39504. * Sets the left trigger value
  39505. */
  39506. leftTrigger: number;
  39507. /**
  39508. * Gets the right trigger value
  39509. */
  39510. /**
  39511. * Sets the right trigger value
  39512. */
  39513. rightTrigger: number;
  39514. /**
  39515. * Defines the callback to call when a button is pressed
  39516. * @param callback defines the callback to use
  39517. */
  39518. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39519. /**
  39520. * Defines the callback to call when a button is released
  39521. * @param callback defines the callback to use
  39522. */
  39523. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39524. /**
  39525. * Defines the callback to call when a pad is pressed
  39526. * @param callback defines the callback to use
  39527. */
  39528. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39529. /**
  39530. * Defines the callback to call when a pad is released
  39531. * @param callback defines the callback to use
  39532. */
  39533. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39534. private _setButtonValue;
  39535. private _setDPadValue;
  39536. /**
  39537. * Gets the value of the `A` button
  39538. */
  39539. /**
  39540. * Sets the value of the `A` button
  39541. */
  39542. buttonA: number;
  39543. /**
  39544. * Gets the value of the `B` button
  39545. */
  39546. /**
  39547. * Sets the value of the `B` button
  39548. */
  39549. buttonB: number;
  39550. /**
  39551. * Gets the value of the `X` button
  39552. */
  39553. /**
  39554. * Sets the value of the `X` button
  39555. */
  39556. buttonX: number;
  39557. /**
  39558. * Gets the value of the `Y` button
  39559. */
  39560. /**
  39561. * Sets the value of the `Y` button
  39562. */
  39563. buttonY: number;
  39564. /**
  39565. * Gets the value of the `Start` button
  39566. */
  39567. /**
  39568. * Sets the value of the `Start` button
  39569. */
  39570. buttonStart: number;
  39571. /**
  39572. * Gets the value of the `Back` button
  39573. */
  39574. /**
  39575. * Sets the value of the `Back` button
  39576. */
  39577. buttonBack: number;
  39578. /**
  39579. * Gets the value of the `Left` button
  39580. */
  39581. /**
  39582. * Sets the value of the `Left` button
  39583. */
  39584. buttonLB: number;
  39585. /**
  39586. * Gets the value of the `Right` button
  39587. */
  39588. /**
  39589. * Sets the value of the `Right` button
  39590. */
  39591. buttonRB: number;
  39592. /**
  39593. * Gets the value of the Left joystick
  39594. */
  39595. /**
  39596. * Sets the value of the Left joystick
  39597. */
  39598. buttonLeftStick: number;
  39599. /**
  39600. * Gets the value of the Right joystick
  39601. */
  39602. /**
  39603. * Sets the value of the Right joystick
  39604. */
  39605. buttonRightStick: number;
  39606. /**
  39607. * Gets the value of D-pad up
  39608. */
  39609. /**
  39610. * Sets the value of D-pad up
  39611. */
  39612. dPadUp: number;
  39613. /**
  39614. * Gets the value of D-pad down
  39615. */
  39616. /**
  39617. * Sets the value of D-pad down
  39618. */
  39619. dPadDown: number;
  39620. /**
  39621. * Gets the value of D-pad left
  39622. */
  39623. /**
  39624. * Sets the value of D-pad left
  39625. */
  39626. dPadLeft: number;
  39627. /**
  39628. * Gets the value of D-pad right
  39629. */
  39630. /**
  39631. * Sets the value of D-pad right
  39632. */
  39633. dPadRight: number;
  39634. /**
  39635. * Force the gamepad to synchronize with device values
  39636. */
  39637. update(): void;
  39638. /**
  39639. * Disposes the gamepad
  39640. */
  39641. dispose(): void;
  39642. }
  39643. }
  39644. declare module "babylonjs/Gamepads/gamepadManager" {
  39645. import { Observable } from "babylonjs/Misc/observable";
  39646. import { Nullable } from "babylonjs/types";
  39647. import { Scene } from "babylonjs/scene";
  39648. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39649. /**
  39650. * Manager for handling gamepads
  39651. */
  39652. export class GamepadManager {
  39653. private _scene?;
  39654. private _babylonGamepads;
  39655. private _oneGamepadConnected;
  39656. /** @hidden */
  39657. _isMonitoring: boolean;
  39658. private _gamepadEventSupported;
  39659. private _gamepadSupport;
  39660. /**
  39661. * observable to be triggered when the gamepad controller has been connected
  39662. */
  39663. onGamepadConnectedObservable: Observable<Gamepad>;
  39664. /**
  39665. * observable to be triggered when the gamepad controller has been disconnected
  39666. */
  39667. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39668. private _onGamepadConnectedEvent;
  39669. private _onGamepadDisconnectedEvent;
  39670. /**
  39671. * Initializes the gamepad manager
  39672. * @param _scene BabylonJS scene
  39673. */
  39674. constructor(_scene?: Scene | undefined);
  39675. /**
  39676. * The gamepads in the game pad manager
  39677. */
  39678. readonly gamepads: Gamepad[];
  39679. /**
  39680. * Get the gamepad controllers based on type
  39681. * @param type The type of gamepad controller
  39682. * @returns Nullable gamepad
  39683. */
  39684. getGamepadByType(type?: number): Nullable<Gamepad>;
  39685. /**
  39686. * Disposes the gamepad manager
  39687. */
  39688. dispose(): void;
  39689. private _addNewGamepad;
  39690. private _startMonitoringGamepads;
  39691. private _stopMonitoringGamepads;
  39692. /** @hidden */
  39693. _checkGamepadsStatus(): void;
  39694. private _updateGamepadObjects;
  39695. }
  39696. }
  39697. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39698. import { Nullable } from "babylonjs/types";
  39699. import { Scene } from "babylonjs/scene";
  39700. import { ISceneComponent } from "babylonjs/sceneComponent";
  39701. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39702. module "babylonjs/scene" {
  39703. interface Scene {
  39704. /** @hidden */
  39705. _gamepadManager: Nullable<GamepadManager>;
  39706. /**
  39707. * Gets the gamepad manager associated with the scene
  39708. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39709. */
  39710. gamepadManager: GamepadManager;
  39711. }
  39712. }
  39713. module "babylonjs/Cameras/freeCameraInputsManager" {
  39714. /**
  39715. * Interface representing a free camera inputs manager
  39716. */
  39717. interface FreeCameraInputsManager {
  39718. /**
  39719. * Adds gamepad input support to the FreeCameraInputsManager.
  39720. * @returns the FreeCameraInputsManager
  39721. */
  39722. addGamepad(): FreeCameraInputsManager;
  39723. }
  39724. }
  39725. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39726. /**
  39727. * Interface representing an arc rotate camera inputs manager
  39728. */
  39729. interface ArcRotateCameraInputsManager {
  39730. /**
  39731. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39732. * @returns the camera inputs manager
  39733. */
  39734. addGamepad(): ArcRotateCameraInputsManager;
  39735. }
  39736. }
  39737. /**
  39738. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39739. */
  39740. export class GamepadSystemSceneComponent implements ISceneComponent {
  39741. /**
  39742. * The component name helpfull to identify the component in the list of scene components.
  39743. */
  39744. readonly name: string;
  39745. /**
  39746. * The scene the component belongs to.
  39747. */
  39748. scene: Scene;
  39749. /**
  39750. * Creates a new instance of the component for the given scene
  39751. * @param scene Defines the scene to register the component in
  39752. */
  39753. constructor(scene: Scene);
  39754. /**
  39755. * Registers the component in a given scene
  39756. */
  39757. register(): void;
  39758. /**
  39759. * Rebuilds the elements related to this component in case of
  39760. * context lost for instance.
  39761. */
  39762. rebuild(): void;
  39763. /**
  39764. * Disposes the component and the associated ressources
  39765. */
  39766. dispose(): void;
  39767. private _beforeCameraUpdate;
  39768. }
  39769. }
  39770. declare module "babylonjs/Cameras/universalCamera" {
  39771. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39772. import { Scene } from "babylonjs/scene";
  39773. import { Vector3 } from "babylonjs/Maths/math.vector";
  39774. import "babylonjs/Gamepads/gamepadSceneComponent";
  39775. /**
  39776. * 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,
  39777. * which still works and will still be found in many Playgrounds.
  39778. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39779. */
  39780. export class UniversalCamera extends TouchCamera {
  39781. /**
  39782. * Defines the gamepad rotation sensiblity.
  39783. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39784. */
  39785. gamepadAngularSensibility: number;
  39786. /**
  39787. * Defines the gamepad move sensiblity.
  39788. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39789. */
  39790. gamepadMoveSensibility: number;
  39791. /**
  39792. * 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,
  39793. * which still works and will still be found in many Playgrounds.
  39794. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39795. * @param name Define the name of the camera in the scene
  39796. * @param position Define the start position of the camera in the scene
  39797. * @param scene Define the scene the camera belongs to
  39798. */
  39799. constructor(name: string, position: Vector3, scene: Scene);
  39800. /**
  39801. * Gets the current object class name.
  39802. * @return the class name
  39803. */
  39804. getClassName(): string;
  39805. }
  39806. }
  39807. declare module "babylonjs/Cameras/gamepadCamera" {
  39808. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39809. import { Scene } from "babylonjs/scene";
  39810. import { Vector3 } from "babylonjs/Maths/math.vector";
  39811. /**
  39812. * This represents a FPS type of camera. This is only here for back compat purpose.
  39813. * Please use the UniversalCamera instead as both are identical.
  39814. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39815. */
  39816. export class GamepadCamera extends UniversalCamera {
  39817. /**
  39818. * Instantiates a new Gamepad Camera
  39819. * This represents a FPS type of camera. This is only here for back compat purpose.
  39820. * Please use the UniversalCamera instead as both are identical.
  39821. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39822. * @param name Define the name of the camera in the scene
  39823. * @param position Define the start position of the camera in the scene
  39824. * @param scene Define the scene the camera belongs to
  39825. */
  39826. constructor(name: string, position: Vector3, scene: Scene);
  39827. /**
  39828. * Gets the current object class name.
  39829. * @return the class name
  39830. */
  39831. getClassName(): string;
  39832. }
  39833. }
  39834. declare module "babylonjs/Shaders/pass.fragment" {
  39835. /** @hidden */
  39836. export var passPixelShader: {
  39837. name: string;
  39838. shader: string;
  39839. };
  39840. }
  39841. declare module "babylonjs/Shaders/passCube.fragment" {
  39842. /** @hidden */
  39843. export var passCubePixelShader: {
  39844. name: string;
  39845. shader: string;
  39846. };
  39847. }
  39848. declare module "babylonjs/PostProcesses/passPostProcess" {
  39849. import { Nullable } from "babylonjs/types";
  39850. import { Camera } from "babylonjs/Cameras/camera";
  39851. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39852. import { Engine } from "babylonjs/Engines/engine";
  39853. import "babylonjs/Shaders/pass.fragment";
  39854. import "babylonjs/Shaders/passCube.fragment";
  39855. /**
  39856. * PassPostProcess which produces an output the same as it's input
  39857. */
  39858. export class PassPostProcess extends PostProcess {
  39859. /**
  39860. * Creates the PassPostProcess
  39861. * @param name The name of the effect.
  39862. * @param options The required width/height ratio to downsize to before computing the render pass.
  39863. * @param camera The camera to apply the render pass to.
  39864. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39865. * @param engine The engine which the post process will be applied. (default: current engine)
  39866. * @param reusable If the post process can be reused on the same frame. (default: false)
  39867. * @param textureType The type of texture to be used when performing the post processing.
  39868. * @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)
  39869. */
  39870. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39871. }
  39872. /**
  39873. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39874. */
  39875. export class PassCubePostProcess extends PostProcess {
  39876. private _face;
  39877. /**
  39878. * Gets or sets the cube face to display.
  39879. * * 0 is +X
  39880. * * 1 is -X
  39881. * * 2 is +Y
  39882. * * 3 is -Y
  39883. * * 4 is +Z
  39884. * * 5 is -Z
  39885. */
  39886. face: number;
  39887. /**
  39888. * Creates the PassCubePostProcess
  39889. * @param name The name of the effect.
  39890. * @param options The required width/height ratio to downsize to before computing the render pass.
  39891. * @param camera The camera to apply the render pass to.
  39892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39893. * @param engine The engine which the post process will be applied. (default: current engine)
  39894. * @param reusable If the post process can be reused on the same frame. (default: false)
  39895. * @param textureType The type of texture to be used when performing the post processing.
  39896. * @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)
  39897. */
  39898. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39899. }
  39900. }
  39901. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39902. /** @hidden */
  39903. export var anaglyphPixelShader: {
  39904. name: string;
  39905. shader: string;
  39906. };
  39907. }
  39908. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39909. import { Engine } from "babylonjs/Engines/engine";
  39910. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39911. import { Camera } from "babylonjs/Cameras/camera";
  39912. import "babylonjs/Shaders/anaglyph.fragment";
  39913. /**
  39914. * Postprocess used to generate anaglyphic rendering
  39915. */
  39916. export class AnaglyphPostProcess extends PostProcess {
  39917. private _passedProcess;
  39918. /**
  39919. * Creates a new AnaglyphPostProcess
  39920. * @param name defines postprocess name
  39921. * @param options defines creation options or target ratio scale
  39922. * @param rigCameras defines cameras using this postprocess
  39923. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39924. * @param engine defines hosting engine
  39925. * @param reusable defines if the postprocess will be reused multiple times per frame
  39926. */
  39927. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39928. }
  39929. }
  39930. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39931. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39932. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39933. import { Scene } from "babylonjs/scene";
  39934. import { Vector3 } from "babylonjs/Maths/math.vector";
  39935. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39936. /**
  39937. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39938. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39939. */
  39940. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39941. /**
  39942. * Creates a new AnaglyphArcRotateCamera
  39943. * @param name defines camera name
  39944. * @param alpha defines alpha angle (in radians)
  39945. * @param beta defines beta angle (in radians)
  39946. * @param radius defines radius
  39947. * @param target defines camera target
  39948. * @param interaxialDistance defines distance between each color axis
  39949. * @param scene defines the hosting scene
  39950. */
  39951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39952. /**
  39953. * Gets camera class name
  39954. * @returns AnaglyphArcRotateCamera
  39955. */
  39956. getClassName(): string;
  39957. }
  39958. }
  39959. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39961. import { Scene } from "babylonjs/scene";
  39962. import { Vector3 } from "babylonjs/Maths/math.vector";
  39963. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39964. /**
  39965. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39966. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39967. */
  39968. export class AnaglyphFreeCamera extends FreeCamera {
  39969. /**
  39970. * Creates a new AnaglyphFreeCamera
  39971. * @param name defines camera name
  39972. * @param position defines initial position
  39973. * @param interaxialDistance defines distance between each color axis
  39974. * @param scene defines the hosting scene
  39975. */
  39976. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39977. /**
  39978. * Gets camera class name
  39979. * @returns AnaglyphFreeCamera
  39980. */
  39981. getClassName(): string;
  39982. }
  39983. }
  39984. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39985. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39986. import { Scene } from "babylonjs/scene";
  39987. import { Vector3 } from "babylonjs/Maths/math.vector";
  39988. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39989. /**
  39990. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39991. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39992. */
  39993. export class AnaglyphGamepadCamera extends GamepadCamera {
  39994. /**
  39995. * Creates a new AnaglyphGamepadCamera
  39996. * @param name defines camera name
  39997. * @param position defines initial position
  39998. * @param interaxialDistance defines distance between each color axis
  39999. * @param scene defines the hosting scene
  40000. */
  40001. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40002. /**
  40003. * Gets camera class name
  40004. * @returns AnaglyphGamepadCamera
  40005. */
  40006. getClassName(): string;
  40007. }
  40008. }
  40009. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40010. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40011. import { Scene } from "babylonjs/scene";
  40012. import { Vector3 } from "babylonjs/Maths/math.vector";
  40013. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40014. /**
  40015. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40016. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40017. */
  40018. export class AnaglyphUniversalCamera extends UniversalCamera {
  40019. /**
  40020. * Creates a new AnaglyphUniversalCamera
  40021. * @param name defines camera name
  40022. * @param position defines initial position
  40023. * @param interaxialDistance defines distance between each color axis
  40024. * @param scene defines the hosting scene
  40025. */
  40026. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40027. /**
  40028. * Gets camera class name
  40029. * @returns AnaglyphUniversalCamera
  40030. */
  40031. getClassName(): string;
  40032. }
  40033. }
  40034. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40035. /** @hidden */
  40036. export var stereoscopicInterlacePixelShader: {
  40037. name: string;
  40038. shader: string;
  40039. };
  40040. }
  40041. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40042. import { Camera } from "babylonjs/Cameras/camera";
  40043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40044. import { Engine } from "babylonjs/Engines/engine";
  40045. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40046. /**
  40047. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40048. */
  40049. export class StereoscopicInterlacePostProcess extends PostProcess {
  40050. private _stepSize;
  40051. private _passedProcess;
  40052. /**
  40053. * Initializes a StereoscopicInterlacePostProcess
  40054. * @param name The name of the effect.
  40055. * @param rigCameras The rig cameras to be appled to the post process
  40056. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40058. * @param engine The engine which the post process will be applied. (default: current engine)
  40059. * @param reusable If the post process can be reused on the same frame. (default: false)
  40060. */
  40061. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40062. }
  40063. }
  40064. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40065. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40066. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40067. import { Scene } from "babylonjs/scene";
  40068. import { Vector3 } from "babylonjs/Maths/math.vector";
  40069. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40070. /**
  40071. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40072. * @see http://doc.babylonjs.com/features/cameras
  40073. */
  40074. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40075. /**
  40076. * Creates a new StereoscopicArcRotateCamera
  40077. * @param name defines camera name
  40078. * @param alpha defines alpha angle (in radians)
  40079. * @param beta defines beta angle (in radians)
  40080. * @param radius defines radius
  40081. * @param target defines camera target
  40082. * @param interaxialDistance defines distance between each color axis
  40083. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40084. * @param scene defines the hosting scene
  40085. */
  40086. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40087. /**
  40088. * Gets camera class name
  40089. * @returns StereoscopicArcRotateCamera
  40090. */
  40091. getClassName(): string;
  40092. }
  40093. }
  40094. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40095. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40096. import { Scene } from "babylonjs/scene";
  40097. import { Vector3 } from "babylonjs/Maths/math.vector";
  40098. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40099. /**
  40100. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40101. * @see http://doc.babylonjs.com/features/cameras
  40102. */
  40103. export class StereoscopicFreeCamera extends FreeCamera {
  40104. /**
  40105. * Creates a new StereoscopicFreeCamera
  40106. * @param name defines camera name
  40107. * @param position defines initial position
  40108. * @param interaxialDistance defines distance between each color axis
  40109. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40110. * @param scene defines the hosting scene
  40111. */
  40112. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40113. /**
  40114. * Gets camera class name
  40115. * @returns StereoscopicFreeCamera
  40116. */
  40117. getClassName(): string;
  40118. }
  40119. }
  40120. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40121. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40122. import { Scene } from "babylonjs/scene";
  40123. import { Vector3 } from "babylonjs/Maths/math.vector";
  40124. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40125. /**
  40126. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40127. * @see http://doc.babylonjs.com/features/cameras
  40128. */
  40129. export class StereoscopicGamepadCamera extends GamepadCamera {
  40130. /**
  40131. * Creates a new StereoscopicGamepadCamera
  40132. * @param name defines camera name
  40133. * @param position defines initial position
  40134. * @param interaxialDistance defines distance between each color axis
  40135. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40136. * @param scene defines the hosting scene
  40137. */
  40138. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40139. /**
  40140. * Gets camera class name
  40141. * @returns StereoscopicGamepadCamera
  40142. */
  40143. getClassName(): string;
  40144. }
  40145. }
  40146. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40147. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40148. import { Scene } from "babylonjs/scene";
  40149. import { Vector3 } from "babylonjs/Maths/math.vector";
  40150. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40151. /**
  40152. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40153. * @see http://doc.babylonjs.com/features/cameras
  40154. */
  40155. export class StereoscopicUniversalCamera extends UniversalCamera {
  40156. /**
  40157. * Creates a new StereoscopicUniversalCamera
  40158. * @param name defines camera name
  40159. * @param position defines initial position
  40160. * @param interaxialDistance defines distance between each color axis
  40161. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40162. * @param scene defines the hosting scene
  40163. */
  40164. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40165. /**
  40166. * Gets camera class name
  40167. * @returns StereoscopicUniversalCamera
  40168. */
  40169. getClassName(): string;
  40170. }
  40171. }
  40172. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40173. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40174. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40175. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40176. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40177. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40178. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40179. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40180. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40181. }
  40182. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40183. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40184. import { Scene } from "babylonjs/scene";
  40185. import { Vector3 } from "babylonjs/Maths/math.vector";
  40186. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40187. /**
  40188. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40189. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40190. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40191. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40192. */
  40193. export class VirtualJoysticksCamera extends FreeCamera {
  40194. /**
  40195. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40196. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40197. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40198. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40199. * @param name Define the name of the camera in the scene
  40200. * @param position Define the start position of the camera in the scene
  40201. * @param scene Define the scene the camera belongs to
  40202. */
  40203. constructor(name: string, position: Vector3, scene: Scene);
  40204. /**
  40205. * Gets the current object class name.
  40206. * @return the class name
  40207. */
  40208. getClassName(): string;
  40209. }
  40210. }
  40211. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40212. import { Matrix } from "babylonjs/Maths/math.vector";
  40213. /**
  40214. * This represents all the required metrics to create a VR camera.
  40215. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40216. */
  40217. export class VRCameraMetrics {
  40218. /**
  40219. * Define the horizontal resolution off the screen.
  40220. */
  40221. hResolution: number;
  40222. /**
  40223. * Define the vertical resolution off the screen.
  40224. */
  40225. vResolution: number;
  40226. /**
  40227. * Define the horizontal screen size.
  40228. */
  40229. hScreenSize: number;
  40230. /**
  40231. * Define the vertical screen size.
  40232. */
  40233. vScreenSize: number;
  40234. /**
  40235. * Define the vertical screen center position.
  40236. */
  40237. vScreenCenter: number;
  40238. /**
  40239. * Define the distance of the eyes to the screen.
  40240. */
  40241. eyeToScreenDistance: number;
  40242. /**
  40243. * Define the distance between both lenses
  40244. */
  40245. lensSeparationDistance: number;
  40246. /**
  40247. * Define the distance between both viewer's eyes.
  40248. */
  40249. interpupillaryDistance: number;
  40250. /**
  40251. * Define the distortion factor of the VR postprocess.
  40252. * Please, touch with care.
  40253. */
  40254. distortionK: number[];
  40255. /**
  40256. * Define the chromatic aberration correction factors for the VR post process.
  40257. */
  40258. chromaAbCorrection: number[];
  40259. /**
  40260. * Define the scale factor of the post process.
  40261. * The smaller the better but the slower.
  40262. */
  40263. postProcessScaleFactor: number;
  40264. /**
  40265. * Define an offset for the lens center.
  40266. */
  40267. lensCenterOffset: number;
  40268. /**
  40269. * Define if the current vr camera should compensate the distortion of the lense or not.
  40270. */
  40271. compensateDistortion: boolean;
  40272. /**
  40273. * Defines if multiview should be enabled when rendering (Default: false)
  40274. */
  40275. multiviewEnabled: boolean;
  40276. /**
  40277. * Gets the rendering aspect ratio based on the provided resolutions.
  40278. */
  40279. readonly aspectRatio: number;
  40280. /**
  40281. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40282. */
  40283. readonly aspectRatioFov: number;
  40284. /**
  40285. * @hidden
  40286. */
  40287. readonly leftHMatrix: Matrix;
  40288. /**
  40289. * @hidden
  40290. */
  40291. readonly rightHMatrix: Matrix;
  40292. /**
  40293. * @hidden
  40294. */
  40295. readonly leftPreViewMatrix: Matrix;
  40296. /**
  40297. * @hidden
  40298. */
  40299. readonly rightPreViewMatrix: Matrix;
  40300. /**
  40301. * Get the default VRMetrics based on the most generic setup.
  40302. * @returns the default vr metrics
  40303. */
  40304. static GetDefault(): VRCameraMetrics;
  40305. }
  40306. }
  40307. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40308. /** @hidden */
  40309. export var vrDistortionCorrectionPixelShader: {
  40310. name: string;
  40311. shader: string;
  40312. };
  40313. }
  40314. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40315. import { Camera } from "babylonjs/Cameras/camera";
  40316. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40318. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40319. /**
  40320. * VRDistortionCorrectionPostProcess used for mobile VR
  40321. */
  40322. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40323. private _isRightEye;
  40324. private _distortionFactors;
  40325. private _postProcessScaleFactor;
  40326. private _lensCenterOffset;
  40327. private _scaleIn;
  40328. private _scaleFactor;
  40329. private _lensCenter;
  40330. /**
  40331. * Initializes the VRDistortionCorrectionPostProcess
  40332. * @param name The name of the effect.
  40333. * @param camera The camera to apply the render pass to.
  40334. * @param isRightEye If this is for the right eye distortion
  40335. * @param vrMetrics All the required metrics for the VR camera
  40336. */
  40337. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40338. }
  40339. }
  40340. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40341. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40342. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40343. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40344. import { Scene } from "babylonjs/scene";
  40345. import { Vector3 } from "babylonjs/Maths/math.vector";
  40346. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40347. import "babylonjs/Cameras/RigModes/vrRigMode";
  40348. /**
  40349. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40350. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40351. */
  40352. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40353. /**
  40354. * Creates a new VRDeviceOrientationArcRotateCamera
  40355. * @param name defines camera name
  40356. * @param alpha defines the camera rotation along the logitudinal axis
  40357. * @param beta defines the camera rotation along the latitudinal axis
  40358. * @param radius defines the camera distance from its target
  40359. * @param target defines the camera target
  40360. * @param scene defines the scene the camera belongs to
  40361. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40362. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40363. */
  40364. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40365. /**
  40366. * Gets camera class name
  40367. * @returns VRDeviceOrientationArcRotateCamera
  40368. */
  40369. getClassName(): string;
  40370. }
  40371. }
  40372. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40373. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40374. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40375. import { Scene } from "babylonjs/scene";
  40376. import { Vector3 } from "babylonjs/Maths/math.vector";
  40377. import "babylonjs/Cameras/RigModes/vrRigMode";
  40378. /**
  40379. * Camera used to simulate VR rendering (based on FreeCamera)
  40380. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40381. */
  40382. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40383. /**
  40384. * Creates a new VRDeviceOrientationFreeCamera
  40385. * @param name defines camera name
  40386. * @param position defines the start position of the camera
  40387. * @param scene defines the scene the camera belongs to
  40388. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40389. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40390. */
  40391. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40392. /**
  40393. * Gets camera class name
  40394. * @returns VRDeviceOrientationFreeCamera
  40395. */
  40396. getClassName(): string;
  40397. }
  40398. }
  40399. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40400. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40401. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40402. import { Scene } from "babylonjs/scene";
  40403. import { Vector3 } from "babylonjs/Maths/math.vector";
  40404. import "babylonjs/Gamepads/gamepadSceneComponent";
  40405. /**
  40406. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40407. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40408. */
  40409. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40410. /**
  40411. * Creates a new VRDeviceOrientationGamepadCamera
  40412. * @param name defines camera name
  40413. * @param position defines the start position of the camera
  40414. * @param scene defines the scene the camera belongs to
  40415. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40416. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40417. */
  40418. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40419. /**
  40420. * Gets camera class name
  40421. * @returns VRDeviceOrientationGamepadCamera
  40422. */
  40423. getClassName(): string;
  40424. }
  40425. }
  40426. declare module "babylonjs/Materials/pushMaterial" {
  40427. import { Nullable } from "babylonjs/types";
  40428. import { Scene } from "babylonjs/scene";
  40429. import { Matrix } from "babylonjs/Maths/math.vector";
  40430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40431. import { Mesh } from "babylonjs/Meshes/mesh";
  40432. import { Material } from "babylonjs/Materials/material";
  40433. import { Effect } from "babylonjs/Materials/effect";
  40434. /**
  40435. * Base class of materials working in push mode in babylon JS
  40436. * @hidden
  40437. */
  40438. export class PushMaterial extends Material {
  40439. protected _activeEffect: Effect;
  40440. protected _normalMatrix: Matrix;
  40441. /**
  40442. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40443. * This means that the material can keep using a previous shader while a new one is being compiled.
  40444. * This is mostly used when shader parallel compilation is supported (true by default)
  40445. */
  40446. allowShaderHotSwapping: boolean;
  40447. constructor(name: string, scene: Scene);
  40448. getEffect(): Effect;
  40449. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40450. /**
  40451. * Binds the given world matrix to the active effect
  40452. *
  40453. * @param world the matrix to bind
  40454. */
  40455. bindOnlyWorldMatrix(world: Matrix): void;
  40456. /**
  40457. * Binds the given normal matrix to the active effect
  40458. *
  40459. * @param normalMatrix the matrix to bind
  40460. */
  40461. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40462. bind(world: Matrix, mesh?: Mesh): void;
  40463. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40464. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40465. }
  40466. }
  40467. declare module "babylonjs/Materials/materialFlags" {
  40468. /**
  40469. * This groups all the flags used to control the materials channel.
  40470. */
  40471. export class MaterialFlags {
  40472. private static _DiffuseTextureEnabled;
  40473. /**
  40474. * Are diffuse textures enabled in the application.
  40475. */
  40476. static DiffuseTextureEnabled: boolean;
  40477. private static _AmbientTextureEnabled;
  40478. /**
  40479. * Are ambient textures enabled in the application.
  40480. */
  40481. static AmbientTextureEnabled: boolean;
  40482. private static _OpacityTextureEnabled;
  40483. /**
  40484. * Are opacity textures enabled in the application.
  40485. */
  40486. static OpacityTextureEnabled: boolean;
  40487. private static _ReflectionTextureEnabled;
  40488. /**
  40489. * Are reflection textures enabled in the application.
  40490. */
  40491. static ReflectionTextureEnabled: boolean;
  40492. private static _EmissiveTextureEnabled;
  40493. /**
  40494. * Are emissive textures enabled in the application.
  40495. */
  40496. static EmissiveTextureEnabled: boolean;
  40497. private static _SpecularTextureEnabled;
  40498. /**
  40499. * Are specular textures enabled in the application.
  40500. */
  40501. static SpecularTextureEnabled: boolean;
  40502. private static _BumpTextureEnabled;
  40503. /**
  40504. * Are bump textures enabled in the application.
  40505. */
  40506. static BumpTextureEnabled: boolean;
  40507. private static _LightmapTextureEnabled;
  40508. /**
  40509. * Are lightmap textures enabled in the application.
  40510. */
  40511. static LightmapTextureEnabled: boolean;
  40512. private static _RefractionTextureEnabled;
  40513. /**
  40514. * Are refraction textures enabled in the application.
  40515. */
  40516. static RefractionTextureEnabled: boolean;
  40517. private static _ColorGradingTextureEnabled;
  40518. /**
  40519. * Are color grading textures enabled in the application.
  40520. */
  40521. static ColorGradingTextureEnabled: boolean;
  40522. private static _FresnelEnabled;
  40523. /**
  40524. * Are fresnels enabled in the application.
  40525. */
  40526. static FresnelEnabled: boolean;
  40527. private static _ClearCoatTextureEnabled;
  40528. /**
  40529. * Are clear coat textures enabled in the application.
  40530. */
  40531. static ClearCoatTextureEnabled: boolean;
  40532. private static _ClearCoatBumpTextureEnabled;
  40533. /**
  40534. * Are clear coat bump textures enabled in the application.
  40535. */
  40536. static ClearCoatBumpTextureEnabled: boolean;
  40537. private static _ClearCoatTintTextureEnabled;
  40538. /**
  40539. * Are clear coat tint textures enabled in the application.
  40540. */
  40541. static ClearCoatTintTextureEnabled: boolean;
  40542. private static _SheenTextureEnabled;
  40543. /**
  40544. * Are sheen textures enabled in the application.
  40545. */
  40546. static SheenTextureEnabled: boolean;
  40547. private static _AnisotropicTextureEnabled;
  40548. /**
  40549. * Are anisotropic textures enabled in the application.
  40550. */
  40551. static AnisotropicTextureEnabled: boolean;
  40552. private static _ThicknessTextureEnabled;
  40553. /**
  40554. * Are thickness textures enabled in the application.
  40555. */
  40556. static ThicknessTextureEnabled: boolean;
  40557. }
  40558. }
  40559. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40560. /** @hidden */
  40561. export var defaultFragmentDeclaration: {
  40562. name: string;
  40563. shader: string;
  40564. };
  40565. }
  40566. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40567. /** @hidden */
  40568. export var defaultUboDeclaration: {
  40569. name: string;
  40570. shader: string;
  40571. };
  40572. }
  40573. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40574. /** @hidden */
  40575. export var lightFragmentDeclaration: {
  40576. name: string;
  40577. shader: string;
  40578. };
  40579. }
  40580. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40581. /** @hidden */
  40582. export var lightUboDeclaration: {
  40583. name: string;
  40584. shader: string;
  40585. };
  40586. }
  40587. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40588. /** @hidden */
  40589. export var lightsFragmentFunctions: {
  40590. name: string;
  40591. shader: string;
  40592. };
  40593. }
  40594. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40595. /** @hidden */
  40596. export var shadowsFragmentFunctions: {
  40597. name: string;
  40598. shader: string;
  40599. };
  40600. }
  40601. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40602. /** @hidden */
  40603. export var fresnelFunction: {
  40604. name: string;
  40605. shader: string;
  40606. };
  40607. }
  40608. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40609. /** @hidden */
  40610. export var reflectionFunction: {
  40611. name: string;
  40612. shader: string;
  40613. };
  40614. }
  40615. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40616. /** @hidden */
  40617. export var bumpFragmentFunctions: {
  40618. name: string;
  40619. shader: string;
  40620. };
  40621. }
  40622. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40623. /** @hidden */
  40624. export var logDepthDeclaration: {
  40625. name: string;
  40626. shader: string;
  40627. };
  40628. }
  40629. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40630. /** @hidden */
  40631. export var bumpFragment: {
  40632. name: string;
  40633. shader: string;
  40634. };
  40635. }
  40636. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40637. /** @hidden */
  40638. export var depthPrePass: {
  40639. name: string;
  40640. shader: string;
  40641. };
  40642. }
  40643. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40644. /** @hidden */
  40645. export var lightFragment: {
  40646. name: string;
  40647. shader: string;
  40648. };
  40649. }
  40650. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40651. /** @hidden */
  40652. export var logDepthFragment: {
  40653. name: string;
  40654. shader: string;
  40655. };
  40656. }
  40657. declare module "babylonjs/Shaders/default.fragment" {
  40658. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40659. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40660. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40661. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40662. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40663. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40664. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40665. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40666. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40667. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40668. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40669. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40670. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40671. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40672. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40673. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40674. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40675. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40676. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40677. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40678. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40679. /** @hidden */
  40680. export var defaultPixelShader: {
  40681. name: string;
  40682. shader: string;
  40683. };
  40684. }
  40685. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40686. /** @hidden */
  40687. export var defaultVertexDeclaration: {
  40688. name: string;
  40689. shader: string;
  40690. };
  40691. }
  40692. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40693. /** @hidden */
  40694. export var bumpVertexDeclaration: {
  40695. name: string;
  40696. shader: string;
  40697. };
  40698. }
  40699. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40700. /** @hidden */
  40701. export var bumpVertex: {
  40702. name: string;
  40703. shader: string;
  40704. };
  40705. }
  40706. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40707. /** @hidden */
  40708. export var fogVertex: {
  40709. name: string;
  40710. shader: string;
  40711. };
  40712. }
  40713. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40714. /** @hidden */
  40715. export var shadowsVertex: {
  40716. name: string;
  40717. shader: string;
  40718. };
  40719. }
  40720. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40721. /** @hidden */
  40722. export var pointCloudVertex: {
  40723. name: string;
  40724. shader: string;
  40725. };
  40726. }
  40727. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40728. /** @hidden */
  40729. export var logDepthVertex: {
  40730. name: string;
  40731. shader: string;
  40732. };
  40733. }
  40734. declare module "babylonjs/Shaders/default.vertex" {
  40735. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40736. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40737. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40738. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40739. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40740. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40741. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40742. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40743. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40744. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40745. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40747. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40748. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40749. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40750. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40751. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40752. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40753. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40754. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40755. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40756. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40757. /** @hidden */
  40758. export var defaultVertexShader: {
  40759. name: string;
  40760. shader: string;
  40761. };
  40762. }
  40763. declare module "babylonjs/Materials/standardMaterial" {
  40764. import { SmartArray } from "babylonjs/Misc/smartArray";
  40765. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40766. import { Nullable } from "babylonjs/types";
  40767. import { Scene } from "babylonjs/scene";
  40768. import { Matrix } from "babylonjs/Maths/math.vector";
  40769. import { Color3 } from "babylonjs/Maths/math.color";
  40770. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40772. import { Mesh } from "babylonjs/Meshes/mesh";
  40773. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40774. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40775. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40776. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40777. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40778. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40779. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40780. import "babylonjs/Shaders/default.fragment";
  40781. import "babylonjs/Shaders/default.vertex";
  40782. /** @hidden */
  40783. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40784. MAINUV1: boolean;
  40785. MAINUV2: boolean;
  40786. DIFFUSE: boolean;
  40787. DIFFUSEDIRECTUV: number;
  40788. AMBIENT: boolean;
  40789. AMBIENTDIRECTUV: number;
  40790. OPACITY: boolean;
  40791. OPACITYDIRECTUV: number;
  40792. OPACITYRGB: boolean;
  40793. REFLECTION: boolean;
  40794. EMISSIVE: boolean;
  40795. EMISSIVEDIRECTUV: number;
  40796. SPECULAR: boolean;
  40797. SPECULARDIRECTUV: number;
  40798. BUMP: boolean;
  40799. BUMPDIRECTUV: number;
  40800. PARALLAX: boolean;
  40801. PARALLAXOCCLUSION: boolean;
  40802. SPECULAROVERALPHA: boolean;
  40803. CLIPPLANE: boolean;
  40804. CLIPPLANE2: boolean;
  40805. CLIPPLANE3: boolean;
  40806. CLIPPLANE4: boolean;
  40807. ALPHATEST: boolean;
  40808. DEPTHPREPASS: boolean;
  40809. ALPHAFROMDIFFUSE: boolean;
  40810. POINTSIZE: boolean;
  40811. FOG: boolean;
  40812. SPECULARTERM: boolean;
  40813. DIFFUSEFRESNEL: boolean;
  40814. OPACITYFRESNEL: boolean;
  40815. REFLECTIONFRESNEL: boolean;
  40816. REFRACTIONFRESNEL: boolean;
  40817. EMISSIVEFRESNEL: boolean;
  40818. FRESNEL: boolean;
  40819. NORMAL: boolean;
  40820. UV1: boolean;
  40821. UV2: boolean;
  40822. VERTEXCOLOR: boolean;
  40823. VERTEXALPHA: boolean;
  40824. NUM_BONE_INFLUENCERS: number;
  40825. BonesPerMesh: number;
  40826. BONETEXTURE: boolean;
  40827. INSTANCES: boolean;
  40828. GLOSSINESS: boolean;
  40829. ROUGHNESS: boolean;
  40830. EMISSIVEASILLUMINATION: boolean;
  40831. LINKEMISSIVEWITHDIFFUSE: boolean;
  40832. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40833. LIGHTMAP: boolean;
  40834. LIGHTMAPDIRECTUV: number;
  40835. OBJECTSPACE_NORMALMAP: boolean;
  40836. USELIGHTMAPASSHADOWMAP: boolean;
  40837. REFLECTIONMAP_3D: boolean;
  40838. REFLECTIONMAP_SPHERICAL: boolean;
  40839. REFLECTIONMAP_PLANAR: boolean;
  40840. REFLECTIONMAP_CUBIC: boolean;
  40841. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40842. REFLECTIONMAP_PROJECTION: boolean;
  40843. REFLECTIONMAP_SKYBOX: boolean;
  40844. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40845. REFLECTIONMAP_EXPLICIT: boolean;
  40846. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40847. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40848. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40849. INVERTCUBICMAP: boolean;
  40850. LOGARITHMICDEPTH: boolean;
  40851. REFRACTION: boolean;
  40852. REFRACTIONMAP_3D: boolean;
  40853. REFLECTIONOVERALPHA: boolean;
  40854. TWOSIDEDLIGHTING: boolean;
  40855. SHADOWFLOAT: boolean;
  40856. MORPHTARGETS: boolean;
  40857. MORPHTARGETS_NORMAL: boolean;
  40858. MORPHTARGETS_TANGENT: boolean;
  40859. MORPHTARGETS_UV: boolean;
  40860. NUM_MORPH_INFLUENCERS: number;
  40861. NONUNIFORMSCALING: boolean;
  40862. PREMULTIPLYALPHA: boolean;
  40863. IMAGEPROCESSING: boolean;
  40864. VIGNETTE: boolean;
  40865. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40866. VIGNETTEBLENDMODEOPAQUE: boolean;
  40867. TONEMAPPING: boolean;
  40868. TONEMAPPING_ACES: boolean;
  40869. CONTRAST: boolean;
  40870. COLORCURVES: boolean;
  40871. COLORGRADING: boolean;
  40872. COLORGRADING3D: boolean;
  40873. SAMPLER3DGREENDEPTH: boolean;
  40874. SAMPLER3DBGRMAP: boolean;
  40875. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40876. MULTIVIEW: boolean;
  40877. /**
  40878. * If the reflection texture on this material is in linear color space
  40879. * @hidden
  40880. */
  40881. IS_REFLECTION_LINEAR: boolean;
  40882. /**
  40883. * If the refraction texture on this material is in linear color space
  40884. * @hidden
  40885. */
  40886. IS_REFRACTION_LINEAR: boolean;
  40887. EXPOSURE: boolean;
  40888. constructor();
  40889. setReflectionMode(modeToEnable: string): void;
  40890. }
  40891. /**
  40892. * This is the default material used in Babylon. It is the best trade off between quality
  40893. * and performances.
  40894. * @see http://doc.babylonjs.com/babylon101/materials
  40895. */
  40896. export class StandardMaterial extends PushMaterial {
  40897. private _diffuseTexture;
  40898. /**
  40899. * The basic texture of the material as viewed under a light.
  40900. */
  40901. diffuseTexture: Nullable<BaseTexture>;
  40902. private _ambientTexture;
  40903. /**
  40904. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40905. */
  40906. ambientTexture: Nullable<BaseTexture>;
  40907. private _opacityTexture;
  40908. /**
  40909. * Define the transparency of the material from a texture.
  40910. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40911. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40912. */
  40913. opacityTexture: Nullable<BaseTexture>;
  40914. private _reflectionTexture;
  40915. /**
  40916. * Define the texture used to display the reflection.
  40917. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40918. */
  40919. reflectionTexture: Nullable<BaseTexture>;
  40920. private _emissiveTexture;
  40921. /**
  40922. * Define texture of the material as if self lit.
  40923. * This will be mixed in the final result even in the absence of light.
  40924. */
  40925. emissiveTexture: Nullable<BaseTexture>;
  40926. private _specularTexture;
  40927. /**
  40928. * Define how the color and intensity of the highlight given by the light in the material.
  40929. */
  40930. specularTexture: Nullable<BaseTexture>;
  40931. private _bumpTexture;
  40932. /**
  40933. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40934. * 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.
  40935. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40936. */
  40937. bumpTexture: Nullable<BaseTexture>;
  40938. private _lightmapTexture;
  40939. /**
  40940. * Complex lighting can be computationally expensive to compute at runtime.
  40941. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40942. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40943. */
  40944. lightmapTexture: Nullable<BaseTexture>;
  40945. private _refractionTexture;
  40946. /**
  40947. * Define the texture used to display the refraction.
  40948. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40949. */
  40950. refractionTexture: Nullable<BaseTexture>;
  40951. /**
  40952. * The color of the material lit by the environmental background lighting.
  40953. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40954. */
  40955. ambientColor: Color3;
  40956. /**
  40957. * The basic color of the material as viewed under a light.
  40958. */
  40959. diffuseColor: Color3;
  40960. /**
  40961. * Define how the color and intensity of the highlight given by the light in the material.
  40962. */
  40963. specularColor: Color3;
  40964. /**
  40965. * Define the color of the material as if self lit.
  40966. * This will be mixed in the final result even in the absence of light.
  40967. */
  40968. emissiveColor: Color3;
  40969. /**
  40970. * Defines how sharp are the highlights in the material.
  40971. * The bigger the value the sharper giving a more glossy feeling to the result.
  40972. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40973. */
  40974. specularPower: number;
  40975. private _useAlphaFromDiffuseTexture;
  40976. /**
  40977. * Does the transparency come from the diffuse texture alpha channel.
  40978. */
  40979. useAlphaFromDiffuseTexture: boolean;
  40980. private _useEmissiveAsIllumination;
  40981. /**
  40982. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40983. */
  40984. useEmissiveAsIllumination: boolean;
  40985. private _linkEmissiveWithDiffuse;
  40986. /**
  40987. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40988. * the emissive level when the final color is close to one.
  40989. */
  40990. linkEmissiveWithDiffuse: boolean;
  40991. private _useSpecularOverAlpha;
  40992. /**
  40993. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40994. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40995. */
  40996. useSpecularOverAlpha: boolean;
  40997. private _useReflectionOverAlpha;
  40998. /**
  40999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41001. */
  41002. useReflectionOverAlpha: boolean;
  41003. private _disableLighting;
  41004. /**
  41005. * Does lights from the scene impacts this material.
  41006. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41007. */
  41008. disableLighting: boolean;
  41009. private _useObjectSpaceNormalMap;
  41010. /**
  41011. * Allows using an object space normal map (instead of tangent space).
  41012. */
  41013. useObjectSpaceNormalMap: boolean;
  41014. private _useParallax;
  41015. /**
  41016. * Is parallax enabled or not.
  41017. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41018. */
  41019. useParallax: boolean;
  41020. private _useParallaxOcclusion;
  41021. /**
  41022. * Is parallax occlusion enabled or not.
  41023. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41024. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41025. */
  41026. useParallaxOcclusion: boolean;
  41027. /**
  41028. * 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.
  41029. */
  41030. parallaxScaleBias: number;
  41031. private _roughness;
  41032. /**
  41033. * Helps to define how blurry the reflections should appears in the material.
  41034. */
  41035. roughness: number;
  41036. /**
  41037. * In case of refraction, define the value of the index of refraction.
  41038. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41039. */
  41040. indexOfRefraction: number;
  41041. /**
  41042. * Invert the refraction texture alongside the y axis.
  41043. * It can be useful with procedural textures or probe for instance.
  41044. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41045. */
  41046. invertRefractionY: boolean;
  41047. /**
  41048. * Defines the alpha limits in alpha test mode.
  41049. */
  41050. alphaCutOff: number;
  41051. private _useLightmapAsShadowmap;
  41052. /**
  41053. * In case of light mapping, define whether the map contains light or shadow informations.
  41054. */
  41055. useLightmapAsShadowmap: boolean;
  41056. private _diffuseFresnelParameters;
  41057. /**
  41058. * Define the diffuse fresnel parameters of the material.
  41059. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41060. */
  41061. diffuseFresnelParameters: FresnelParameters;
  41062. private _opacityFresnelParameters;
  41063. /**
  41064. * Define the opacity fresnel parameters of the material.
  41065. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41066. */
  41067. opacityFresnelParameters: FresnelParameters;
  41068. private _reflectionFresnelParameters;
  41069. /**
  41070. * Define the reflection fresnel parameters of the material.
  41071. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41072. */
  41073. reflectionFresnelParameters: FresnelParameters;
  41074. private _refractionFresnelParameters;
  41075. /**
  41076. * Define the refraction fresnel parameters of the material.
  41077. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41078. */
  41079. refractionFresnelParameters: FresnelParameters;
  41080. private _emissiveFresnelParameters;
  41081. /**
  41082. * Define the emissive fresnel parameters of the material.
  41083. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41084. */
  41085. emissiveFresnelParameters: FresnelParameters;
  41086. private _useReflectionFresnelFromSpecular;
  41087. /**
  41088. * If true automatically deducts the fresnels values from the material specularity.
  41089. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41090. */
  41091. useReflectionFresnelFromSpecular: boolean;
  41092. private _useGlossinessFromSpecularMapAlpha;
  41093. /**
  41094. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41095. */
  41096. useGlossinessFromSpecularMapAlpha: boolean;
  41097. private _maxSimultaneousLights;
  41098. /**
  41099. * Defines the maximum number of lights that can be used in the material
  41100. */
  41101. maxSimultaneousLights: number;
  41102. private _invertNormalMapX;
  41103. /**
  41104. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41105. */
  41106. invertNormalMapX: boolean;
  41107. private _invertNormalMapY;
  41108. /**
  41109. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41110. */
  41111. invertNormalMapY: boolean;
  41112. private _twoSidedLighting;
  41113. /**
  41114. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41115. */
  41116. twoSidedLighting: boolean;
  41117. /**
  41118. * Default configuration related to image processing available in the standard Material.
  41119. */
  41120. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41121. /**
  41122. * Gets the image processing configuration used either in this material.
  41123. */
  41124. /**
  41125. * Sets the Default image processing configuration used either in the this material.
  41126. *
  41127. * If sets to null, the scene one is in use.
  41128. */
  41129. imageProcessingConfiguration: ImageProcessingConfiguration;
  41130. /**
  41131. * Keep track of the image processing observer to allow dispose and replace.
  41132. */
  41133. private _imageProcessingObserver;
  41134. /**
  41135. * Attaches a new image processing configuration to the Standard Material.
  41136. * @param configuration
  41137. */
  41138. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41139. /**
  41140. * Gets wether the color curves effect is enabled.
  41141. */
  41142. /**
  41143. * Sets wether the color curves effect is enabled.
  41144. */
  41145. cameraColorCurvesEnabled: boolean;
  41146. /**
  41147. * Gets wether the color grading effect is enabled.
  41148. */
  41149. /**
  41150. * Gets wether the color grading effect is enabled.
  41151. */
  41152. cameraColorGradingEnabled: boolean;
  41153. /**
  41154. * Gets wether tonemapping is enabled or not.
  41155. */
  41156. /**
  41157. * Sets wether tonemapping is enabled or not
  41158. */
  41159. cameraToneMappingEnabled: boolean;
  41160. /**
  41161. * The camera exposure used on this material.
  41162. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41163. * This corresponds to a photographic exposure.
  41164. */
  41165. /**
  41166. * The camera exposure used on this material.
  41167. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41168. * This corresponds to a photographic exposure.
  41169. */
  41170. cameraExposure: number;
  41171. /**
  41172. * Gets The camera contrast used on this material.
  41173. */
  41174. /**
  41175. * Sets The camera contrast used on this material.
  41176. */
  41177. cameraContrast: number;
  41178. /**
  41179. * Gets the Color Grading 2D Lookup Texture.
  41180. */
  41181. /**
  41182. * Sets the Color Grading 2D Lookup Texture.
  41183. */
  41184. cameraColorGradingTexture: Nullable<BaseTexture>;
  41185. /**
  41186. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41187. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41188. * 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;
  41189. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41190. */
  41191. /**
  41192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41194. * 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;
  41195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41196. */
  41197. cameraColorCurves: Nullable<ColorCurves>;
  41198. /**
  41199. * Custom callback helping to override the default shader used in the material.
  41200. */
  41201. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41202. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41203. protected _worldViewProjectionMatrix: Matrix;
  41204. protected _globalAmbientColor: Color3;
  41205. protected _useLogarithmicDepth: boolean;
  41206. /**
  41207. * Instantiates a new standard material.
  41208. * This is the default material used in Babylon. It is the best trade off between quality
  41209. * and performances.
  41210. * @see http://doc.babylonjs.com/babylon101/materials
  41211. * @param name Define the name of the material in the scene
  41212. * @param scene Define the scene the material belong to
  41213. */
  41214. constructor(name: string, scene: Scene);
  41215. /**
  41216. * Gets a boolean indicating that current material needs to register RTT
  41217. */
  41218. readonly hasRenderTargetTextures: boolean;
  41219. /**
  41220. * Gets the current class name of the material e.g. "StandardMaterial"
  41221. * Mainly use in serialization.
  41222. * @returns the class name
  41223. */
  41224. getClassName(): string;
  41225. /**
  41226. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41227. * You can try switching to logarithmic depth.
  41228. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41229. */
  41230. useLogarithmicDepth: boolean;
  41231. /**
  41232. * Specifies if the material will require alpha blending
  41233. * @returns a boolean specifying if alpha blending is needed
  41234. */
  41235. needAlphaBlending(): boolean;
  41236. /**
  41237. * Specifies if this material should be rendered in alpha test mode
  41238. * @returns a boolean specifying if an alpha test is needed.
  41239. */
  41240. needAlphaTesting(): boolean;
  41241. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41242. /**
  41243. * Get the texture used for alpha test purpose.
  41244. * @returns the diffuse texture in case of the standard material.
  41245. */
  41246. getAlphaTestTexture(): Nullable<BaseTexture>;
  41247. /**
  41248. * Get if the submesh is ready to be used and all its information available.
  41249. * Child classes can use it to update shaders
  41250. * @param mesh defines the mesh to check
  41251. * @param subMesh defines which submesh to check
  41252. * @param useInstances specifies that instances should be used
  41253. * @returns a boolean indicating that the submesh is ready or not
  41254. */
  41255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41256. /**
  41257. * Builds the material UBO layouts.
  41258. * Used internally during the effect preparation.
  41259. */
  41260. buildUniformLayout(): void;
  41261. /**
  41262. * Unbinds the material from the mesh
  41263. */
  41264. unbind(): void;
  41265. /**
  41266. * Binds the submesh to this material by preparing the effect and shader to draw
  41267. * @param world defines the world transformation matrix
  41268. * @param mesh defines the mesh containing the submesh
  41269. * @param subMesh defines the submesh to bind the material to
  41270. */
  41271. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41272. /**
  41273. * Get the list of animatables in the material.
  41274. * @returns the list of animatables object used in the material
  41275. */
  41276. getAnimatables(): IAnimatable[];
  41277. /**
  41278. * Gets the active textures from the material
  41279. * @returns an array of textures
  41280. */
  41281. getActiveTextures(): BaseTexture[];
  41282. /**
  41283. * Specifies if the material uses a texture
  41284. * @param texture defines the texture to check against the material
  41285. * @returns a boolean specifying if the material uses the texture
  41286. */
  41287. hasTexture(texture: BaseTexture): boolean;
  41288. /**
  41289. * Disposes the material
  41290. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41291. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41292. */
  41293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41294. /**
  41295. * Makes a duplicate of the material, and gives it a new name
  41296. * @param name defines the new name for the duplicated material
  41297. * @returns the cloned material
  41298. */
  41299. clone(name: string): StandardMaterial;
  41300. /**
  41301. * Serializes this material in a JSON representation
  41302. * @returns the serialized material object
  41303. */
  41304. serialize(): any;
  41305. /**
  41306. * Creates a standard material from parsed material data
  41307. * @param source defines the JSON representation of the material
  41308. * @param scene defines the hosting scene
  41309. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41310. * @returns a new standard material
  41311. */
  41312. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41313. /**
  41314. * Are diffuse textures enabled in the application.
  41315. */
  41316. static DiffuseTextureEnabled: boolean;
  41317. /**
  41318. * Are ambient textures enabled in the application.
  41319. */
  41320. static AmbientTextureEnabled: boolean;
  41321. /**
  41322. * Are opacity textures enabled in the application.
  41323. */
  41324. static OpacityTextureEnabled: boolean;
  41325. /**
  41326. * Are reflection textures enabled in the application.
  41327. */
  41328. static ReflectionTextureEnabled: boolean;
  41329. /**
  41330. * Are emissive textures enabled in the application.
  41331. */
  41332. static EmissiveTextureEnabled: boolean;
  41333. /**
  41334. * Are specular textures enabled in the application.
  41335. */
  41336. static SpecularTextureEnabled: boolean;
  41337. /**
  41338. * Are bump textures enabled in the application.
  41339. */
  41340. static BumpTextureEnabled: boolean;
  41341. /**
  41342. * Are lightmap textures enabled in the application.
  41343. */
  41344. static LightmapTextureEnabled: boolean;
  41345. /**
  41346. * Are refraction textures enabled in the application.
  41347. */
  41348. static RefractionTextureEnabled: boolean;
  41349. /**
  41350. * Are color grading textures enabled in the application.
  41351. */
  41352. static ColorGradingTextureEnabled: boolean;
  41353. /**
  41354. * Are fresnels enabled in the application.
  41355. */
  41356. static FresnelEnabled: boolean;
  41357. }
  41358. }
  41359. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41360. import { Scene } from "babylonjs/scene";
  41361. import { Texture } from "babylonjs/Materials/Textures/texture";
  41362. /**
  41363. * A class extending Texture allowing drawing on a texture
  41364. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41365. */
  41366. export class DynamicTexture extends Texture {
  41367. private _generateMipMaps;
  41368. private _canvas;
  41369. private _context;
  41370. private _engine;
  41371. /**
  41372. * Creates a DynamicTexture
  41373. * @param name defines the name of the texture
  41374. * @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
  41375. * @param scene defines the scene where you want the texture
  41376. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41377. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41378. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41379. */
  41380. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41381. /**
  41382. * Get the current class name of the texture useful for serialization or dynamic coding.
  41383. * @returns "DynamicTexture"
  41384. */
  41385. getClassName(): string;
  41386. /**
  41387. * Gets the current state of canRescale
  41388. */
  41389. readonly canRescale: boolean;
  41390. private _recreate;
  41391. /**
  41392. * Scales the texture
  41393. * @param ratio the scale factor to apply to both width and height
  41394. */
  41395. scale(ratio: number): void;
  41396. /**
  41397. * Resizes the texture
  41398. * @param width the new width
  41399. * @param height the new height
  41400. */
  41401. scaleTo(width: number, height: number): void;
  41402. /**
  41403. * Gets the context of the canvas used by the texture
  41404. * @returns the canvas context of the dynamic texture
  41405. */
  41406. getContext(): CanvasRenderingContext2D;
  41407. /**
  41408. * Clears the texture
  41409. */
  41410. clear(): void;
  41411. /**
  41412. * Updates the texture
  41413. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41414. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41415. */
  41416. update(invertY?: boolean, premulAlpha?: boolean): void;
  41417. /**
  41418. * Draws text onto the texture
  41419. * @param text defines the text to be drawn
  41420. * @param x defines the placement of the text from the left
  41421. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41422. * @param font defines the font to be used with font-style, font-size, font-name
  41423. * @param color defines the color used for the text
  41424. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41425. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41426. * @param update defines whether texture is immediately update (default is true)
  41427. */
  41428. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41429. /**
  41430. * Clones the texture
  41431. * @returns the clone of the texture.
  41432. */
  41433. clone(): DynamicTexture;
  41434. /**
  41435. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41436. * @returns a serialized dynamic texture object
  41437. */
  41438. serialize(): any;
  41439. /** @hidden */
  41440. _rebuild(): void;
  41441. }
  41442. }
  41443. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41444. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41445. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41446. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41447. /** @hidden */
  41448. export var imageProcessingPixelShader: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41454. import { Nullable } from "babylonjs/types";
  41455. import { Color4 } from "babylonjs/Maths/math.color";
  41456. import { Camera } from "babylonjs/Cameras/camera";
  41457. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41458. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41459. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41460. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41461. import { Engine } from "babylonjs/Engines/engine";
  41462. import "babylonjs/Shaders/imageProcessing.fragment";
  41463. import "babylonjs/Shaders/postprocess.vertex";
  41464. /**
  41465. * ImageProcessingPostProcess
  41466. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41467. */
  41468. export class ImageProcessingPostProcess extends PostProcess {
  41469. /**
  41470. * Default configuration related to image processing available in the PBR Material.
  41471. */
  41472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41473. /**
  41474. * Gets the image processing configuration used either in this material.
  41475. */
  41476. /**
  41477. * Sets the Default image processing configuration used either in the this material.
  41478. *
  41479. * If sets to null, the scene one is in use.
  41480. */
  41481. imageProcessingConfiguration: ImageProcessingConfiguration;
  41482. /**
  41483. * Keep track of the image processing observer to allow dispose and replace.
  41484. */
  41485. private _imageProcessingObserver;
  41486. /**
  41487. * Attaches a new image processing configuration to the PBR Material.
  41488. * @param configuration
  41489. */
  41490. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41491. /**
  41492. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41493. */
  41494. /**
  41495. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41496. */
  41497. colorCurves: Nullable<ColorCurves>;
  41498. /**
  41499. * Gets wether the color curves effect is enabled.
  41500. */
  41501. /**
  41502. * Sets wether the color curves effect is enabled.
  41503. */
  41504. colorCurvesEnabled: boolean;
  41505. /**
  41506. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41507. */
  41508. /**
  41509. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41510. */
  41511. colorGradingTexture: Nullable<BaseTexture>;
  41512. /**
  41513. * Gets wether the color grading effect is enabled.
  41514. */
  41515. /**
  41516. * Gets wether the color grading effect is enabled.
  41517. */
  41518. colorGradingEnabled: boolean;
  41519. /**
  41520. * Gets exposure used in the effect.
  41521. */
  41522. /**
  41523. * Sets exposure used in the effect.
  41524. */
  41525. exposure: number;
  41526. /**
  41527. * Gets wether tonemapping is enabled or not.
  41528. */
  41529. /**
  41530. * Sets wether tonemapping is enabled or not
  41531. */
  41532. toneMappingEnabled: boolean;
  41533. /**
  41534. * Gets the type of tone mapping effect.
  41535. */
  41536. /**
  41537. * Sets the type of tone mapping effect.
  41538. */
  41539. toneMappingType: number;
  41540. /**
  41541. * Gets contrast used in the effect.
  41542. */
  41543. /**
  41544. * Sets contrast used in the effect.
  41545. */
  41546. contrast: number;
  41547. /**
  41548. * Gets Vignette stretch size.
  41549. */
  41550. /**
  41551. * Sets Vignette stretch size.
  41552. */
  41553. vignetteStretch: number;
  41554. /**
  41555. * Gets Vignette centre X Offset.
  41556. */
  41557. /**
  41558. * Sets Vignette centre X Offset.
  41559. */
  41560. vignetteCentreX: number;
  41561. /**
  41562. * Gets Vignette centre Y Offset.
  41563. */
  41564. /**
  41565. * Sets Vignette centre Y Offset.
  41566. */
  41567. vignetteCentreY: number;
  41568. /**
  41569. * Gets Vignette weight or intensity of the vignette effect.
  41570. */
  41571. /**
  41572. * Sets Vignette weight or intensity of the vignette effect.
  41573. */
  41574. vignetteWeight: number;
  41575. /**
  41576. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41577. * if vignetteEnabled is set to true.
  41578. */
  41579. /**
  41580. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41581. * if vignetteEnabled is set to true.
  41582. */
  41583. vignetteColor: Color4;
  41584. /**
  41585. * Gets Camera field of view used by the Vignette effect.
  41586. */
  41587. /**
  41588. * Sets Camera field of view used by the Vignette effect.
  41589. */
  41590. vignetteCameraFov: number;
  41591. /**
  41592. * Gets the vignette blend mode allowing different kind of effect.
  41593. */
  41594. /**
  41595. * Sets the vignette blend mode allowing different kind of effect.
  41596. */
  41597. vignetteBlendMode: number;
  41598. /**
  41599. * Gets wether the vignette effect is enabled.
  41600. */
  41601. /**
  41602. * Sets wether the vignette effect is enabled.
  41603. */
  41604. vignetteEnabled: boolean;
  41605. private _fromLinearSpace;
  41606. /**
  41607. * Gets wether the input of the processing is in Gamma or Linear Space.
  41608. */
  41609. /**
  41610. * Sets wether the input of the processing is in Gamma or Linear Space.
  41611. */
  41612. fromLinearSpace: boolean;
  41613. /**
  41614. * Defines cache preventing GC.
  41615. */
  41616. private _defines;
  41617. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41618. /**
  41619. * "ImageProcessingPostProcess"
  41620. * @returns "ImageProcessingPostProcess"
  41621. */
  41622. getClassName(): string;
  41623. protected _updateParameters(): void;
  41624. dispose(camera?: Camera): void;
  41625. }
  41626. }
  41627. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41628. import { Scene } from "babylonjs/scene";
  41629. import { Color3 } from "babylonjs/Maths/math.color";
  41630. import { Mesh } from "babylonjs/Meshes/mesh";
  41631. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41632. import { Nullable } from "babylonjs/types";
  41633. /**
  41634. * Class containing static functions to help procedurally build meshes
  41635. */
  41636. export class GroundBuilder {
  41637. /**
  41638. * Creates a ground mesh
  41639. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41640. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41642. * @param name defines the name of the mesh
  41643. * @param options defines the options used to create the mesh
  41644. * @param scene defines the hosting scene
  41645. * @returns the ground mesh
  41646. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41647. */
  41648. static CreateGround(name: string, options: {
  41649. width?: number;
  41650. height?: number;
  41651. subdivisions?: number;
  41652. subdivisionsX?: number;
  41653. subdivisionsY?: number;
  41654. updatable?: boolean;
  41655. }, scene: any): Mesh;
  41656. /**
  41657. * Creates a tiled ground mesh
  41658. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41659. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41660. * * 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
  41661. * * 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
  41662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41663. * @param name defines the name of the mesh
  41664. * @param options defines the options used to create the mesh
  41665. * @param scene defines the hosting scene
  41666. * @returns the tiled ground mesh
  41667. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41668. */
  41669. static CreateTiledGround(name: string, options: {
  41670. xmin: number;
  41671. zmin: number;
  41672. xmax: number;
  41673. zmax: number;
  41674. subdivisions?: {
  41675. w: number;
  41676. h: number;
  41677. };
  41678. precision?: {
  41679. w: number;
  41680. h: number;
  41681. };
  41682. updatable?: boolean;
  41683. }, scene?: Nullable<Scene>): Mesh;
  41684. /**
  41685. * Creates a ground mesh from a height map
  41686. * * The parameter `url` sets the URL of the height map image resource.
  41687. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41688. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41689. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41690. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41691. * * 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.
  41692. * * 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).
  41693. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41694. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41695. * @param name defines the name of the mesh
  41696. * @param url defines the url to the height map
  41697. * @param options defines the options used to create the mesh
  41698. * @param scene defines the hosting scene
  41699. * @returns the ground mesh
  41700. * @see https://doc.babylonjs.com/babylon101/height_map
  41701. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41702. */
  41703. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41704. width?: number;
  41705. height?: number;
  41706. subdivisions?: number;
  41707. minHeight?: number;
  41708. maxHeight?: number;
  41709. colorFilter?: Color3;
  41710. alphaFilter?: number;
  41711. updatable?: boolean;
  41712. onReady?: (mesh: GroundMesh) => void;
  41713. }, scene?: Nullable<Scene>): GroundMesh;
  41714. }
  41715. }
  41716. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41717. import { Vector4 } from "babylonjs/Maths/math.vector";
  41718. import { Mesh } from "babylonjs/Meshes/mesh";
  41719. /**
  41720. * Class containing static functions to help procedurally build meshes
  41721. */
  41722. export class TorusBuilder {
  41723. /**
  41724. * Creates a torus mesh
  41725. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41726. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41727. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41731. * @param name defines the name of the mesh
  41732. * @param options defines the options used to create the mesh
  41733. * @param scene defines the hosting scene
  41734. * @returns the torus mesh
  41735. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41736. */
  41737. static CreateTorus(name: string, options: {
  41738. diameter?: number;
  41739. thickness?: number;
  41740. tessellation?: number;
  41741. updatable?: boolean;
  41742. sideOrientation?: number;
  41743. frontUVs?: Vector4;
  41744. backUVs?: Vector4;
  41745. }, scene: any): Mesh;
  41746. }
  41747. }
  41748. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41749. import { Vector4 } from "babylonjs/Maths/math.vector";
  41750. import { Color4 } from "babylonjs/Maths/math.color";
  41751. import { Mesh } from "babylonjs/Meshes/mesh";
  41752. /**
  41753. * Class containing static functions to help procedurally build meshes
  41754. */
  41755. export class CylinderBuilder {
  41756. /**
  41757. * Creates a cylinder or a cone mesh
  41758. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41759. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41760. * * 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.
  41761. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41762. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41763. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41764. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41765. * * 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).
  41766. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41767. * * 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).
  41768. * * 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
  41769. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41770. * * 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
  41771. * * 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.
  41772. * * If `enclose` is false, a ring surface is one element.
  41773. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41774. * * 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
  41775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41778. * @param name defines the name of the mesh
  41779. * @param options defines the options used to create the mesh
  41780. * @param scene defines the hosting scene
  41781. * @returns the cylinder mesh
  41782. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41783. */
  41784. static CreateCylinder(name: string, options: {
  41785. height?: number;
  41786. diameterTop?: number;
  41787. diameterBottom?: number;
  41788. diameter?: number;
  41789. tessellation?: number;
  41790. subdivisions?: number;
  41791. arc?: number;
  41792. faceColors?: Color4[];
  41793. faceUV?: Vector4[];
  41794. updatable?: boolean;
  41795. hasRings?: boolean;
  41796. enclose?: boolean;
  41797. cap?: number;
  41798. sideOrientation?: number;
  41799. frontUVs?: Vector4;
  41800. backUVs?: Vector4;
  41801. }, scene: any): Mesh;
  41802. }
  41803. }
  41804. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41805. import { Observable } from "babylonjs/Misc/observable";
  41806. import { Nullable } from "babylonjs/types";
  41807. import { Camera } from "babylonjs/Cameras/camera";
  41808. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41809. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41810. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41811. import { Scene } from "babylonjs/scene";
  41812. import { Vector3 } from "babylonjs/Maths/math.vector";
  41813. import { Color3 } from "babylonjs/Maths/math.color";
  41814. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41816. import { Mesh } from "babylonjs/Meshes/mesh";
  41817. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41818. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41819. import "babylonjs/Meshes/Builders/groundBuilder";
  41820. import "babylonjs/Meshes/Builders/torusBuilder";
  41821. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41822. import "babylonjs/Gamepads/gamepadSceneComponent";
  41823. import "babylonjs/Animations/animatable";
  41824. /**
  41825. * Options to modify the vr teleportation behavior.
  41826. */
  41827. export interface VRTeleportationOptions {
  41828. /**
  41829. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41830. */
  41831. floorMeshName?: string;
  41832. /**
  41833. * A list of meshes to be used as the teleportation floor. (default: empty)
  41834. */
  41835. floorMeshes?: Mesh[];
  41836. }
  41837. /**
  41838. * Options to modify the vr experience helper's behavior.
  41839. */
  41840. export interface VRExperienceHelperOptions extends WebVROptions {
  41841. /**
  41842. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41843. */
  41844. createDeviceOrientationCamera?: boolean;
  41845. /**
  41846. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41847. */
  41848. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41849. /**
  41850. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41851. */
  41852. laserToggle?: boolean;
  41853. /**
  41854. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41855. */
  41856. floorMeshes?: Mesh[];
  41857. /**
  41858. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41859. */
  41860. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41861. }
  41862. /**
  41863. * Event containing information after VR has been entered
  41864. */
  41865. export class OnAfterEnteringVRObservableEvent {
  41866. /**
  41867. * If entering vr was successful
  41868. */
  41869. success: boolean;
  41870. }
  41871. /**
  41872. * Helps to quickly add VR support to an existing scene.
  41873. * See http://doc.babylonjs.com/how_to/webvr_helper
  41874. */
  41875. export class VRExperienceHelper {
  41876. /** Options to modify the vr experience helper's behavior. */
  41877. webVROptions: VRExperienceHelperOptions;
  41878. private _scene;
  41879. private _position;
  41880. private _btnVR;
  41881. private _btnVRDisplayed;
  41882. private _webVRsupported;
  41883. private _webVRready;
  41884. private _webVRrequesting;
  41885. private _webVRpresenting;
  41886. private _hasEnteredVR;
  41887. private _fullscreenVRpresenting;
  41888. private _canvas;
  41889. private _webVRCamera;
  41890. private _vrDeviceOrientationCamera;
  41891. private _deviceOrientationCamera;
  41892. private _existingCamera;
  41893. private _onKeyDown;
  41894. private _onVrDisplayPresentChange;
  41895. private _onVRDisplayChanged;
  41896. private _onVRRequestPresentStart;
  41897. private _onVRRequestPresentComplete;
  41898. /**
  41899. * 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)
  41900. */
  41901. enableGazeEvenWhenNoPointerLock: boolean;
  41902. /**
  41903. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41904. */
  41905. exitVROnDoubleTap: boolean;
  41906. /**
  41907. * Observable raised right before entering VR.
  41908. */
  41909. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41910. /**
  41911. * Observable raised when entering VR has completed.
  41912. */
  41913. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41914. /**
  41915. * Observable raised when exiting VR.
  41916. */
  41917. onExitingVRObservable: Observable<VRExperienceHelper>;
  41918. /**
  41919. * Observable raised when controller mesh is loaded.
  41920. */
  41921. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41922. /** Return this.onEnteringVRObservable
  41923. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41924. */
  41925. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41926. /** Return this.onExitingVRObservable
  41927. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41928. */
  41929. readonly onExitingVR: Observable<VRExperienceHelper>;
  41930. /** Return this.onControllerMeshLoadedObservable
  41931. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41932. */
  41933. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41934. private _rayLength;
  41935. private _useCustomVRButton;
  41936. private _teleportationRequested;
  41937. private _teleportActive;
  41938. private _floorMeshName;
  41939. private _floorMeshesCollection;
  41940. private _rotationAllowed;
  41941. private _teleportBackwardsVector;
  41942. private _teleportationTarget;
  41943. private _isDefaultTeleportationTarget;
  41944. private _postProcessMove;
  41945. private _teleportationFillColor;
  41946. private _teleportationBorderColor;
  41947. private _rotationAngle;
  41948. private _haloCenter;
  41949. private _cameraGazer;
  41950. private _padSensibilityUp;
  41951. private _padSensibilityDown;
  41952. private _leftController;
  41953. private _rightController;
  41954. /**
  41955. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41956. */
  41957. onNewMeshSelected: Observable<AbstractMesh>;
  41958. /**
  41959. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41960. */
  41961. onNewMeshPicked: Observable<PickingInfo>;
  41962. private _circleEase;
  41963. /**
  41964. * Observable raised before camera teleportation
  41965. */
  41966. onBeforeCameraTeleport: Observable<Vector3>;
  41967. /**
  41968. * Observable raised after camera teleportation
  41969. */
  41970. onAfterCameraTeleport: Observable<Vector3>;
  41971. /**
  41972. * Observable raised when current selected mesh gets unselected
  41973. */
  41974. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41975. private _raySelectionPredicate;
  41976. /**
  41977. * To be optionaly changed by user to define custom ray selection
  41978. */
  41979. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41980. /**
  41981. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41982. */
  41983. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41984. /**
  41985. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41986. */
  41987. teleportationEnabled: boolean;
  41988. private _defaultHeight;
  41989. private _teleportationInitialized;
  41990. private _interactionsEnabled;
  41991. private _interactionsRequested;
  41992. private _displayGaze;
  41993. private _displayLaserPointer;
  41994. /**
  41995. * The mesh used to display where the user is going to teleport.
  41996. */
  41997. /**
  41998. * Sets the mesh to be used to display where the user is going to teleport.
  41999. */
  42000. teleportationTarget: Mesh;
  42001. /**
  42002. * 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
  42003. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42004. * See http://doc.babylonjs.com/resources/baking_transformations
  42005. */
  42006. gazeTrackerMesh: Mesh;
  42007. /**
  42008. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42009. */
  42010. updateGazeTrackerScale: boolean;
  42011. /**
  42012. * If the gaze trackers color should be updated when selecting meshes
  42013. */
  42014. updateGazeTrackerColor: boolean;
  42015. /**
  42016. * The gaze tracking mesh corresponding to the left controller
  42017. */
  42018. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42019. /**
  42020. * The gaze tracking mesh corresponding to the right controller
  42021. */
  42022. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42023. /**
  42024. * If the ray of the gaze should be displayed.
  42025. */
  42026. /**
  42027. * Sets if the ray of the gaze should be displayed.
  42028. */
  42029. displayGaze: boolean;
  42030. /**
  42031. * If the ray of the LaserPointer should be displayed.
  42032. */
  42033. /**
  42034. * Sets if the ray of the LaserPointer should be displayed.
  42035. */
  42036. displayLaserPointer: boolean;
  42037. /**
  42038. * The deviceOrientationCamera used as the camera when not in VR.
  42039. */
  42040. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42041. /**
  42042. * Based on the current WebVR support, returns the current VR camera used.
  42043. */
  42044. readonly currentVRCamera: Nullable<Camera>;
  42045. /**
  42046. * The webVRCamera which is used when in VR.
  42047. */
  42048. readonly webVRCamera: WebVRFreeCamera;
  42049. /**
  42050. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42051. */
  42052. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42053. /**
  42054. * The html button that is used to trigger entering into VR.
  42055. */
  42056. readonly vrButton: Nullable<HTMLButtonElement>;
  42057. private readonly _teleportationRequestInitiated;
  42058. /**
  42059. * Defines wether or not Pointer lock should be requested when switching to
  42060. * full screen.
  42061. */
  42062. requestPointerLockOnFullScreen: boolean;
  42063. /**
  42064. * Instantiates a VRExperienceHelper.
  42065. * Helps to quickly add VR support to an existing scene.
  42066. * @param scene The scene the VRExperienceHelper belongs to.
  42067. * @param webVROptions Options to modify the vr experience helper's behavior.
  42068. */
  42069. constructor(scene: Scene,
  42070. /** Options to modify the vr experience helper's behavior. */
  42071. webVROptions?: VRExperienceHelperOptions);
  42072. private _onDefaultMeshLoaded;
  42073. private _onResize;
  42074. private _onFullscreenChange;
  42075. /**
  42076. * Gets a value indicating if we are currently in VR mode.
  42077. */
  42078. readonly isInVRMode: boolean;
  42079. private onVrDisplayPresentChange;
  42080. private onVRDisplayChanged;
  42081. private moveButtonToBottomRight;
  42082. private displayVRButton;
  42083. private updateButtonVisibility;
  42084. private _cachedAngularSensibility;
  42085. /**
  42086. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42087. * Otherwise, will use the fullscreen API.
  42088. */
  42089. enterVR(): void;
  42090. /**
  42091. * Attempt to exit VR, or fullscreen.
  42092. */
  42093. exitVR(): void;
  42094. /**
  42095. * The position of the vr experience helper.
  42096. */
  42097. /**
  42098. * Sets the position of the vr experience helper.
  42099. */
  42100. position: Vector3;
  42101. /**
  42102. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42103. */
  42104. enableInteractions(): void;
  42105. private readonly _noControllerIsActive;
  42106. private beforeRender;
  42107. private _isTeleportationFloor;
  42108. /**
  42109. * Adds a floor mesh to be used for teleportation.
  42110. * @param floorMesh the mesh to be used for teleportation.
  42111. */
  42112. addFloorMesh(floorMesh: Mesh): void;
  42113. /**
  42114. * Removes a floor mesh from being used for teleportation.
  42115. * @param floorMesh the mesh to be removed.
  42116. */
  42117. removeFloorMesh(floorMesh: Mesh): void;
  42118. /**
  42119. * Enables interactions and teleportation using the VR controllers and gaze.
  42120. * @param vrTeleportationOptions options to modify teleportation behavior.
  42121. */
  42122. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42123. private _onNewGamepadConnected;
  42124. private _tryEnableInteractionOnController;
  42125. private _onNewGamepadDisconnected;
  42126. private _enableInteractionOnController;
  42127. private _checkTeleportWithRay;
  42128. private _checkRotate;
  42129. private _checkTeleportBackwards;
  42130. private _enableTeleportationOnController;
  42131. private _createTeleportationCircles;
  42132. private _displayTeleportationTarget;
  42133. private _hideTeleportationTarget;
  42134. private _rotateCamera;
  42135. private _moveTeleportationSelectorTo;
  42136. private _workingVector;
  42137. private _workingQuaternion;
  42138. private _workingMatrix;
  42139. /**
  42140. * Teleports the users feet to the desired location
  42141. * @param location The location where the user's feet should be placed
  42142. */
  42143. teleportCamera(location: Vector3): void;
  42144. private _convertNormalToDirectionOfRay;
  42145. private _castRayAndSelectObject;
  42146. private _notifySelectedMeshUnselected;
  42147. /**
  42148. * Sets the color of the laser ray from the vr controllers.
  42149. * @param color new color for the ray.
  42150. */
  42151. changeLaserColor(color: Color3): void;
  42152. /**
  42153. * Sets the color of the ray from the vr headsets gaze.
  42154. * @param color new color for the ray.
  42155. */
  42156. changeGazeColor(color: Color3): void;
  42157. /**
  42158. * Exits VR and disposes of the vr experience helper
  42159. */
  42160. dispose(): void;
  42161. /**
  42162. * Gets the name of the VRExperienceHelper class
  42163. * @returns "VRExperienceHelper"
  42164. */
  42165. getClassName(): string;
  42166. }
  42167. }
  42168. declare module "babylonjs/Cameras/VR/index" {
  42169. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42170. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42171. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42172. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42173. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42174. export * from "babylonjs/Cameras/VR/webVRCamera";
  42175. }
  42176. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42177. import { Observable } from "babylonjs/Misc/observable";
  42178. import { Nullable } from "babylonjs/types";
  42179. import { IDisposable, Scene } from "babylonjs/scene";
  42180. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42181. /**
  42182. * Manages an XRSession to work with Babylon's engine
  42183. * @see https://doc.babylonjs.com/how_to/webxr
  42184. */
  42185. export class WebXRSessionManager implements IDisposable {
  42186. private scene;
  42187. /**
  42188. * Fires every time a new xrFrame arrives which can be used to update the camera
  42189. */
  42190. onXRFrameObservable: Observable<any>;
  42191. /**
  42192. * Fires when the xr session is ended either by the device or manually done
  42193. */
  42194. onXRSessionEnded: Observable<any>;
  42195. /**
  42196. * Underlying xr session
  42197. */
  42198. session: XRSession;
  42199. /**
  42200. * Type of reference space used when creating the session
  42201. */
  42202. referenceSpace: XRReferenceSpace;
  42203. /** @hidden */
  42204. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42205. /**
  42206. * Current XR frame
  42207. */
  42208. currentFrame: Nullable<XRFrame>;
  42209. private _xrNavigator;
  42210. private baseLayer;
  42211. /**
  42212. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42213. * @param scene The scene which the session should be created for
  42214. */
  42215. constructor(scene: Scene);
  42216. /**
  42217. * Initializes the manager
  42218. * After initialization enterXR can be called to start an XR session
  42219. * @returns Promise which resolves after it is initialized
  42220. */
  42221. initializeAsync(): Promise<void>;
  42222. /**
  42223. * Initializes an xr session
  42224. * @param xrSessionMode mode to initialize
  42225. * @returns a promise which will resolve once the session has been initialized
  42226. */
  42227. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42228. /**
  42229. * Sets the reference space on the xr session
  42230. * @param referenceSpace space to set
  42231. * @returns a promise that will resolve once the reference space has been set
  42232. */
  42233. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42234. /**
  42235. * Updates the render state of the session
  42236. * @param state state to set
  42237. * @returns a promise that resolves once the render state has been updated
  42238. */
  42239. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42240. /**
  42241. * Starts rendering to the xr layer
  42242. * @returns a promise that will resolve once rendering has started
  42243. */
  42244. startRenderingToXRAsync(): Promise<void>;
  42245. /**
  42246. * Stops the xrSession and restores the renderloop
  42247. * @returns Promise which resolves after it exits XR
  42248. */
  42249. exitXRAsync(): Promise<unknown>;
  42250. /**
  42251. * Checks if a session would be supported for the creation options specified
  42252. * @param sessionMode session mode to check if supported eg. immersive-vr
  42253. * @returns true if supported
  42254. */
  42255. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42256. /**
  42257. * @hidden
  42258. * Converts the render layer of xrSession to a render target
  42259. * @param session session to create render target for
  42260. * @param scene scene the new render target should be created for
  42261. */
  42262. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42263. /**
  42264. * Disposes of the session manager
  42265. */
  42266. dispose(): void;
  42267. }
  42268. }
  42269. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42270. import { Scene } from "babylonjs/scene";
  42271. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42272. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42273. /**
  42274. * WebXR Camera which holds the views for the xrSession
  42275. * @see https://doc.babylonjs.com/how_to/webxr
  42276. */
  42277. export class WebXRCamera extends FreeCamera {
  42278. private static _TmpMatrix;
  42279. /**
  42280. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42281. * @param name the name of the camera
  42282. * @param scene the scene to add the camera to
  42283. */
  42284. constructor(name: string, scene: Scene);
  42285. private _updateNumberOfRigCameras;
  42286. /** @hidden */
  42287. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42288. /**
  42289. * Updates the cameras position from the current pose information of the XR session
  42290. * @param xrSessionManager the session containing pose information
  42291. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42292. */
  42293. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42294. }
  42295. }
  42296. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42297. import { Nullable } from "babylonjs/types";
  42298. import { IDisposable } from "babylonjs/scene";
  42299. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42300. /**
  42301. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42302. */
  42303. export class WebXRManagedOutputCanvas implements IDisposable {
  42304. private helper;
  42305. private _canvas;
  42306. /**
  42307. * xrpresent context of the canvas which can be used to display/mirror xr content
  42308. */
  42309. canvasContext: WebGLRenderingContext;
  42310. /**
  42311. * xr layer for the canvas
  42312. */
  42313. xrLayer: Nullable<XRWebGLLayer>;
  42314. /**
  42315. * Initializes the xr layer for the session
  42316. * @param xrSession xr session
  42317. * @returns a promise that will resolve once the XR Layer has been created
  42318. */
  42319. initializeXRLayerAsync(xrSession: any): any;
  42320. /**
  42321. * Initializes the canvas to be added/removed upon entering/exiting xr
  42322. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42323. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42324. */
  42325. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42326. /**
  42327. * Disposes of the object
  42328. */
  42329. dispose(): void;
  42330. private _setManagedOutputCanvas;
  42331. private _addCanvas;
  42332. private _removeCanvas;
  42333. }
  42334. }
  42335. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42336. import { Observable } from "babylonjs/Misc/observable";
  42337. import { IDisposable, Scene } from "babylonjs/scene";
  42338. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42340. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42341. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42342. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42343. /**
  42344. * States of the webXR experience
  42345. */
  42346. export enum WebXRState {
  42347. /**
  42348. * Transitioning to being in XR mode
  42349. */
  42350. ENTERING_XR = 0,
  42351. /**
  42352. * Transitioning to non XR mode
  42353. */
  42354. EXITING_XR = 1,
  42355. /**
  42356. * In XR mode and presenting
  42357. */
  42358. IN_XR = 2,
  42359. /**
  42360. * Not entered XR mode
  42361. */
  42362. NOT_IN_XR = 3
  42363. }
  42364. /**
  42365. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42366. * @see https://doc.babylonjs.com/how_to/webxr
  42367. */
  42368. export class WebXRExperienceHelper implements IDisposable {
  42369. private scene;
  42370. /**
  42371. * 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
  42372. */
  42373. container: AbstractMesh;
  42374. /**
  42375. * Camera used to render xr content
  42376. */
  42377. camera: WebXRCamera;
  42378. /**
  42379. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42380. */
  42381. state: WebXRState;
  42382. private _setState;
  42383. private static _TmpVector;
  42384. /**
  42385. * Fires when the state of the experience helper has changed
  42386. */
  42387. onStateChangedObservable: Observable<WebXRState>;
  42388. /** Session manager used to keep track of xr session */
  42389. sessionManager: WebXRSessionManager;
  42390. private _nonVRCamera;
  42391. private _originalSceneAutoClear;
  42392. private _supported;
  42393. /**
  42394. * Creates the experience helper
  42395. * @param scene the scene to attach the experience helper to
  42396. * @returns a promise for the experience helper
  42397. */
  42398. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42399. /**
  42400. * Creates a WebXRExperienceHelper
  42401. * @param scene The scene the helper should be created in
  42402. */
  42403. private constructor();
  42404. /**
  42405. * Exits XR mode and returns the scene to its original state
  42406. * @returns promise that resolves after xr mode has exited
  42407. */
  42408. exitXRAsync(): Promise<unknown>;
  42409. /**
  42410. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42411. * @param sessionCreationOptions options for the XR session
  42412. * @param referenceSpaceType frame of reference of the XR session
  42413. * @param outputCanvas the output canvas that will be used to enter XR mode
  42414. * @returns promise that resolves after xr mode has entered
  42415. */
  42416. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42417. /**
  42418. * Updates the global position of the camera by moving the camera's container
  42419. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42420. * @param position The desired global position of the camera
  42421. */
  42422. setPositionOfCameraUsingContainer(position: Vector3): void;
  42423. /**
  42424. * Rotates the xr camera by rotating the camera's container around the camera's position
  42425. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42426. * @param rotation the desired quaternion rotation to apply to the camera
  42427. */
  42428. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42429. /**
  42430. * Disposes of the experience helper
  42431. */
  42432. dispose(): void;
  42433. }
  42434. }
  42435. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42436. import { Nullable } from "babylonjs/types";
  42437. import { Observable } from "babylonjs/Misc/observable";
  42438. import { IDisposable, Scene } from "babylonjs/scene";
  42439. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42440. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42441. /**
  42442. * Button which can be used to enter a different mode of XR
  42443. */
  42444. export class WebXREnterExitUIButton {
  42445. /** button element */
  42446. element: HTMLElement;
  42447. /** XR initialization options for the button */
  42448. sessionMode: XRSessionMode;
  42449. /** Reference space type */
  42450. referenceSpaceType: XRReferenceSpaceType;
  42451. /**
  42452. * Creates a WebXREnterExitUIButton
  42453. * @param element button element
  42454. * @param sessionMode XR initialization session mode
  42455. * @param referenceSpaceType the type of reference space to be used
  42456. */
  42457. constructor(
  42458. /** button element */
  42459. element: HTMLElement,
  42460. /** XR initialization options for the button */
  42461. sessionMode: XRSessionMode,
  42462. /** Reference space type */
  42463. referenceSpaceType: XRReferenceSpaceType);
  42464. /**
  42465. * Overwritable function which can be used to update the button's visuals when the state changes
  42466. * @param activeButton the current active button in the UI
  42467. */
  42468. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42469. }
  42470. /**
  42471. * Options to create the webXR UI
  42472. */
  42473. export class WebXREnterExitUIOptions {
  42474. /**
  42475. * Context to enter xr with
  42476. */
  42477. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42478. /**
  42479. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42480. */
  42481. customButtons?: Array<WebXREnterExitUIButton>;
  42482. }
  42483. /**
  42484. * UI to allow the user to enter/exit XR mode
  42485. */
  42486. export class WebXREnterExitUI implements IDisposable {
  42487. private scene;
  42488. private _overlay;
  42489. private _buttons;
  42490. private _activeButton;
  42491. /**
  42492. * Fired every time the active button is changed.
  42493. *
  42494. * When xr is entered via a button that launches xr that button will be the callback parameter
  42495. *
  42496. * When exiting xr the callback parameter will be null)
  42497. */
  42498. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42499. /**
  42500. * Creates UI to allow the user to enter/exit XR mode
  42501. * @param scene the scene to add the ui to
  42502. * @param helper the xr experience helper to enter/exit xr with
  42503. * @param options options to configure the UI
  42504. * @returns the created ui
  42505. */
  42506. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42507. private constructor();
  42508. private _updateButtons;
  42509. /**
  42510. * Disposes of the object
  42511. */
  42512. dispose(): void;
  42513. }
  42514. }
  42515. declare module "babylonjs/Cameras/XR/webXRController" {
  42516. import { Nullable } from "babylonjs/types";
  42517. import { Observable } from "babylonjs/Misc/observable";
  42518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42519. import { Ray } from "babylonjs/Culling/ray";
  42520. import { Scene } from "babylonjs/scene";
  42521. /**
  42522. * Represents an XR input
  42523. */
  42524. export class WebXRController {
  42525. private scene;
  42526. /** The underlying input source for the controller */
  42527. inputSource: XRInputSource;
  42528. private parentContainer;
  42529. /**
  42530. * 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
  42531. */
  42532. grip?: AbstractMesh;
  42533. /**
  42534. * Pointer which can be used to select objects or attach a visible laser to
  42535. */
  42536. pointer: AbstractMesh;
  42537. /**
  42538. * Event that fires when the controller is removed/disposed
  42539. */
  42540. onDisposeObservable: Observable<{}>;
  42541. private _tmpMatrix;
  42542. private _tmpQuaternion;
  42543. private _tmpVector;
  42544. /**
  42545. * Creates the controller
  42546. * @see https://doc.babylonjs.com/how_to/webxr
  42547. * @param scene the scene which the controller should be associated to
  42548. * @param inputSource the underlying input source for the controller
  42549. * @param parentContainer parent that the controller meshes should be children of
  42550. */
  42551. constructor(scene: Scene,
  42552. /** The underlying input source for the controller */
  42553. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42554. /**
  42555. * Updates the controller pose based on the given XRFrame
  42556. * @param xrFrame xr frame to update the pose with
  42557. * @param referenceSpace reference space to use
  42558. */
  42559. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42560. /**
  42561. * Gets a world space ray coming from the controller
  42562. * @param result the resulting ray
  42563. */
  42564. getWorldPointerRayToRef(result: Ray): void;
  42565. /**
  42566. * Disposes of the object
  42567. */
  42568. dispose(): void;
  42569. }
  42570. }
  42571. declare module "babylonjs/Cameras/XR/webXRInput" {
  42572. import { Observable } from "babylonjs/Misc/observable";
  42573. import { IDisposable } from "babylonjs/scene";
  42574. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42575. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42576. /**
  42577. * XR input used to track XR inputs such as controllers/rays
  42578. */
  42579. export class WebXRInput implements IDisposable {
  42580. /**
  42581. * Base experience the input listens to
  42582. */
  42583. baseExperience: WebXRExperienceHelper;
  42584. /**
  42585. * XR controllers being tracked
  42586. */
  42587. controllers: Array<WebXRController>;
  42588. private _frameObserver;
  42589. private _stateObserver;
  42590. /**
  42591. * Event when a controller has been connected/added
  42592. */
  42593. onControllerAddedObservable: Observable<WebXRController>;
  42594. /**
  42595. * Event when a controller has been removed/disconnected
  42596. */
  42597. onControllerRemovedObservable: Observable<WebXRController>;
  42598. /**
  42599. * Initializes the WebXRInput
  42600. * @param baseExperience experience helper which the input should be created for
  42601. */
  42602. constructor(
  42603. /**
  42604. * Base experience the input listens to
  42605. */
  42606. baseExperience: WebXRExperienceHelper);
  42607. private _onInputSourcesChange;
  42608. private _addAndRemoveControllers;
  42609. /**
  42610. * Disposes of the object
  42611. */
  42612. dispose(): void;
  42613. }
  42614. }
  42615. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42617. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42618. /**
  42619. * Enables teleportation
  42620. */
  42621. export class WebXRControllerTeleportation {
  42622. private _teleportationFillColor;
  42623. private _teleportationBorderColor;
  42624. private _tmpRay;
  42625. private _tmpVector;
  42626. /**
  42627. * Creates a WebXRControllerTeleportation
  42628. * @param input input manager to add teleportation to
  42629. * @param floorMeshes floormeshes which can be teleported to
  42630. */
  42631. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42632. }
  42633. }
  42634. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42635. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42636. /**
  42637. * Handles pointer input automatically for the pointer of XR controllers
  42638. */
  42639. export class WebXRControllerPointerSelection {
  42640. private static _idCounter;
  42641. private _tmpRay;
  42642. /**
  42643. * Creates a WebXRControllerPointerSelection
  42644. * @param input input manager to setup pointer selection
  42645. */
  42646. constructor(input: WebXRInput);
  42647. private _convertNormalToDirectionOfRay;
  42648. private _updatePointerDistance;
  42649. }
  42650. }
  42651. declare module "babylonjs/Loading/sceneLoader" {
  42652. import { Observable } from "babylonjs/Misc/observable";
  42653. import { Nullable } from "babylonjs/types";
  42654. import { Scene } from "babylonjs/scene";
  42655. import { Engine } from "babylonjs/Engines/engine";
  42656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42657. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42658. import { AssetContainer } from "babylonjs/assetContainer";
  42659. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42660. import { Skeleton } from "babylonjs/Bones/skeleton";
  42661. /**
  42662. * Class used to represent data loading progression
  42663. */
  42664. export class SceneLoaderProgressEvent {
  42665. /** defines if data length to load can be evaluated */
  42666. readonly lengthComputable: boolean;
  42667. /** defines the loaded data length */
  42668. readonly loaded: number;
  42669. /** defines the data length to load */
  42670. readonly total: number;
  42671. /**
  42672. * Create a new progress event
  42673. * @param lengthComputable defines if data length to load can be evaluated
  42674. * @param loaded defines the loaded data length
  42675. * @param total defines the data length to load
  42676. */
  42677. constructor(
  42678. /** defines if data length to load can be evaluated */
  42679. lengthComputable: boolean,
  42680. /** defines the loaded data length */
  42681. loaded: number,
  42682. /** defines the data length to load */
  42683. total: number);
  42684. /**
  42685. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42686. * @param event defines the source event
  42687. * @returns a new SceneLoaderProgressEvent
  42688. */
  42689. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42690. }
  42691. /**
  42692. * Interface used by SceneLoader plugins to define supported file extensions
  42693. */
  42694. export interface ISceneLoaderPluginExtensions {
  42695. /**
  42696. * Defines the list of supported extensions
  42697. */
  42698. [extension: string]: {
  42699. isBinary: boolean;
  42700. };
  42701. }
  42702. /**
  42703. * Interface used by SceneLoader plugin factory
  42704. */
  42705. export interface ISceneLoaderPluginFactory {
  42706. /**
  42707. * Defines the name of the factory
  42708. */
  42709. name: string;
  42710. /**
  42711. * Function called to create a new plugin
  42712. * @return the new plugin
  42713. */
  42714. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42715. /**
  42716. * Boolean indicating if the plugin can direct load specific data
  42717. */
  42718. canDirectLoad?: (data: string) => boolean;
  42719. }
  42720. /**
  42721. * Interface used to define a SceneLoader plugin
  42722. */
  42723. export interface ISceneLoaderPlugin {
  42724. /**
  42725. * The friendly name of this plugin.
  42726. */
  42727. name: string;
  42728. /**
  42729. * The file extensions supported by this plugin.
  42730. */
  42731. extensions: string | ISceneLoaderPluginExtensions;
  42732. /**
  42733. * Import meshes into a scene.
  42734. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42735. * @param scene The scene to import into
  42736. * @param data The data to import
  42737. * @param rootUrl The root url for scene and resources
  42738. * @param meshes The meshes array to import into
  42739. * @param particleSystems The particle systems array to import into
  42740. * @param skeletons The skeletons array to import into
  42741. * @param onError The callback when import fails
  42742. * @returns True if successful or false otherwise
  42743. */
  42744. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42745. /**
  42746. * Load into a scene.
  42747. * @param scene The scene to load into
  42748. * @param data The data to import
  42749. * @param rootUrl The root url for scene and resources
  42750. * @param onError The callback when import fails
  42751. * @returns true if successful or false otherwise
  42752. */
  42753. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42754. /**
  42755. * The callback that returns true if the data can be directly loaded.
  42756. */
  42757. canDirectLoad?: (data: string) => boolean;
  42758. /**
  42759. * The callback that allows custom handling of the root url based on the response url.
  42760. */
  42761. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42762. /**
  42763. * Load into an asset container.
  42764. * @param scene The scene to load into
  42765. * @param data The data to import
  42766. * @param rootUrl The root url for scene and resources
  42767. * @param onError The callback when import fails
  42768. * @returns The loaded asset container
  42769. */
  42770. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42771. }
  42772. /**
  42773. * Interface used to define an async SceneLoader plugin
  42774. */
  42775. export interface ISceneLoaderPluginAsync {
  42776. /**
  42777. * The friendly name of this plugin.
  42778. */
  42779. name: string;
  42780. /**
  42781. * The file extensions supported by this plugin.
  42782. */
  42783. extensions: string | ISceneLoaderPluginExtensions;
  42784. /**
  42785. * Import meshes into a scene.
  42786. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42787. * @param scene The scene to import into
  42788. * @param data The data to import
  42789. * @param rootUrl The root url for scene and resources
  42790. * @param onProgress The callback when the load progresses
  42791. * @param fileName Defines the name of the file to load
  42792. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42793. */
  42794. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42795. meshes: AbstractMesh[];
  42796. particleSystems: IParticleSystem[];
  42797. skeletons: Skeleton[];
  42798. animationGroups: AnimationGroup[];
  42799. }>;
  42800. /**
  42801. * Load into a scene.
  42802. * @param scene The scene to load into
  42803. * @param data The data to import
  42804. * @param rootUrl The root url for scene and resources
  42805. * @param onProgress The callback when the load progresses
  42806. * @param fileName Defines the name of the file to load
  42807. * @returns Nothing
  42808. */
  42809. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42810. /**
  42811. * The callback that returns true if the data can be directly loaded.
  42812. */
  42813. canDirectLoad?: (data: string) => boolean;
  42814. /**
  42815. * The callback that allows custom handling of the root url based on the response url.
  42816. */
  42817. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42818. /**
  42819. * Load into an asset container.
  42820. * @param scene The scene to load into
  42821. * @param data The data to import
  42822. * @param rootUrl The root url for scene and resources
  42823. * @param onProgress The callback when the load progresses
  42824. * @param fileName Defines the name of the file to load
  42825. * @returns The loaded asset container
  42826. */
  42827. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42828. }
  42829. /**
  42830. * Class used to load scene from various file formats using registered plugins
  42831. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42832. */
  42833. export class SceneLoader {
  42834. /**
  42835. * No logging while loading
  42836. */
  42837. static readonly NO_LOGGING: number;
  42838. /**
  42839. * Minimal logging while loading
  42840. */
  42841. static readonly MINIMAL_LOGGING: number;
  42842. /**
  42843. * Summary logging while loading
  42844. */
  42845. static readonly SUMMARY_LOGGING: number;
  42846. /**
  42847. * Detailled logging while loading
  42848. */
  42849. static readonly DETAILED_LOGGING: number;
  42850. /**
  42851. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42852. */
  42853. static ForceFullSceneLoadingForIncremental: boolean;
  42854. /**
  42855. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42856. */
  42857. static ShowLoadingScreen: boolean;
  42858. /**
  42859. * Defines the current logging level (while loading the scene)
  42860. * @ignorenaming
  42861. */
  42862. static loggingLevel: number;
  42863. /**
  42864. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42865. */
  42866. static CleanBoneMatrixWeights: boolean;
  42867. /**
  42868. * Event raised when a plugin is used to load a scene
  42869. */
  42870. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42871. private static _registeredPlugins;
  42872. private static _getDefaultPlugin;
  42873. private static _getPluginForExtension;
  42874. private static _getPluginForDirectLoad;
  42875. private static _getPluginForFilename;
  42876. private static _getDirectLoad;
  42877. private static _loadData;
  42878. private static _getFileInfo;
  42879. /**
  42880. * Gets a plugin that can load the given extension
  42881. * @param extension defines the extension to load
  42882. * @returns a plugin or null if none works
  42883. */
  42884. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42885. /**
  42886. * Gets a boolean indicating that the given extension can be loaded
  42887. * @param extension defines the extension to load
  42888. * @returns true if the extension is supported
  42889. */
  42890. static IsPluginForExtensionAvailable(extension: string): boolean;
  42891. /**
  42892. * Adds a new plugin to the list of registered plugins
  42893. * @param plugin defines the plugin to add
  42894. */
  42895. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42896. /**
  42897. * Import meshes into a scene
  42898. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42899. * @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)
  42900. * @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)
  42901. * @param scene the instance of BABYLON.Scene to append to
  42902. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42903. * @param onProgress a callback with a progress event for each file being loaded
  42904. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42905. * @param pluginExtension the extension used to determine the plugin
  42906. * @returns The loaded plugin
  42907. */
  42908. 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>;
  42909. /**
  42910. * Import meshes into a scene
  42911. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42912. * @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)
  42913. * @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)
  42914. * @param scene the instance of BABYLON.Scene to append to
  42915. * @param onProgress a callback with a progress event for each file being loaded
  42916. * @param pluginExtension the extension used to determine the plugin
  42917. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42918. */
  42919. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42920. meshes: AbstractMesh[];
  42921. particleSystems: IParticleSystem[];
  42922. skeletons: Skeleton[];
  42923. animationGroups: AnimationGroup[];
  42924. }>;
  42925. /**
  42926. * Load a scene
  42927. * @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)
  42928. * @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)
  42929. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42930. * @param onSuccess a callback with the scene when import succeeds
  42931. * @param onProgress a callback with a progress event for each file being loaded
  42932. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42933. * @param pluginExtension the extension used to determine the plugin
  42934. * @returns The loaded plugin
  42935. */
  42936. 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>;
  42937. /**
  42938. * Load a scene
  42939. * @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)
  42940. * @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)
  42941. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42942. * @param onProgress a callback with a progress event for each file being loaded
  42943. * @param pluginExtension the extension used to determine the plugin
  42944. * @returns The loaded scene
  42945. */
  42946. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42947. /**
  42948. * Append a scene
  42949. * @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)
  42950. * @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)
  42951. * @param scene is the instance of BABYLON.Scene to append to
  42952. * @param onSuccess a callback with the scene when import succeeds
  42953. * @param onProgress a callback with a progress event for each file being loaded
  42954. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42955. * @param pluginExtension the extension used to determine the plugin
  42956. * @returns The loaded plugin
  42957. */
  42958. 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>;
  42959. /**
  42960. * Append a scene
  42961. * @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)
  42962. * @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)
  42963. * @param scene is the instance of BABYLON.Scene to append to
  42964. * @param onProgress a callback with a progress event for each file being loaded
  42965. * @param pluginExtension the extension used to determine the plugin
  42966. * @returns The given scene
  42967. */
  42968. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42969. /**
  42970. * Load a scene into an asset container
  42971. * @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)
  42972. * @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)
  42973. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42974. * @param onSuccess a callback with the scene when import succeeds
  42975. * @param onProgress a callback with a progress event for each file being loaded
  42976. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42977. * @param pluginExtension the extension used to determine the plugin
  42978. * @returns The loaded plugin
  42979. */
  42980. 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>;
  42981. /**
  42982. * Load a scene into an asset container
  42983. * @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)
  42984. * @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)
  42985. * @param scene is the instance of Scene to append to
  42986. * @param onProgress a callback with a progress event for each file being loaded
  42987. * @param pluginExtension the extension used to determine the plugin
  42988. * @returns The loaded asset container
  42989. */
  42990. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42991. }
  42992. }
  42993. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42994. import { Scene } from "babylonjs/scene";
  42995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42996. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42997. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42998. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42999. /**
  43000. * Generic Controller
  43001. */
  43002. export class GenericController extends WebVRController {
  43003. /**
  43004. * Base Url for the controller model.
  43005. */
  43006. static readonly MODEL_BASE_URL: string;
  43007. /**
  43008. * File name for the controller model.
  43009. */
  43010. static readonly MODEL_FILENAME: string;
  43011. /**
  43012. * Creates a new GenericController from a gamepad
  43013. * @param vrGamepad the gamepad that the controller should be created from
  43014. */
  43015. constructor(vrGamepad: any);
  43016. /**
  43017. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43018. * @param scene scene in which to add meshes
  43019. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43020. */
  43021. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43022. /**
  43023. * Called once for each button that changed state since the last frame
  43024. * @param buttonIdx Which button index changed
  43025. * @param state New state of the button
  43026. * @param changes Which properties on the state changed since last frame
  43027. */
  43028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43029. }
  43030. }
  43031. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43032. import { Observable } from "babylonjs/Misc/observable";
  43033. import { Scene } from "babylonjs/scene";
  43034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43035. import { Ray } from "babylonjs/Culling/ray";
  43036. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43037. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43038. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43039. /**
  43040. * Defines the WindowsMotionController object that the state of the windows motion controller
  43041. */
  43042. export class WindowsMotionController extends WebVRController {
  43043. /**
  43044. * The base url used to load the left and right controller models
  43045. */
  43046. static MODEL_BASE_URL: string;
  43047. /**
  43048. * The name of the left controller model file
  43049. */
  43050. static MODEL_LEFT_FILENAME: string;
  43051. /**
  43052. * The name of the right controller model file
  43053. */
  43054. static MODEL_RIGHT_FILENAME: string;
  43055. /**
  43056. * The controller name prefix for this controller type
  43057. */
  43058. static readonly GAMEPAD_ID_PREFIX: string;
  43059. /**
  43060. * The controller id pattern for this controller type
  43061. */
  43062. private static readonly GAMEPAD_ID_PATTERN;
  43063. private _loadedMeshInfo;
  43064. private readonly _mapping;
  43065. /**
  43066. * Fired when the trackpad on this controller is clicked
  43067. */
  43068. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43069. /**
  43070. * Fired when the trackpad on this controller is modified
  43071. */
  43072. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43073. /**
  43074. * The current x and y values of this controller's trackpad
  43075. */
  43076. trackpad: StickValues;
  43077. /**
  43078. * Creates a new WindowsMotionController from a gamepad
  43079. * @param vrGamepad the gamepad that the controller should be created from
  43080. */
  43081. constructor(vrGamepad: any);
  43082. /**
  43083. * Fired when the trigger on this controller is modified
  43084. */
  43085. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43086. /**
  43087. * Fired when the menu button on this controller is modified
  43088. */
  43089. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43090. /**
  43091. * Fired when the grip button on this controller is modified
  43092. */
  43093. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43094. /**
  43095. * Fired when the thumbstick button on this controller is modified
  43096. */
  43097. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43098. /**
  43099. * Fired when the touchpad button on this controller is modified
  43100. */
  43101. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43102. /**
  43103. * Fired when the touchpad values on this controller are modified
  43104. */
  43105. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43106. private _updateTrackpad;
  43107. /**
  43108. * Called once per frame by the engine.
  43109. */
  43110. update(): void;
  43111. /**
  43112. * Called once for each button that changed state since the last frame
  43113. * @param buttonIdx Which button index changed
  43114. * @param state New state of the button
  43115. * @param changes Which properties on the state changed since last frame
  43116. */
  43117. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43118. /**
  43119. * Moves the buttons on the controller mesh based on their current state
  43120. * @param buttonName the name of the button to move
  43121. * @param buttonValue the value of the button which determines the buttons new position
  43122. */
  43123. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43124. /**
  43125. * Moves the axis on the controller mesh based on its current state
  43126. * @param axis the index of the axis
  43127. * @param axisValue the value of the axis which determines the meshes new position
  43128. * @hidden
  43129. */
  43130. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43131. /**
  43132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43133. * @param scene scene in which to add meshes
  43134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43135. */
  43136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43137. /**
  43138. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43139. * can be transformed by button presses and axes values, based on this._mapping.
  43140. *
  43141. * @param scene scene in which the meshes exist
  43142. * @param meshes list of meshes that make up the controller model to process
  43143. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43144. */
  43145. private processModel;
  43146. private createMeshInfo;
  43147. /**
  43148. * Gets the ray of the controller in the direction the controller is pointing
  43149. * @param length the length the resulting ray should be
  43150. * @returns a ray in the direction the controller is pointing
  43151. */
  43152. getForwardRay(length?: number): Ray;
  43153. /**
  43154. * Disposes of the controller
  43155. */
  43156. dispose(): void;
  43157. }
  43158. }
  43159. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43160. import { Observable } from "babylonjs/Misc/observable";
  43161. import { Scene } from "babylonjs/scene";
  43162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43163. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43164. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43165. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43166. /**
  43167. * Oculus Touch Controller
  43168. */
  43169. export class OculusTouchController extends WebVRController {
  43170. /**
  43171. * Base Url for the controller model.
  43172. */
  43173. static MODEL_BASE_URL: string;
  43174. /**
  43175. * File name for the left controller model.
  43176. */
  43177. static MODEL_LEFT_FILENAME: string;
  43178. /**
  43179. * File name for the right controller model.
  43180. */
  43181. static MODEL_RIGHT_FILENAME: string;
  43182. /**
  43183. * Base Url for the Quest controller model.
  43184. */
  43185. static QUEST_MODEL_BASE_URL: string;
  43186. /**
  43187. * @hidden
  43188. * If the controllers are running on a device that needs the updated Quest controller models
  43189. */
  43190. static _IsQuest: boolean;
  43191. /**
  43192. * Fired when the secondary trigger on this controller is modified
  43193. */
  43194. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43195. /**
  43196. * Fired when the thumb rest on this controller is modified
  43197. */
  43198. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43199. /**
  43200. * Creates a new OculusTouchController from a gamepad
  43201. * @param vrGamepad the gamepad that the controller should be created from
  43202. */
  43203. constructor(vrGamepad: any);
  43204. /**
  43205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43206. * @param scene scene in which to add meshes
  43207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43208. */
  43209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43210. /**
  43211. * Fired when the A button on this controller is modified
  43212. */
  43213. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43214. /**
  43215. * Fired when the B button on this controller is modified
  43216. */
  43217. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43218. /**
  43219. * Fired when the X button on this controller is modified
  43220. */
  43221. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43222. /**
  43223. * Fired when the Y button on this controller is modified
  43224. */
  43225. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43226. /**
  43227. * Called once for each button that changed state since the last frame
  43228. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43229. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43230. * 2) secondary trigger (same)
  43231. * 3) A (right) X (left), touch, pressed = value
  43232. * 4) B / Y
  43233. * 5) thumb rest
  43234. * @param buttonIdx Which button index changed
  43235. * @param state New state of the button
  43236. * @param changes Which properties on the state changed since last frame
  43237. */
  43238. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43239. }
  43240. }
  43241. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43242. import { Scene } from "babylonjs/scene";
  43243. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43244. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43245. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43246. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43247. import { Observable } from "babylonjs/Misc/observable";
  43248. /**
  43249. * Vive Controller
  43250. */
  43251. export class ViveController extends WebVRController {
  43252. /**
  43253. * Base Url for the controller model.
  43254. */
  43255. static MODEL_BASE_URL: string;
  43256. /**
  43257. * File name for the controller model.
  43258. */
  43259. static MODEL_FILENAME: string;
  43260. /**
  43261. * Creates a new ViveController from a gamepad
  43262. * @param vrGamepad the gamepad that the controller should be created from
  43263. */
  43264. constructor(vrGamepad: any);
  43265. /**
  43266. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43267. * @param scene scene in which to add meshes
  43268. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43269. */
  43270. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43271. /**
  43272. * Fired when the left button on this controller is modified
  43273. */
  43274. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43275. /**
  43276. * Fired when the right button on this controller is modified
  43277. */
  43278. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43279. /**
  43280. * Fired when the menu button on this controller is modified
  43281. */
  43282. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43283. /**
  43284. * Called once for each button that changed state since the last frame
  43285. * Vive mapping:
  43286. * 0: touchpad
  43287. * 1: trigger
  43288. * 2: left AND right buttons
  43289. * 3: menu button
  43290. * @param buttonIdx Which button index changed
  43291. * @param state New state of the button
  43292. * @param changes Which properties on the state changed since last frame
  43293. */
  43294. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43298. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43299. /**
  43300. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43301. */
  43302. export class WebXRControllerModelLoader {
  43303. /**
  43304. * Creates the WebXRControllerModelLoader
  43305. * @param input xr input that creates the controllers
  43306. */
  43307. constructor(input: WebXRInput);
  43308. }
  43309. }
  43310. declare module "babylonjs/Cameras/XR/index" {
  43311. export * from "babylonjs/Cameras/XR/webXRCamera";
  43312. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43313. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43314. export * from "babylonjs/Cameras/XR/webXRInput";
  43315. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43316. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43317. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43318. export * from "babylonjs/Cameras/XR/webXRController";
  43319. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43320. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43321. }
  43322. declare module "babylonjs/Cameras/RigModes/index" {
  43323. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43324. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43325. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43326. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43327. }
  43328. declare module "babylonjs/Cameras/index" {
  43329. export * from "babylonjs/Cameras/Inputs/index";
  43330. export * from "babylonjs/Cameras/cameraInputsManager";
  43331. export * from "babylonjs/Cameras/camera";
  43332. export * from "babylonjs/Cameras/targetCamera";
  43333. export * from "babylonjs/Cameras/freeCamera";
  43334. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43335. export * from "babylonjs/Cameras/touchCamera";
  43336. export * from "babylonjs/Cameras/arcRotateCamera";
  43337. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43338. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43339. export * from "babylonjs/Cameras/flyCamera";
  43340. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43341. export * from "babylonjs/Cameras/followCamera";
  43342. export * from "babylonjs/Cameras/gamepadCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/index";
  43344. export * from "babylonjs/Cameras/universalCamera";
  43345. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43346. export * from "babylonjs/Cameras/VR/index";
  43347. export * from "babylonjs/Cameras/XR/index";
  43348. export * from "babylonjs/Cameras/RigModes/index";
  43349. }
  43350. declare module "babylonjs/Collisions/index" {
  43351. export * from "babylonjs/Collisions/collider";
  43352. export * from "babylonjs/Collisions/collisionCoordinator";
  43353. export * from "babylonjs/Collisions/pickingInfo";
  43354. export * from "babylonjs/Collisions/intersectionInfo";
  43355. export * from "babylonjs/Collisions/meshCollisionData";
  43356. }
  43357. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43358. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43359. import { Vector3 } from "babylonjs/Maths/math.vector";
  43360. import { Ray } from "babylonjs/Culling/ray";
  43361. import { Plane } from "babylonjs/Maths/math.plane";
  43362. /**
  43363. * Contains an array of blocks representing the octree
  43364. */
  43365. export interface IOctreeContainer<T> {
  43366. /**
  43367. * Blocks within the octree
  43368. */
  43369. blocks: Array<OctreeBlock<T>>;
  43370. }
  43371. /**
  43372. * Class used to store a cell in an octree
  43373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43374. */
  43375. export class OctreeBlock<T> {
  43376. /**
  43377. * Gets the content of the current block
  43378. */
  43379. entries: T[];
  43380. /**
  43381. * Gets the list of block children
  43382. */
  43383. blocks: Array<OctreeBlock<T>>;
  43384. private _depth;
  43385. private _maxDepth;
  43386. private _capacity;
  43387. private _minPoint;
  43388. private _maxPoint;
  43389. private _boundingVectors;
  43390. private _creationFunc;
  43391. /**
  43392. * Creates a new block
  43393. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43394. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43395. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43396. * @param depth defines the current depth of this block in the octree
  43397. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43398. * @param creationFunc defines a callback to call when an element is added to the block
  43399. */
  43400. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43401. /**
  43402. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43403. */
  43404. readonly capacity: number;
  43405. /**
  43406. * Gets the minimum vector (in world space) of the block's bounding box
  43407. */
  43408. readonly minPoint: Vector3;
  43409. /**
  43410. * Gets the maximum vector (in world space) of the block's bounding box
  43411. */
  43412. readonly maxPoint: Vector3;
  43413. /**
  43414. * Add a new element to this block
  43415. * @param entry defines the element to add
  43416. */
  43417. addEntry(entry: T): void;
  43418. /**
  43419. * Remove an element from this block
  43420. * @param entry defines the element to remove
  43421. */
  43422. removeEntry(entry: T): void;
  43423. /**
  43424. * Add an array of elements to this block
  43425. * @param entries defines the array of elements to add
  43426. */
  43427. addEntries(entries: T[]): void;
  43428. /**
  43429. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43430. * @param frustumPlanes defines the frustum planes to test
  43431. * @param selection defines the array to store current content if selection is positive
  43432. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43433. */
  43434. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43435. /**
  43436. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43437. * @param sphereCenter defines the bounding sphere center
  43438. * @param sphereRadius defines the bounding sphere radius
  43439. * @param selection defines the array to store current content if selection is positive
  43440. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43441. */
  43442. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43443. /**
  43444. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43445. * @param ray defines the ray to test with
  43446. * @param selection defines the array to store current content if selection is positive
  43447. */
  43448. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43449. /**
  43450. * Subdivide the content into child blocks (this block will then be empty)
  43451. */
  43452. createInnerBlocks(): void;
  43453. /**
  43454. * @hidden
  43455. */
  43456. 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;
  43457. }
  43458. }
  43459. declare module "babylonjs/Culling/Octrees/octree" {
  43460. import { SmartArray } from "babylonjs/Misc/smartArray";
  43461. import { Vector3 } from "babylonjs/Maths/math.vector";
  43462. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43464. import { Ray } from "babylonjs/Culling/ray";
  43465. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43466. import { Plane } from "babylonjs/Maths/math.plane";
  43467. /**
  43468. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43469. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43470. */
  43471. export class Octree<T> {
  43472. /** 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.) */
  43473. maxDepth: number;
  43474. /**
  43475. * Blocks within the octree containing objects
  43476. */
  43477. blocks: Array<OctreeBlock<T>>;
  43478. /**
  43479. * Content stored in the octree
  43480. */
  43481. dynamicContent: T[];
  43482. private _maxBlockCapacity;
  43483. private _selectionContent;
  43484. private _creationFunc;
  43485. /**
  43486. * Creates a octree
  43487. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43488. * @param creationFunc function to be used to instatiate the octree
  43489. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43490. * @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.)
  43491. */
  43492. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43493. /** 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.) */
  43494. maxDepth?: number);
  43495. /**
  43496. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43497. * @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);
  43498. * @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);
  43499. * @param entries meshes to be added to the octree blocks
  43500. */
  43501. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43502. /**
  43503. * Adds a mesh to the octree
  43504. * @param entry Mesh to add to the octree
  43505. */
  43506. addMesh(entry: T): void;
  43507. /**
  43508. * Remove an element from the octree
  43509. * @param entry defines the element to remove
  43510. */
  43511. removeMesh(entry: T): void;
  43512. /**
  43513. * Selects an array of meshes within the frustum
  43514. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43515. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43516. * @returns array of meshes within the frustum
  43517. */
  43518. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43519. /**
  43520. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43521. * @param sphereCenter defines the bounding sphere center
  43522. * @param sphereRadius defines the bounding sphere radius
  43523. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43524. * @returns an array of objects that intersect the sphere
  43525. */
  43526. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43527. /**
  43528. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43529. * @param ray defines the ray to test with
  43530. * @returns array of intersected objects
  43531. */
  43532. intersectsRay(ray: Ray): SmartArray<T>;
  43533. /**
  43534. * Adds a mesh into the octree block if it intersects the block
  43535. */
  43536. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43537. /**
  43538. * Adds a submesh into the octree block if it intersects the block
  43539. */
  43540. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43541. }
  43542. }
  43543. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43544. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43545. import { Scene } from "babylonjs/scene";
  43546. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43548. import { Ray } from "babylonjs/Culling/ray";
  43549. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43550. import { Collider } from "babylonjs/Collisions/collider";
  43551. module "babylonjs/scene" {
  43552. interface Scene {
  43553. /**
  43554. * @hidden
  43555. * Backing Filed
  43556. */
  43557. _selectionOctree: Octree<AbstractMesh>;
  43558. /**
  43559. * Gets the octree used to boost mesh selection (picking)
  43560. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43561. */
  43562. selectionOctree: Octree<AbstractMesh>;
  43563. /**
  43564. * Creates or updates the octree used to boost selection (picking)
  43565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43566. * @param maxCapacity defines the maximum capacity per leaf
  43567. * @param maxDepth defines the maximum depth of the octree
  43568. * @returns an octree of AbstractMesh
  43569. */
  43570. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43571. }
  43572. }
  43573. module "babylonjs/Meshes/abstractMesh" {
  43574. interface AbstractMesh {
  43575. /**
  43576. * @hidden
  43577. * Backing Field
  43578. */
  43579. _submeshesOctree: Octree<SubMesh>;
  43580. /**
  43581. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43582. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43583. * @param maxCapacity defines the maximum size of each block (64 by default)
  43584. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43585. * @returns the new octree
  43586. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43587. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43588. */
  43589. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43590. }
  43591. }
  43592. /**
  43593. * Defines the octree scene component responsible to manage any octrees
  43594. * in a given scene.
  43595. */
  43596. export class OctreeSceneComponent {
  43597. /**
  43598. * The component name help to identify the component in the list of scene components.
  43599. */
  43600. readonly name: string;
  43601. /**
  43602. * The scene the component belongs to.
  43603. */
  43604. scene: Scene;
  43605. /**
  43606. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43607. */
  43608. readonly checksIsEnabled: boolean;
  43609. /**
  43610. * Creates a new instance of the component for the given scene
  43611. * @param scene Defines the scene to register the component in
  43612. */
  43613. constructor(scene: Scene);
  43614. /**
  43615. * Registers the component in a given scene
  43616. */
  43617. register(): void;
  43618. /**
  43619. * Return the list of active meshes
  43620. * @returns the list of active meshes
  43621. */
  43622. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43623. /**
  43624. * Return the list of active sub meshes
  43625. * @param mesh The mesh to get the candidates sub meshes from
  43626. * @returns the list of active sub meshes
  43627. */
  43628. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43629. private _tempRay;
  43630. /**
  43631. * Return the list of sub meshes intersecting with a given local ray
  43632. * @param mesh defines the mesh to find the submesh for
  43633. * @param localRay defines the ray in local space
  43634. * @returns the list of intersecting sub meshes
  43635. */
  43636. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43637. /**
  43638. * Return the list of sub meshes colliding with a collider
  43639. * @param mesh defines the mesh to find the submesh for
  43640. * @param collider defines the collider to evaluate the collision against
  43641. * @returns the list of colliding sub meshes
  43642. */
  43643. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43644. /**
  43645. * Rebuilds the elements related to this component in case of
  43646. * context lost for instance.
  43647. */
  43648. rebuild(): void;
  43649. /**
  43650. * Disposes the component and the associated ressources.
  43651. */
  43652. dispose(): void;
  43653. }
  43654. }
  43655. declare module "babylonjs/Culling/Octrees/index" {
  43656. export * from "babylonjs/Culling/Octrees/octree";
  43657. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43658. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43659. }
  43660. declare module "babylonjs/Culling/index" {
  43661. export * from "babylonjs/Culling/boundingBox";
  43662. export * from "babylonjs/Culling/boundingInfo";
  43663. export * from "babylonjs/Culling/boundingSphere";
  43664. export * from "babylonjs/Culling/Octrees/index";
  43665. export * from "babylonjs/Culling/ray";
  43666. }
  43667. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43668. import { IDisposable, Scene } from "babylonjs/scene";
  43669. import { Nullable } from "babylonjs/types";
  43670. import { Observable } from "babylonjs/Misc/observable";
  43671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43672. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43673. import { Camera } from "babylonjs/Cameras/camera";
  43674. /**
  43675. * Renders a layer on top of an existing scene
  43676. */
  43677. export class UtilityLayerRenderer implements IDisposable {
  43678. /** the original scene that will be rendered on top of */
  43679. originalScene: Scene;
  43680. private _pointerCaptures;
  43681. private _lastPointerEvents;
  43682. private static _DefaultUtilityLayer;
  43683. private static _DefaultKeepDepthUtilityLayer;
  43684. private _sharedGizmoLight;
  43685. private _renderCamera;
  43686. /**
  43687. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43688. * @returns the camera that is used when rendering the utility layer
  43689. */
  43690. getRenderCamera(): Nullable<Camera>;
  43691. /**
  43692. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43693. * @param cam the camera that should be used when rendering the utility layer
  43694. */
  43695. setRenderCamera(cam: Nullable<Camera>): void;
  43696. /**
  43697. * @hidden
  43698. * Light which used by gizmos to get light shading
  43699. */
  43700. _getSharedGizmoLight(): HemisphericLight;
  43701. /**
  43702. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43703. */
  43704. pickUtilitySceneFirst: boolean;
  43705. /**
  43706. * 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)
  43707. */
  43708. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43709. /**
  43710. * 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)
  43711. */
  43712. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43713. /**
  43714. * The scene that is rendered on top of the original scene
  43715. */
  43716. utilityLayerScene: Scene;
  43717. /**
  43718. * If the utility layer should automatically be rendered on top of existing scene
  43719. */
  43720. shouldRender: boolean;
  43721. /**
  43722. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43723. */
  43724. onlyCheckPointerDownEvents: boolean;
  43725. /**
  43726. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43727. */
  43728. processAllEvents: boolean;
  43729. /**
  43730. * Observable raised when the pointer move from the utility layer scene to the main scene
  43731. */
  43732. onPointerOutObservable: Observable<number>;
  43733. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43734. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43735. private _afterRenderObserver;
  43736. private _sceneDisposeObserver;
  43737. private _originalPointerObserver;
  43738. /**
  43739. * Instantiates a UtilityLayerRenderer
  43740. * @param originalScene the original scene that will be rendered on top of
  43741. * @param handleEvents boolean indicating if the utility layer should handle events
  43742. */
  43743. constructor(
  43744. /** the original scene that will be rendered on top of */
  43745. originalScene: Scene, handleEvents?: boolean);
  43746. private _notifyObservers;
  43747. /**
  43748. * Renders the utility layers scene on top of the original scene
  43749. */
  43750. render(): void;
  43751. /**
  43752. * Disposes of the renderer
  43753. */
  43754. dispose(): void;
  43755. private _updateCamera;
  43756. }
  43757. }
  43758. declare module "babylonjs/Gizmos/gizmo" {
  43759. import { Nullable } from "babylonjs/types";
  43760. import { IDisposable } from "babylonjs/scene";
  43761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43762. import { Mesh } from "babylonjs/Meshes/mesh";
  43763. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43764. /**
  43765. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43766. */
  43767. export class Gizmo implements IDisposable {
  43768. /** The utility layer the gizmo will be added to */
  43769. gizmoLayer: UtilityLayerRenderer;
  43770. /**
  43771. * The root mesh of the gizmo
  43772. */
  43773. _rootMesh: Mesh;
  43774. private _attachedMesh;
  43775. /**
  43776. * Ratio for the scale of the gizmo (Default: 1)
  43777. */
  43778. scaleRatio: number;
  43779. /**
  43780. * If a custom mesh has been set (Default: false)
  43781. */
  43782. protected _customMeshSet: boolean;
  43783. /**
  43784. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43785. * * When set, interactions will be enabled
  43786. */
  43787. attachedMesh: Nullable<AbstractMesh>;
  43788. /**
  43789. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43790. * @param mesh The mesh to replace the default mesh of the gizmo
  43791. */
  43792. setCustomMesh(mesh: Mesh): void;
  43793. /**
  43794. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43795. */
  43796. updateGizmoRotationToMatchAttachedMesh: boolean;
  43797. /**
  43798. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43799. */
  43800. updateGizmoPositionToMatchAttachedMesh: boolean;
  43801. /**
  43802. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43803. */
  43804. updateScale: boolean;
  43805. protected _interactionsEnabled: boolean;
  43806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43807. private _beforeRenderObserver;
  43808. private _tempVector;
  43809. /**
  43810. * Creates a gizmo
  43811. * @param gizmoLayer The utility layer the gizmo will be added to
  43812. */
  43813. constructor(
  43814. /** The utility layer the gizmo will be added to */
  43815. gizmoLayer?: UtilityLayerRenderer);
  43816. /**
  43817. * Updates the gizmo to match the attached mesh's position/rotation
  43818. */
  43819. protected _update(): void;
  43820. /**
  43821. * Disposes of the gizmo
  43822. */
  43823. dispose(): void;
  43824. }
  43825. }
  43826. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43827. import { Observable } from "babylonjs/Misc/observable";
  43828. import { Nullable } from "babylonjs/types";
  43829. import { Vector3 } from "babylonjs/Maths/math.vector";
  43830. import { Color3 } from "babylonjs/Maths/math.color";
  43831. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43833. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43834. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43835. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43836. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43837. import { Scene } from "babylonjs/scene";
  43838. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43839. /**
  43840. * Single plane drag gizmo
  43841. */
  43842. export class PlaneDragGizmo extends Gizmo {
  43843. /**
  43844. * Drag behavior responsible for the gizmos dragging interactions
  43845. */
  43846. dragBehavior: PointerDragBehavior;
  43847. private _pointerObserver;
  43848. /**
  43849. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43850. */
  43851. snapDistance: number;
  43852. /**
  43853. * Event that fires each time the gizmo snaps to a new location.
  43854. * * snapDistance is the the change in distance
  43855. */
  43856. onSnapObservable: Observable<{
  43857. snapDistance: number;
  43858. }>;
  43859. private _plane;
  43860. private _coloredMaterial;
  43861. private _hoverMaterial;
  43862. private _isEnabled;
  43863. private _parent;
  43864. /** @hidden */
  43865. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43866. /** @hidden */
  43867. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43868. /**
  43869. * Creates a PlaneDragGizmo
  43870. * @param gizmoLayer The utility layer the gizmo will be added to
  43871. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43872. * @param color The color of the gizmo
  43873. */
  43874. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43875. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43876. /**
  43877. * If the gizmo is enabled
  43878. */
  43879. isEnabled: boolean;
  43880. /**
  43881. * Disposes of the gizmo
  43882. */
  43883. dispose(): void;
  43884. }
  43885. }
  43886. declare module "babylonjs/Gizmos/positionGizmo" {
  43887. import { Observable } from "babylonjs/Misc/observable";
  43888. import { Nullable } from "babylonjs/types";
  43889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43890. import { Mesh } from "babylonjs/Meshes/mesh";
  43891. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43892. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43893. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43894. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43895. /**
  43896. * Gizmo that enables dragging a mesh along 3 axis
  43897. */
  43898. export class PositionGizmo extends Gizmo {
  43899. /**
  43900. * Internal gizmo used for interactions on the x axis
  43901. */
  43902. xGizmo: AxisDragGizmo;
  43903. /**
  43904. * Internal gizmo used for interactions on the y axis
  43905. */
  43906. yGizmo: AxisDragGizmo;
  43907. /**
  43908. * Internal gizmo used for interactions on the z axis
  43909. */
  43910. zGizmo: AxisDragGizmo;
  43911. /**
  43912. * Internal gizmo used for interactions on the yz plane
  43913. */
  43914. xPlaneGizmo: PlaneDragGizmo;
  43915. /**
  43916. * Internal gizmo used for interactions on the xz plane
  43917. */
  43918. yPlaneGizmo: PlaneDragGizmo;
  43919. /**
  43920. * Internal gizmo used for interactions on the xy plane
  43921. */
  43922. zPlaneGizmo: PlaneDragGizmo;
  43923. /**
  43924. * private variables
  43925. */
  43926. private _meshAttached;
  43927. private _updateGizmoRotationToMatchAttachedMesh;
  43928. private _snapDistance;
  43929. private _scaleRatio;
  43930. /** Fires an event when any of it's sub gizmos are dragged */
  43931. onDragStartObservable: Observable<unknown>;
  43932. /** Fires an event when any of it's sub gizmos are released from dragging */
  43933. onDragEndObservable: Observable<unknown>;
  43934. /**
  43935. * If set to true, planar drag is enabled
  43936. */
  43937. private _planarGizmoEnabled;
  43938. attachedMesh: Nullable<AbstractMesh>;
  43939. /**
  43940. * Creates a PositionGizmo
  43941. * @param gizmoLayer The utility layer the gizmo will be added to
  43942. */
  43943. constructor(gizmoLayer?: UtilityLayerRenderer);
  43944. /**
  43945. * If the planar drag gizmo is enabled
  43946. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43947. */
  43948. planarGizmoEnabled: boolean;
  43949. updateGizmoRotationToMatchAttachedMesh: boolean;
  43950. /**
  43951. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43952. */
  43953. snapDistance: number;
  43954. /**
  43955. * Ratio for the scale of the gizmo (Default: 1)
  43956. */
  43957. scaleRatio: number;
  43958. /**
  43959. * Disposes of the gizmo
  43960. */
  43961. dispose(): void;
  43962. /**
  43963. * CustomMeshes are not supported by this gizmo
  43964. * @param mesh The mesh to replace the default mesh of the gizmo
  43965. */
  43966. setCustomMesh(mesh: Mesh): void;
  43967. }
  43968. }
  43969. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43970. import { Observable } from "babylonjs/Misc/observable";
  43971. import { Nullable } from "babylonjs/types";
  43972. import { Vector3 } from "babylonjs/Maths/math.vector";
  43973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43975. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43976. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43977. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43978. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43979. import { Scene } from "babylonjs/scene";
  43980. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43981. import { Color3 } from "babylonjs/Maths/math.color";
  43982. /**
  43983. * Single axis drag gizmo
  43984. */
  43985. export class AxisDragGizmo extends Gizmo {
  43986. /**
  43987. * Drag behavior responsible for the gizmos dragging interactions
  43988. */
  43989. dragBehavior: PointerDragBehavior;
  43990. private _pointerObserver;
  43991. /**
  43992. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43993. */
  43994. snapDistance: number;
  43995. /**
  43996. * Event that fires each time the gizmo snaps to a new location.
  43997. * * snapDistance is the the change in distance
  43998. */
  43999. onSnapObservable: Observable<{
  44000. snapDistance: number;
  44001. }>;
  44002. private _isEnabled;
  44003. private _parent;
  44004. private _arrow;
  44005. private _coloredMaterial;
  44006. private _hoverMaterial;
  44007. /** @hidden */
  44008. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44009. /** @hidden */
  44010. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44011. /**
  44012. * Creates an AxisDragGizmo
  44013. * @param gizmoLayer The utility layer the gizmo will be added to
  44014. * @param dragAxis The axis which the gizmo will be able to drag on
  44015. * @param color The color of the gizmo
  44016. */
  44017. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44018. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44019. /**
  44020. * If the gizmo is enabled
  44021. */
  44022. isEnabled: boolean;
  44023. /**
  44024. * Disposes of the gizmo
  44025. */
  44026. dispose(): void;
  44027. }
  44028. }
  44029. declare module "babylonjs/Debug/axesViewer" {
  44030. import { Vector3 } from "babylonjs/Maths/math.vector";
  44031. import { Nullable } from "babylonjs/types";
  44032. import { Scene } from "babylonjs/scene";
  44033. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44034. /**
  44035. * The Axes viewer will show 3 axes in a specific point in space
  44036. */
  44037. export class AxesViewer {
  44038. private _xAxis;
  44039. private _yAxis;
  44040. private _zAxis;
  44041. private _scaleLinesFactor;
  44042. private _instanced;
  44043. /**
  44044. * Gets the hosting scene
  44045. */
  44046. scene: Scene;
  44047. /**
  44048. * Gets or sets a number used to scale line length
  44049. */
  44050. scaleLines: number;
  44051. /** Gets the node hierarchy used to render x-axis */
  44052. readonly xAxis: TransformNode;
  44053. /** Gets the node hierarchy used to render y-axis */
  44054. readonly yAxis: TransformNode;
  44055. /** Gets the node hierarchy used to render z-axis */
  44056. readonly zAxis: TransformNode;
  44057. /**
  44058. * Creates a new AxesViewer
  44059. * @param scene defines the hosting scene
  44060. * @param scaleLines defines a number used to scale line length (1 by default)
  44061. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44062. * @param xAxis defines the node hierarchy used to render the x-axis
  44063. * @param yAxis defines the node hierarchy used to render the y-axis
  44064. * @param zAxis defines the node hierarchy used to render the z-axis
  44065. */
  44066. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44067. /**
  44068. * Force the viewer to update
  44069. * @param position defines the position of the viewer
  44070. * @param xaxis defines the x axis of the viewer
  44071. * @param yaxis defines the y axis of the viewer
  44072. * @param zaxis defines the z axis of the viewer
  44073. */
  44074. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44075. /**
  44076. * Creates an instance of this axes viewer.
  44077. * @returns a new axes viewer with instanced meshes
  44078. */
  44079. createInstance(): AxesViewer;
  44080. /** Releases resources */
  44081. dispose(): void;
  44082. private static _SetRenderingGroupId;
  44083. }
  44084. }
  44085. declare module "babylonjs/Debug/boneAxesViewer" {
  44086. import { Nullable } from "babylonjs/types";
  44087. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44088. import { Vector3 } from "babylonjs/Maths/math.vector";
  44089. import { Mesh } from "babylonjs/Meshes/mesh";
  44090. import { Bone } from "babylonjs/Bones/bone";
  44091. import { Scene } from "babylonjs/scene";
  44092. /**
  44093. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44094. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44095. */
  44096. export class BoneAxesViewer extends AxesViewer {
  44097. /**
  44098. * Gets or sets the target mesh where to display the axes viewer
  44099. */
  44100. mesh: Nullable<Mesh>;
  44101. /**
  44102. * Gets or sets the target bone where to display the axes viewer
  44103. */
  44104. bone: Nullable<Bone>;
  44105. /** Gets current position */
  44106. pos: Vector3;
  44107. /** Gets direction of X axis */
  44108. xaxis: Vector3;
  44109. /** Gets direction of Y axis */
  44110. yaxis: Vector3;
  44111. /** Gets direction of Z axis */
  44112. zaxis: Vector3;
  44113. /**
  44114. * Creates a new BoneAxesViewer
  44115. * @param scene defines the hosting scene
  44116. * @param bone defines the target bone
  44117. * @param mesh defines the target mesh
  44118. * @param scaleLines defines a scaling factor for line length (1 by default)
  44119. */
  44120. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44121. /**
  44122. * Force the viewer to update
  44123. */
  44124. update(): void;
  44125. /** Releases resources */
  44126. dispose(): void;
  44127. }
  44128. }
  44129. declare module "babylonjs/Debug/debugLayer" {
  44130. import { Scene } from "babylonjs/scene";
  44131. /**
  44132. * Interface used to define scene explorer extensibility option
  44133. */
  44134. export interface IExplorerExtensibilityOption {
  44135. /**
  44136. * Define the option label
  44137. */
  44138. label: string;
  44139. /**
  44140. * Defines the action to execute on click
  44141. */
  44142. action: (entity: any) => void;
  44143. }
  44144. /**
  44145. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44146. */
  44147. export interface IExplorerExtensibilityGroup {
  44148. /**
  44149. * Defines a predicate to test if a given type mut be extended
  44150. */
  44151. predicate: (entity: any) => boolean;
  44152. /**
  44153. * Gets the list of options added to a type
  44154. */
  44155. entries: IExplorerExtensibilityOption[];
  44156. }
  44157. /**
  44158. * Interface used to define the options to use to create the Inspector
  44159. */
  44160. export interface IInspectorOptions {
  44161. /**
  44162. * Display in overlay mode (default: false)
  44163. */
  44164. overlay?: boolean;
  44165. /**
  44166. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44167. */
  44168. globalRoot?: HTMLElement;
  44169. /**
  44170. * Display the Scene explorer
  44171. */
  44172. showExplorer?: boolean;
  44173. /**
  44174. * Display the property inspector
  44175. */
  44176. showInspector?: boolean;
  44177. /**
  44178. * Display in embed mode (both panes on the right)
  44179. */
  44180. embedMode?: boolean;
  44181. /**
  44182. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44183. */
  44184. handleResize?: boolean;
  44185. /**
  44186. * Allow the panes to popup (default: true)
  44187. */
  44188. enablePopup?: boolean;
  44189. /**
  44190. * Allow the panes to be closed by users (default: true)
  44191. */
  44192. enableClose?: boolean;
  44193. /**
  44194. * Optional list of extensibility entries
  44195. */
  44196. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44197. /**
  44198. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44199. */
  44200. inspectorURL?: string;
  44201. }
  44202. module "babylonjs/scene" {
  44203. interface Scene {
  44204. /**
  44205. * @hidden
  44206. * Backing field
  44207. */
  44208. _debugLayer: DebugLayer;
  44209. /**
  44210. * Gets the debug layer (aka Inspector) associated with the scene
  44211. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44212. */
  44213. debugLayer: DebugLayer;
  44214. }
  44215. }
  44216. /**
  44217. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44218. * what is happening in your scene
  44219. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44220. */
  44221. export class DebugLayer {
  44222. /**
  44223. * Define the url to get the inspector script from.
  44224. * By default it uses the babylonjs CDN.
  44225. * @ignoreNaming
  44226. */
  44227. static InspectorURL: string;
  44228. private _scene;
  44229. private BJSINSPECTOR;
  44230. private _onPropertyChangedObservable?;
  44231. /**
  44232. * Observable triggered when a property is changed through the inspector.
  44233. */
  44234. readonly onPropertyChangedObservable: any;
  44235. /**
  44236. * Instantiates a new debug layer.
  44237. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44238. * what is happening in your scene
  44239. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44240. * @param scene Defines the scene to inspect
  44241. */
  44242. constructor(scene: Scene);
  44243. /** Creates the inspector window. */
  44244. private _createInspector;
  44245. /**
  44246. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44247. * @param entity defines the entity to select
  44248. * @param lineContainerTitle defines the specific block to highlight
  44249. */
  44250. select(entity: any, lineContainerTitle?: string): void;
  44251. /** Get the inspector from bundle or global */
  44252. private _getGlobalInspector;
  44253. /**
  44254. * Get if the inspector is visible or not.
  44255. * @returns true if visible otherwise, false
  44256. */
  44257. isVisible(): boolean;
  44258. /**
  44259. * Hide the inspector and close its window.
  44260. */
  44261. hide(): void;
  44262. /**
  44263. * Launch the debugLayer.
  44264. * @param config Define the configuration of the inspector
  44265. * @return a promise fulfilled when the debug layer is visible
  44266. */
  44267. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44268. }
  44269. }
  44270. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44271. import { Nullable } from "babylonjs/types";
  44272. import { Scene } from "babylonjs/scene";
  44273. import { Vector4 } from "babylonjs/Maths/math.vector";
  44274. import { Color4 } from "babylonjs/Maths/math.color";
  44275. import { Mesh } from "babylonjs/Meshes/mesh";
  44276. /**
  44277. * Class containing static functions to help procedurally build meshes
  44278. */
  44279. export class BoxBuilder {
  44280. /**
  44281. * Creates a box mesh
  44282. * * The parameter `size` sets the size (float) of each box side (default 1)
  44283. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44284. * * 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)
  44285. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44286. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44287. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44289. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44290. * @param name defines the name of the mesh
  44291. * @param options defines the options used to create the mesh
  44292. * @param scene defines the hosting scene
  44293. * @returns the box mesh
  44294. */
  44295. static CreateBox(name: string, options: {
  44296. size?: number;
  44297. width?: number;
  44298. height?: number;
  44299. depth?: number;
  44300. faceUV?: Vector4[];
  44301. faceColors?: Color4[];
  44302. sideOrientation?: number;
  44303. frontUVs?: Vector4;
  44304. backUVs?: Vector4;
  44305. wrap?: boolean;
  44306. topBaseAt?: number;
  44307. bottomBaseAt?: number;
  44308. updatable?: boolean;
  44309. }, scene?: Nullable<Scene>): Mesh;
  44310. }
  44311. }
  44312. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44313. import { Vector4 } from "babylonjs/Maths/math.vector";
  44314. import { Mesh } from "babylonjs/Meshes/mesh";
  44315. /**
  44316. * Class containing static functions to help procedurally build meshes
  44317. */
  44318. export class SphereBuilder {
  44319. /**
  44320. * Creates a sphere mesh
  44321. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44322. * * 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`)
  44323. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44324. * * 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
  44325. * * 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)
  44326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44329. * @param name defines the name of the mesh
  44330. * @param options defines the options used to create the mesh
  44331. * @param scene defines the hosting scene
  44332. * @returns the sphere mesh
  44333. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44334. */
  44335. static CreateSphere(name: string, options: {
  44336. segments?: number;
  44337. diameter?: number;
  44338. diameterX?: number;
  44339. diameterY?: number;
  44340. diameterZ?: number;
  44341. arc?: number;
  44342. slice?: number;
  44343. sideOrientation?: number;
  44344. frontUVs?: Vector4;
  44345. backUVs?: Vector4;
  44346. updatable?: boolean;
  44347. }, scene: any): Mesh;
  44348. }
  44349. }
  44350. declare module "babylonjs/Debug/physicsViewer" {
  44351. import { Nullable } from "babylonjs/types";
  44352. import { Scene } from "babylonjs/scene";
  44353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44354. import { Mesh } from "babylonjs/Meshes/mesh";
  44355. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44356. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44357. /**
  44358. * Used to show the physics impostor around the specific mesh
  44359. */
  44360. export class PhysicsViewer {
  44361. /** @hidden */
  44362. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44363. /** @hidden */
  44364. protected _meshes: Array<Nullable<AbstractMesh>>;
  44365. /** @hidden */
  44366. protected _scene: Nullable<Scene>;
  44367. /** @hidden */
  44368. protected _numMeshes: number;
  44369. /** @hidden */
  44370. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44371. private _renderFunction;
  44372. private _utilityLayer;
  44373. private _debugBoxMesh;
  44374. private _debugSphereMesh;
  44375. private _debugCylinderMesh;
  44376. private _debugMaterial;
  44377. private _debugMeshMeshes;
  44378. /**
  44379. * Creates a new PhysicsViewer
  44380. * @param scene defines the hosting scene
  44381. */
  44382. constructor(scene: Scene);
  44383. /** @hidden */
  44384. protected _updateDebugMeshes(): void;
  44385. /**
  44386. * Renders a specified physic impostor
  44387. * @param impostor defines the impostor to render
  44388. * @param targetMesh defines the mesh represented by the impostor
  44389. * @returns the new debug mesh used to render the impostor
  44390. */
  44391. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44392. /**
  44393. * Hides a specified physic impostor
  44394. * @param impostor defines the impostor to hide
  44395. */
  44396. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44397. private _getDebugMaterial;
  44398. private _getDebugBoxMesh;
  44399. private _getDebugSphereMesh;
  44400. private _getDebugCylinderMesh;
  44401. private _getDebugMeshMesh;
  44402. private _getDebugMesh;
  44403. /** Releases all resources */
  44404. dispose(): void;
  44405. }
  44406. }
  44407. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44408. import { Vector3 } from "babylonjs/Maths/math.vector";
  44409. import { Color4 } from "babylonjs/Maths/math.color";
  44410. import { Nullable } from "babylonjs/types";
  44411. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44412. import { Scene } from "babylonjs/scene";
  44413. /**
  44414. * Class containing static functions to help procedurally build meshes
  44415. */
  44416. export class LinesBuilder {
  44417. /**
  44418. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44419. * * 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
  44420. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44421. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44422. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44423. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44424. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44425. * * 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
  44426. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44428. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44429. * @param name defines the name of the new line system
  44430. * @param options defines the options used to create the line system
  44431. * @param scene defines the hosting scene
  44432. * @returns a new line system mesh
  44433. */
  44434. static CreateLineSystem(name: string, options: {
  44435. lines: Vector3[][];
  44436. updatable?: boolean;
  44437. instance?: Nullable<LinesMesh>;
  44438. colors?: Nullable<Color4[][]>;
  44439. useVertexAlpha?: boolean;
  44440. }, scene: Nullable<Scene>): LinesMesh;
  44441. /**
  44442. * Creates a line mesh
  44443. * 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
  44444. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44445. * * The parameter `points` is an array successive Vector3
  44446. * * 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
  44447. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44448. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44449. * * When updating an instance, remember that only point positions can change, not the number of points
  44450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44451. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44452. * @param name defines the name of the new line system
  44453. * @param options defines the options used to create the line system
  44454. * @param scene defines the hosting scene
  44455. * @returns a new line mesh
  44456. */
  44457. static CreateLines(name: string, options: {
  44458. points: Vector3[];
  44459. updatable?: boolean;
  44460. instance?: Nullable<LinesMesh>;
  44461. colors?: Color4[];
  44462. useVertexAlpha?: boolean;
  44463. }, scene?: Nullable<Scene>): LinesMesh;
  44464. /**
  44465. * Creates a dashed line mesh
  44466. * * 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
  44467. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44468. * * The parameter `points` is an array successive Vector3
  44469. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44470. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44471. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44472. * * 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
  44473. * * When updating an instance, remember that only point positions can change, not the number of points
  44474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44475. * @param name defines the name of the mesh
  44476. * @param options defines the options used to create the mesh
  44477. * @param scene defines the hosting scene
  44478. * @returns the dashed line mesh
  44479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44480. */
  44481. static CreateDashedLines(name: string, options: {
  44482. points: Vector3[];
  44483. dashSize?: number;
  44484. gapSize?: number;
  44485. dashNb?: number;
  44486. updatable?: boolean;
  44487. instance?: LinesMesh;
  44488. }, scene?: Nullable<Scene>): LinesMesh;
  44489. }
  44490. }
  44491. declare module "babylonjs/Debug/rayHelper" {
  44492. import { Nullable } from "babylonjs/types";
  44493. import { Ray } from "babylonjs/Culling/ray";
  44494. import { Vector3 } from "babylonjs/Maths/math.vector";
  44495. import { Color3 } from "babylonjs/Maths/math.color";
  44496. import { Scene } from "babylonjs/scene";
  44497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44498. import "babylonjs/Meshes/Builders/linesBuilder";
  44499. /**
  44500. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44501. * in order to better appreciate the issue one might have.
  44502. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44503. */
  44504. export class RayHelper {
  44505. /**
  44506. * Defines the ray we are currently tryin to visualize.
  44507. */
  44508. ray: Nullable<Ray>;
  44509. private _renderPoints;
  44510. private _renderLine;
  44511. private _renderFunction;
  44512. private _scene;
  44513. private _updateToMeshFunction;
  44514. private _attachedToMesh;
  44515. private _meshSpaceDirection;
  44516. private _meshSpaceOrigin;
  44517. /**
  44518. * Helper function to create a colored helper in a scene in one line.
  44519. * @param ray Defines the ray we are currently tryin to visualize
  44520. * @param scene Defines the scene the ray is used in
  44521. * @param color Defines the color we want to see the ray in
  44522. * @returns The newly created ray helper.
  44523. */
  44524. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44525. /**
  44526. * Instantiate a new ray helper.
  44527. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44528. * in order to better appreciate the issue one might have.
  44529. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44530. * @param ray Defines the ray we are currently tryin to visualize
  44531. */
  44532. constructor(ray: Ray);
  44533. /**
  44534. * Shows the ray we are willing to debug.
  44535. * @param scene Defines the scene the ray needs to be rendered in
  44536. * @param color Defines the color the ray needs to be rendered in
  44537. */
  44538. show(scene: Scene, color?: Color3): void;
  44539. /**
  44540. * Hides the ray we are debugging.
  44541. */
  44542. hide(): void;
  44543. private _render;
  44544. /**
  44545. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44546. * @param mesh Defines the mesh we want the helper attached to
  44547. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44548. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44549. * @param length Defines the length of the ray
  44550. */
  44551. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44552. /**
  44553. * Detach the ray helper from the mesh it has previously been attached to.
  44554. */
  44555. detachFromMesh(): void;
  44556. private _updateToMesh;
  44557. /**
  44558. * Dispose the helper and release its associated resources.
  44559. */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module "babylonjs/Debug/skeletonViewer" {
  44564. import { Color3 } from "babylonjs/Maths/math.color";
  44565. import { Scene } from "babylonjs/scene";
  44566. import { Nullable } from "babylonjs/types";
  44567. import { Skeleton } from "babylonjs/Bones/skeleton";
  44568. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44569. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44570. /**
  44571. * Class used to render a debug view of a given skeleton
  44572. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44573. */
  44574. export class SkeletonViewer {
  44575. /** defines the skeleton to render */
  44576. skeleton: Skeleton;
  44577. /** defines the mesh attached to the skeleton */
  44578. mesh: AbstractMesh;
  44579. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44580. autoUpdateBonesMatrices: boolean;
  44581. /** defines the rendering group id to use with the viewer */
  44582. renderingGroupId: number;
  44583. /** Gets or sets the color used to render the skeleton */
  44584. color: Color3;
  44585. private _scene;
  44586. private _debugLines;
  44587. private _debugMesh;
  44588. private _isEnabled;
  44589. private _renderFunction;
  44590. private _utilityLayer;
  44591. /**
  44592. * Returns the mesh used to render the bones
  44593. */
  44594. readonly debugMesh: Nullable<LinesMesh>;
  44595. /**
  44596. * Creates a new SkeletonViewer
  44597. * @param skeleton defines the skeleton to render
  44598. * @param mesh defines the mesh attached to the skeleton
  44599. * @param scene defines the hosting scene
  44600. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44601. * @param renderingGroupId defines the rendering group id to use with the viewer
  44602. */
  44603. constructor(
  44604. /** defines the skeleton to render */
  44605. skeleton: Skeleton,
  44606. /** defines the mesh attached to the skeleton */
  44607. mesh: AbstractMesh, scene: Scene,
  44608. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44609. autoUpdateBonesMatrices?: boolean,
  44610. /** defines the rendering group id to use with the viewer */
  44611. renderingGroupId?: number);
  44612. /** Gets or sets a boolean indicating if the viewer is enabled */
  44613. isEnabled: boolean;
  44614. private _getBonePosition;
  44615. private _getLinesForBonesWithLength;
  44616. private _getLinesForBonesNoLength;
  44617. /** Update the viewer to sync with current skeleton state */
  44618. update(): void;
  44619. /** Release associated resources */
  44620. dispose(): void;
  44621. }
  44622. }
  44623. declare module "babylonjs/Debug/index" {
  44624. export * from "babylonjs/Debug/axesViewer";
  44625. export * from "babylonjs/Debug/boneAxesViewer";
  44626. export * from "babylonjs/Debug/debugLayer";
  44627. export * from "babylonjs/Debug/physicsViewer";
  44628. export * from "babylonjs/Debug/rayHelper";
  44629. export * from "babylonjs/Debug/skeletonViewer";
  44630. }
  44631. declare module "babylonjs/Engines/nullEngine" {
  44632. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44633. import { Scene } from "babylonjs/scene";
  44634. import { Engine } from "babylonjs/Engines/engine";
  44635. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44636. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44638. import { Effect } from "babylonjs/Materials/effect";
  44639. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44640. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44641. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44642. /**
  44643. * Options to create the null engine
  44644. */
  44645. export class NullEngineOptions {
  44646. /**
  44647. * Render width (Default: 512)
  44648. */
  44649. renderWidth: number;
  44650. /**
  44651. * Render height (Default: 256)
  44652. */
  44653. renderHeight: number;
  44654. /**
  44655. * Texture size (Default: 512)
  44656. */
  44657. textureSize: number;
  44658. /**
  44659. * If delta time between frames should be constant
  44660. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44661. */
  44662. deterministicLockstep: boolean;
  44663. /**
  44664. * Maximum about of steps between frames (Default: 4)
  44665. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44666. */
  44667. lockstepMaxSteps: number;
  44668. }
  44669. /**
  44670. * The null engine class provides support for headless version of babylon.js.
  44671. * This can be used in server side scenario or for testing purposes
  44672. */
  44673. export class NullEngine extends Engine {
  44674. private _options;
  44675. /**
  44676. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44677. */
  44678. isDeterministicLockStep(): boolean;
  44679. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44680. getLockstepMaxSteps(): number;
  44681. /**
  44682. * Sets hardware scaling, used to save performance if needed
  44683. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44684. */
  44685. getHardwareScalingLevel(): number;
  44686. constructor(options?: NullEngineOptions);
  44687. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44688. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44689. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44690. getRenderWidth(useScreen?: boolean): number;
  44691. getRenderHeight(useScreen?: boolean): number;
  44692. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44693. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44694. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44695. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44696. bindSamplers(effect: Effect): void;
  44697. enableEffect(effect: Effect): void;
  44698. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44699. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44700. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44701. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44702. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44703. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44704. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44705. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44706. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44707. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44708. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44709. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44710. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44711. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44712. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44713. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44714. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44715. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44716. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44717. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44718. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44719. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44720. bindBuffers(vertexBuffers: {
  44721. [key: string]: VertexBuffer;
  44722. }, indexBuffer: DataBuffer, effect: Effect): void;
  44723. wipeCaches(bruteForce?: boolean): void;
  44724. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44725. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44726. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44727. /** @hidden */
  44728. _createTexture(): WebGLTexture;
  44729. /** @hidden */
  44730. _releaseTexture(texture: InternalTexture): void;
  44731. 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;
  44732. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44733. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44734. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44735. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44736. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44737. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44738. areAllEffectsReady(): boolean;
  44739. /**
  44740. * @hidden
  44741. * Get the current error code of the webGL context
  44742. * @returns the error code
  44743. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44744. */
  44745. getError(): number;
  44746. /** @hidden */
  44747. _getUnpackAlignement(): number;
  44748. /** @hidden */
  44749. _unpackFlipY(value: boolean): void;
  44750. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44751. /**
  44752. * Updates a dynamic vertex buffer.
  44753. * @param vertexBuffer the vertex buffer to update
  44754. * @param data the data used to update the vertex buffer
  44755. * @param byteOffset the byte offset of the data (optional)
  44756. * @param byteLength the byte length of the data (optional)
  44757. */
  44758. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44759. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44760. /** @hidden */
  44761. _bindTexture(channel: number, texture: InternalTexture): void;
  44762. /** @hidden */
  44763. _releaseBuffer(buffer: DataBuffer): boolean;
  44764. releaseEffects(): void;
  44765. displayLoadingUI(): void;
  44766. hideLoadingUI(): void;
  44767. /** @hidden */
  44768. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44769. /** @hidden */
  44770. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44771. /** @hidden */
  44772. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44773. /** @hidden */
  44774. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44775. }
  44776. }
  44777. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44778. import { Nullable, int } from "babylonjs/types";
  44779. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44780. /** @hidden */
  44781. export class _OcclusionDataStorage {
  44782. /** @hidden */
  44783. occlusionInternalRetryCounter: number;
  44784. /** @hidden */
  44785. isOcclusionQueryInProgress: boolean;
  44786. /** @hidden */
  44787. isOccluded: boolean;
  44788. /** @hidden */
  44789. occlusionRetryCount: number;
  44790. /** @hidden */
  44791. occlusionType: number;
  44792. /** @hidden */
  44793. occlusionQueryAlgorithmType: number;
  44794. }
  44795. module "babylonjs/Engines/engine" {
  44796. interface Engine {
  44797. /**
  44798. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44799. * @return the new query
  44800. */
  44801. createQuery(): WebGLQuery;
  44802. /**
  44803. * Delete and release a webGL query
  44804. * @param query defines the query to delete
  44805. * @return the current engine
  44806. */
  44807. deleteQuery(query: WebGLQuery): Engine;
  44808. /**
  44809. * Check if a given query has resolved and got its value
  44810. * @param query defines the query to check
  44811. * @returns true if the query got its value
  44812. */
  44813. isQueryResultAvailable(query: WebGLQuery): boolean;
  44814. /**
  44815. * Gets the value of a given query
  44816. * @param query defines the query to check
  44817. * @returns the value of the query
  44818. */
  44819. getQueryResult(query: WebGLQuery): number;
  44820. /**
  44821. * Initiates an occlusion query
  44822. * @param algorithmType defines the algorithm to use
  44823. * @param query defines the query to use
  44824. * @returns the current engine
  44825. * @see http://doc.babylonjs.com/features/occlusionquery
  44826. */
  44827. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44828. /**
  44829. * Ends an occlusion query
  44830. * @see http://doc.babylonjs.com/features/occlusionquery
  44831. * @param algorithmType defines the algorithm to use
  44832. * @returns the current engine
  44833. */
  44834. endOcclusionQuery(algorithmType: number): Engine;
  44835. /**
  44836. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44837. * Please note that only one query can be issued at a time
  44838. * @returns a time token used to track the time span
  44839. */
  44840. startTimeQuery(): Nullable<_TimeToken>;
  44841. /**
  44842. * Ends a time query
  44843. * @param token defines the token used to measure the time span
  44844. * @returns the time spent (in ns)
  44845. */
  44846. endTimeQuery(token: _TimeToken): int;
  44847. /** @hidden */
  44848. _currentNonTimestampToken: Nullable<_TimeToken>;
  44849. /** @hidden */
  44850. _createTimeQuery(): WebGLQuery;
  44851. /** @hidden */
  44852. _deleteTimeQuery(query: WebGLQuery): void;
  44853. /** @hidden */
  44854. _getGlAlgorithmType(algorithmType: number): number;
  44855. /** @hidden */
  44856. _getTimeQueryResult(query: WebGLQuery): any;
  44857. /** @hidden */
  44858. _getTimeQueryAvailability(query: WebGLQuery): any;
  44859. }
  44860. }
  44861. module "babylonjs/Meshes/abstractMesh" {
  44862. interface AbstractMesh {
  44863. /**
  44864. * Backing filed
  44865. * @hidden
  44866. */
  44867. __occlusionDataStorage: _OcclusionDataStorage;
  44868. /**
  44869. * Access property
  44870. * @hidden
  44871. */
  44872. _occlusionDataStorage: _OcclusionDataStorage;
  44873. /**
  44874. * 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.
  44875. * The default value is -1 which means don't break the query and wait till the result
  44876. * @see http://doc.babylonjs.com/features/occlusionquery
  44877. */
  44878. occlusionRetryCount: number;
  44879. /**
  44880. * 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:
  44881. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44882. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44883. * * 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.
  44884. * @see http://doc.babylonjs.com/features/occlusionquery
  44885. */
  44886. occlusionType: number;
  44887. /**
  44888. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44889. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44890. * * 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.
  44891. * @see http://doc.babylonjs.com/features/occlusionquery
  44892. */
  44893. occlusionQueryAlgorithmType: number;
  44894. /**
  44895. * 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
  44896. * @see http://doc.babylonjs.com/features/occlusionquery
  44897. */
  44898. isOccluded: boolean;
  44899. /**
  44900. * Flag to check the progress status of the query
  44901. * @see http://doc.babylonjs.com/features/occlusionquery
  44902. */
  44903. isOcclusionQueryInProgress: boolean;
  44904. }
  44905. }
  44906. }
  44907. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44908. import { Nullable } from "babylonjs/types";
  44909. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44910. /** @hidden */
  44911. export var _forceTransformFeedbackToBundle: boolean;
  44912. module "babylonjs/Engines/engine" {
  44913. interface Engine {
  44914. /**
  44915. * Creates a webGL transform feedback object
  44916. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44917. * @returns the webGL transform feedback object
  44918. */
  44919. createTransformFeedback(): WebGLTransformFeedback;
  44920. /**
  44921. * Delete a webGL transform feedback object
  44922. * @param value defines the webGL transform feedback object to delete
  44923. */
  44924. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44925. /**
  44926. * Bind a webGL transform feedback object to the webgl context
  44927. * @param value defines the webGL transform feedback object to bind
  44928. */
  44929. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44930. /**
  44931. * Begins a transform feedback operation
  44932. * @param usePoints defines if points or triangles must be used
  44933. */
  44934. beginTransformFeedback(usePoints: boolean): void;
  44935. /**
  44936. * Ends a transform feedback operation
  44937. */
  44938. endTransformFeedback(): void;
  44939. /**
  44940. * Specify the varyings to use with transform feedback
  44941. * @param program defines the associated webGL program
  44942. * @param value defines the list of strings representing the varying names
  44943. */
  44944. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44945. /**
  44946. * Bind a webGL buffer for a transform feedback operation
  44947. * @param value defines the webGL buffer to bind
  44948. */
  44949. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44950. }
  44951. }
  44952. }
  44953. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44954. import { Scene } from "babylonjs/scene";
  44955. import { Engine } from "babylonjs/Engines/engine";
  44956. import { Texture } from "babylonjs/Materials/Textures/texture";
  44957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44958. import "babylonjs/Engines/Extensions/engine.multiRender";
  44959. /**
  44960. * Creation options of the multi render target texture.
  44961. */
  44962. export interface IMultiRenderTargetOptions {
  44963. /**
  44964. * Define if the texture needs to create mip maps after render.
  44965. */
  44966. generateMipMaps?: boolean;
  44967. /**
  44968. * Define the types of all the draw buffers we want to create
  44969. */
  44970. types?: number[];
  44971. /**
  44972. * Define the sampling modes of all the draw buffers we want to create
  44973. */
  44974. samplingModes?: number[];
  44975. /**
  44976. * Define if a depth buffer is required
  44977. */
  44978. generateDepthBuffer?: boolean;
  44979. /**
  44980. * Define if a stencil buffer is required
  44981. */
  44982. generateStencilBuffer?: boolean;
  44983. /**
  44984. * Define if a depth texture is required instead of a depth buffer
  44985. */
  44986. generateDepthTexture?: boolean;
  44987. /**
  44988. * Define the number of desired draw buffers
  44989. */
  44990. textureCount?: number;
  44991. /**
  44992. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44993. */
  44994. doNotChangeAspectRatio?: boolean;
  44995. /**
  44996. * Define the default type of the buffers we are creating
  44997. */
  44998. defaultType?: number;
  44999. }
  45000. /**
  45001. * A multi render target, like a render target provides the ability to render to a texture.
  45002. * Unlike the render target, it can render to several draw buffers in one draw.
  45003. * This is specially interesting in deferred rendering or for any effects requiring more than
  45004. * just one color from a single pass.
  45005. */
  45006. export class MultiRenderTarget extends RenderTargetTexture {
  45007. private _internalTextures;
  45008. private _textures;
  45009. private _multiRenderTargetOptions;
  45010. /**
  45011. * Get if draw buffers are currently supported by the used hardware and browser.
  45012. */
  45013. readonly isSupported: boolean;
  45014. /**
  45015. * Get the list of textures generated by the multi render target.
  45016. */
  45017. readonly textures: Texture[];
  45018. /**
  45019. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45020. */
  45021. readonly depthTexture: Texture;
  45022. /**
  45023. * Set the wrapping mode on U of all the textures we are rendering to.
  45024. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45025. */
  45026. wrapU: number;
  45027. /**
  45028. * Set the wrapping mode on V of all the textures we are rendering to.
  45029. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45030. */
  45031. wrapV: number;
  45032. /**
  45033. * Instantiate a new multi render target texture.
  45034. * A multi render target, like a render target provides the ability to render to a texture.
  45035. * Unlike the render target, it can render to several draw buffers in one draw.
  45036. * This is specially interesting in deferred rendering or for any effects requiring more than
  45037. * just one color from a single pass.
  45038. * @param name Define the name of the texture
  45039. * @param size Define the size of the buffers to render to
  45040. * @param count Define the number of target we are rendering into
  45041. * @param scene Define the scene the texture belongs to
  45042. * @param options Define the options used to create the multi render target
  45043. */
  45044. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45045. /** @hidden */
  45046. _rebuild(): void;
  45047. private _createInternalTextures;
  45048. private _createTextures;
  45049. /**
  45050. * Define the number of samples used if MSAA is enabled.
  45051. */
  45052. samples: number;
  45053. /**
  45054. * Resize all the textures in the multi render target.
  45055. * Be carrefull as it will recreate all the data in the new texture.
  45056. * @param size Define the new size
  45057. */
  45058. resize(size: any): void;
  45059. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45060. /**
  45061. * Dispose the render targets and their associated resources
  45062. */
  45063. dispose(): void;
  45064. /**
  45065. * Release all the underlying texture used as draw buffers.
  45066. */
  45067. releaseInternalTextures(): void;
  45068. }
  45069. }
  45070. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45071. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45072. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45073. import { Nullable } from "babylonjs/types";
  45074. module "babylonjs/Engines/engine" {
  45075. interface Engine {
  45076. /**
  45077. * Unbind a list of render target textures from the webGL context
  45078. * This is used only when drawBuffer extension or webGL2 are active
  45079. * @param textures defines the render target textures to unbind
  45080. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45081. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45082. */
  45083. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45084. /**
  45085. * Create a multi render target texture
  45086. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45087. * @param size defines the size of the texture
  45088. * @param options defines the creation options
  45089. * @returns the cube texture as an InternalTexture
  45090. */
  45091. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45092. /**
  45093. * Update the sample count for a given multiple render target texture
  45094. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45095. * @param textures defines the textures to update
  45096. * @param samples defines the sample count to set
  45097. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45098. */
  45099. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45100. }
  45101. }
  45102. }
  45103. declare module "babylonjs/Engines/Extensions/index" {
  45104. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45105. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45106. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45107. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45108. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45109. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45110. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45111. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45112. }
  45113. declare module "babylonjs/Engines/index" {
  45114. export * from "babylonjs/Engines/constants";
  45115. export * from "babylonjs/Engines/engine";
  45116. export * from "babylonjs/Engines/engineStore";
  45117. export * from "babylonjs/Engines/nullEngine";
  45118. export * from "babylonjs/Engines/Extensions/index";
  45119. export * from "babylonjs/Engines/IPipelineContext";
  45120. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45121. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45122. }
  45123. declare module "babylonjs/Events/clipboardEvents" {
  45124. /**
  45125. * Gather the list of clipboard event types as constants.
  45126. */
  45127. export class ClipboardEventTypes {
  45128. /**
  45129. * The clipboard event is fired when a copy command is active (pressed).
  45130. */
  45131. static readonly COPY: number;
  45132. /**
  45133. * The clipboard event is fired when a cut command is active (pressed).
  45134. */
  45135. static readonly CUT: number;
  45136. /**
  45137. * The clipboard event is fired when a paste command is active (pressed).
  45138. */
  45139. static readonly PASTE: number;
  45140. }
  45141. /**
  45142. * This class is used to store clipboard related info for the onClipboardObservable event.
  45143. */
  45144. export class ClipboardInfo {
  45145. /**
  45146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45147. */
  45148. type: number;
  45149. /**
  45150. * Defines the related dom event
  45151. */
  45152. event: ClipboardEvent;
  45153. /**
  45154. *Creates an instance of ClipboardInfo.
  45155. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45156. * @param event Defines the related dom event
  45157. */
  45158. constructor(
  45159. /**
  45160. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45161. */
  45162. type: number,
  45163. /**
  45164. * Defines the related dom event
  45165. */
  45166. event: ClipboardEvent);
  45167. /**
  45168. * Get the clipboard event's type from the keycode.
  45169. * @param keyCode Defines the keyCode for the current keyboard event.
  45170. * @return {number}
  45171. */
  45172. static GetTypeFromCharacter(keyCode: number): number;
  45173. }
  45174. }
  45175. declare module "babylonjs/Events/index" {
  45176. export * from "babylonjs/Events/keyboardEvents";
  45177. export * from "babylonjs/Events/pointerEvents";
  45178. export * from "babylonjs/Events/clipboardEvents";
  45179. }
  45180. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45181. import { Scene } from "babylonjs/scene";
  45182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45183. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45184. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45185. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45186. /**
  45187. * Google Daydream controller
  45188. */
  45189. export class DaydreamController extends WebVRController {
  45190. /**
  45191. * Base Url for the controller model.
  45192. */
  45193. static MODEL_BASE_URL: string;
  45194. /**
  45195. * File name for the controller model.
  45196. */
  45197. static MODEL_FILENAME: string;
  45198. /**
  45199. * Gamepad Id prefix used to identify Daydream Controller.
  45200. */
  45201. static readonly GAMEPAD_ID_PREFIX: string;
  45202. /**
  45203. * Creates a new DaydreamController from a gamepad
  45204. * @param vrGamepad the gamepad that the controller should be created from
  45205. */
  45206. constructor(vrGamepad: any);
  45207. /**
  45208. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45209. * @param scene scene in which to add meshes
  45210. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45211. */
  45212. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45213. /**
  45214. * Called once for each button that changed state since the last frame
  45215. * @param buttonIdx Which button index changed
  45216. * @param state New state of the button
  45217. * @param changes Which properties on the state changed since last frame
  45218. */
  45219. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45220. }
  45221. }
  45222. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45223. import { Scene } from "babylonjs/scene";
  45224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45225. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45226. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45227. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45228. /**
  45229. * Gear VR Controller
  45230. */
  45231. export class GearVRController extends WebVRController {
  45232. /**
  45233. * Base Url for the controller model.
  45234. */
  45235. static MODEL_BASE_URL: string;
  45236. /**
  45237. * File name for the controller model.
  45238. */
  45239. static MODEL_FILENAME: string;
  45240. /**
  45241. * Gamepad Id prefix used to identify this controller.
  45242. */
  45243. static readonly GAMEPAD_ID_PREFIX: string;
  45244. private readonly _buttonIndexToObservableNameMap;
  45245. /**
  45246. * Creates a new GearVRController from a gamepad
  45247. * @param vrGamepad the gamepad that the controller should be created from
  45248. */
  45249. constructor(vrGamepad: any);
  45250. /**
  45251. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45252. * @param scene scene in which to add meshes
  45253. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45254. */
  45255. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45256. /**
  45257. * Called once for each button that changed state since the last frame
  45258. * @param buttonIdx Which button index changed
  45259. * @param state New state of the button
  45260. * @param changes Which properties on the state changed since last frame
  45261. */
  45262. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45263. }
  45264. }
  45265. declare module "babylonjs/Gamepads/Controllers/index" {
  45266. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45267. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45268. export * from "babylonjs/Gamepads/Controllers/genericController";
  45269. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45270. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45271. export * from "babylonjs/Gamepads/Controllers/viveController";
  45272. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45273. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45274. }
  45275. declare module "babylonjs/Gamepads/index" {
  45276. export * from "babylonjs/Gamepads/Controllers/index";
  45277. export * from "babylonjs/Gamepads/gamepad";
  45278. export * from "babylonjs/Gamepads/gamepadManager";
  45279. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45280. export * from "babylonjs/Gamepads/xboxGamepad";
  45281. }
  45282. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45283. import { Scene } from "babylonjs/scene";
  45284. import { Vector4 } from "babylonjs/Maths/math.vector";
  45285. import { Color4 } from "babylonjs/Maths/math.color";
  45286. import { Mesh } from "babylonjs/Meshes/mesh";
  45287. import { Nullable } from "babylonjs/types";
  45288. /**
  45289. * Class containing static functions to help procedurally build meshes
  45290. */
  45291. export class PolyhedronBuilder {
  45292. /**
  45293. * Creates a polyhedron mesh
  45294. * * 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
  45295. * * The parameter `size` (positive float, default 1) sets the polygon size
  45296. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45297. * * 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`
  45298. * * 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
  45299. * * 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)`)
  45300. * * 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
  45301. * * 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
  45302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45305. * @param name defines the name of the mesh
  45306. * @param options defines the options used to create the mesh
  45307. * @param scene defines the hosting scene
  45308. * @returns the polyhedron mesh
  45309. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45310. */
  45311. static CreatePolyhedron(name: string, options: {
  45312. type?: number;
  45313. size?: number;
  45314. sizeX?: number;
  45315. sizeY?: number;
  45316. sizeZ?: number;
  45317. custom?: any;
  45318. faceUV?: Vector4[];
  45319. faceColors?: Color4[];
  45320. flat?: boolean;
  45321. updatable?: boolean;
  45322. sideOrientation?: number;
  45323. frontUVs?: Vector4;
  45324. backUVs?: Vector4;
  45325. }, scene?: Nullable<Scene>): Mesh;
  45326. }
  45327. }
  45328. declare module "babylonjs/Gizmos/scaleGizmo" {
  45329. import { Observable } from "babylonjs/Misc/observable";
  45330. import { Nullable } from "babylonjs/types";
  45331. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45332. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45333. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45334. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45335. /**
  45336. * Gizmo that enables scaling a mesh along 3 axis
  45337. */
  45338. export class ScaleGizmo extends Gizmo {
  45339. /**
  45340. * Internal gizmo used for interactions on the x axis
  45341. */
  45342. xGizmo: AxisScaleGizmo;
  45343. /**
  45344. * Internal gizmo used for interactions on the y axis
  45345. */
  45346. yGizmo: AxisScaleGizmo;
  45347. /**
  45348. * Internal gizmo used for interactions on the z axis
  45349. */
  45350. zGizmo: AxisScaleGizmo;
  45351. /**
  45352. * Internal gizmo used to scale all axis equally
  45353. */
  45354. uniformScaleGizmo: AxisScaleGizmo;
  45355. private _meshAttached;
  45356. private _updateGizmoRotationToMatchAttachedMesh;
  45357. private _snapDistance;
  45358. private _scaleRatio;
  45359. private _uniformScalingMesh;
  45360. private _octahedron;
  45361. /** Fires an event when any of it's sub gizmos are dragged */
  45362. onDragStartObservable: Observable<unknown>;
  45363. /** Fires an event when any of it's sub gizmos are released from dragging */
  45364. onDragEndObservable: Observable<unknown>;
  45365. attachedMesh: Nullable<AbstractMesh>;
  45366. /**
  45367. * Creates a ScaleGizmo
  45368. * @param gizmoLayer The utility layer the gizmo will be added to
  45369. */
  45370. constructor(gizmoLayer?: UtilityLayerRenderer);
  45371. updateGizmoRotationToMatchAttachedMesh: boolean;
  45372. /**
  45373. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45374. */
  45375. snapDistance: number;
  45376. /**
  45377. * Ratio for the scale of the gizmo (Default: 1)
  45378. */
  45379. scaleRatio: number;
  45380. /**
  45381. * Disposes of the gizmo
  45382. */
  45383. dispose(): void;
  45384. }
  45385. }
  45386. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45387. import { Observable } from "babylonjs/Misc/observable";
  45388. import { Nullable } from "babylonjs/types";
  45389. import { Vector3 } from "babylonjs/Maths/math.vector";
  45390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45391. import { Mesh } from "babylonjs/Meshes/mesh";
  45392. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45393. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45395. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45396. import { Color3 } from "babylonjs/Maths/math.color";
  45397. /**
  45398. * Single axis scale gizmo
  45399. */
  45400. export class AxisScaleGizmo extends Gizmo {
  45401. /**
  45402. * Drag behavior responsible for the gizmos dragging interactions
  45403. */
  45404. dragBehavior: PointerDragBehavior;
  45405. private _pointerObserver;
  45406. /**
  45407. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45408. */
  45409. snapDistance: number;
  45410. /**
  45411. * Event that fires each time the gizmo snaps to a new location.
  45412. * * snapDistance is the the change in distance
  45413. */
  45414. onSnapObservable: Observable<{
  45415. snapDistance: number;
  45416. }>;
  45417. /**
  45418. * If the scaling operation should be done on all axis (default: false)
  45419. */
  45420. uniformScaling: boolean;
  45421. private _isEnabled;
  45422. private _parent;
  45423. private _arrow;
  45424. private _coloredMaterial;
  45425. private _hoverMaterial;
  45426. /**
  45427. * Creates an AxisScaleGizmo
  45428. * @param gizmoLayer The utility layer the gizmo will be added to
  45429. * @param dragAxis The axis which the gizmo will be able to scale on
  45430. * @param color The color of the gizmo
  45431. */
  45432. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45433. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45434. /**
  45435. * If the gizmo is enabled
  45436. */
  45437. isEnabled: boolean;
  45438. /**
  45439. * Disposes of the gizmo
  45440. */
  45441. dispose(): void;
  45442. /**
  45443. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45444. * @param mesh The mesh to replace the default mesh of the gizmo
  45445. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45446. */
  45447. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45448. }
  45449. }
  45450. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45451. import { Observable } from "babylonjs/Misc/observable";
  45452. import { Nullable } from "babylonjs/types";
  45453. import { Vector3 } from "babylonjs/Maths/math.vector";
  45454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45455. import { Mesh } from "babylonjs/Meshes/mesh";
  45456. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45457. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45458. import { Color3 } from "babylonjs/Maths/math.color";
  45459. import "babylonjs/Meshes/Builders/boxBuilder";
  45460. /**
  45461. * Bounding box gizmo
  45462. */
  45463. export class BoundingBoxGizmo extends Gizmo {
  45464. private _lineBoundingBox;
  45465. private _rotateSpheresParent;
  45466. private _scaleBoxesParent;
  45467. private _boundingDimensions;
  45468. private _renderObserver;
  45469. private _pointerObserver;
  45470. private _scaleDragSpeed;
  45471. private _tmpQuaternion;
  45472. private _tmpVector;
  45473. private _tmpRotationMatrix;
  45474. /**
  45475. * 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)
  45476. */
  45477. ignoreChildren: boolean;
  45478. /**
  45479. * 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)
  45480. */
  45481. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45482. /**
  45483. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45484. */
  45485. rotationSphereSize: number;
  45486. /**
  45487. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45488. */
  45489. scaleBoxSize: number;
  45490. /**
  45491. * 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)
  45492. */
  45493. fixedDragMeshScreenSize: boolean;
  45494. /**
  45495. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45496. */
  45497. fixedDragMeshScreenSizeDistanceFactor: number;
  45498. /**
  45499. * Fired when a rotation sphere or scale box is dragged
  45500. */
  45501. onDragStartObservable: Observable<{}>;
  45502. /**
  45503. * Fired when a scale box is dragged
  45504. */
  45505. onScaleBoxDragObservable: Observable<{}>;
  45506. /**
  45507. * Fired when a scale box drag is ended
  45508. */
  45509. onScaleBoxDragEndObservable: Observable<{}>;
  45510. /**
  45511. * Fired when a rotation sphere is dragged
  45512. */
  45513. onRotationSphereDragObservable: Observable<{}>;
  45514. /**
  45515. * Fired when a rotation sphere drag is ended
  45516. */
  45517. onRotationSphereDragEndObservable: Observable<{}>;
  45518. /**
  45519. * 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)
  45520. */
  45521. scalePivot: Nullable<Vector3>;
  45522. /**
  45523. * Mesh used as a pivot to rotate the attached mesh
  45524. */
  45525. private _anchorMesh;
  45526. private _existingMeshScale;
  45527. private _dragMesh;
  45528. private pointerDragBehavior;
  45529. private coloredMaterial;
  45530. private hoverColoredMaterial;
  45531. /**
  45532. * Sets the color of the bounding box gizmo
  45533. * @param color the color to set
  45534. */
  45535. setColor(color: Color3): void;
  45536. /**
  45537. * Creates an BoundingBoxGizmo
  45538. * @param gizmoLayer The utility layer the gizmo will be added to
  45539. * @param color The color of the gizmo
  45540. */
  45541. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45543. private _selectNode;
  45544. /**
  45545. * Updates the bounding box information for the Gizmo
  45546. */
  45547. updateBoundingBox(): void;
  45548. private _updateRotationSpheres;
  45549. private _updateScaleBoxes;
  45550. /**
  45551. * Enables rotation on the specified axis and disables rotation on the others
  45552. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45553. */
  45554. setEnabledRotationAxis(axis: string): void;
  45555. /**
  45556. * Enables/disables scaling
  45557. * @param enable if scaling should be enabled
  45558. */
  45559. setEnabledScaling(enable: boolean): void;
  45560. private _updateDummy;
  45561. /**
  45562. * Enables a pointer drag behavior on the bounding box of the gizmo
  45563. */
  45564. enableDragBehavior(): void;
  45565. /**
  45566. * Disposes of the gizmo
  45567. */
  45568. dispose(): void;
  45569. /**
  45570. * 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)
  45571. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45572. * @returns the bounding box mesh with the passed in mesh as a child
  45573. */
  45574. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45575. /**
  45576. * CustomMeshes are not supported by this gizmo
  45577. * @param mesh The mesh to replace the default mesh of the gizmo
  45578. */
  45579. setCustomMesh(mesh: Mesh): void;
  45580. }
  45581. }
  45582. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45583. import { Observable } from "babylonjs/Misc/observable";
  45584. import { Nullable } from "babylonjs/types";
  45585. import { Vector3 } from "babylonjs/Maths/math.vector";
  45586. import { Color3 } from "babylonjs/Maths/math.color";
  45587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45588. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45589. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45590. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45591. import "babylonjs/Meshes/Builders/linesBuilder";
  45592. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45593. /**
  45594. * Single plane rotation gizmo
  45595. */
  45596. export class PlaneRotationGizmo extends Gizmo {
  45597. /**
  45598. * Drag behavior responsible for the gizmos dragging interactions
  45599. */
  45600. dragBehavior: PointerDragBehavior;
  45601. private _pointerObserver;
  45602. /**
  45603. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45604. */
  45605. snapDistance: number;
  45606. /**
  45607. * Event that fires each time the gizmo snaps to a new location.
  45608. * * snapDistance is the the change in distance
  45609. */
  45610. onSnapObservable: Observable<{
  45611. snapDistance: number;
  45612. }>;
  45613. private _isEnabled;
  45614. private _parent;
  45615. /**
  45616. * Creates a PlaneRotationGizmo
  45617. * @param gizmoLayer The utility layer the gizmo will be added to
  45618. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45619. * @param color The color of the gizmo
  45620. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45621. */
  45622. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45623. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45624. /**
  45625. * If the gizmo is enabled
  45626. */
  45627. isEnabled: boolean;
  45628. /**
  45629. * Disposes of the gizmo
  45630. */
  45631. dispose(): void;
  45632. }
  45633. }
  45634. declare module "babylonjs/Gizmos/rotationGizmo" {
  45635. import { Observable } from "babylonjs/Misc/observable";
  45636. import { Nullable } from "babylonjs/types";
  45637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45638. import { Mesh } from "babylonjs/Meshes/mesh";
  45639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45640. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45642. /**
  45643. * Gizmo that enables rotating a mesh along 3 axis
  45644. */
  45645. export class RotationGizmo extends Gizmo {
  45646. /**
  45647. * Internal gizmo used for interactions on the x axis
  45648. */
  45649. xGizmo: PlaneRotationGizmo;
  45650. /**
  45651. * Internal gizmo used for interactions on the y axis
  45652. */
  45653. yGizmo: PlaneRotationGizmo;
  45654. /**
  45655. * Internal gizmo used for interactions on the z axis
  45656. */
  45657. zGizmo: PlaneRotationGizmo;
  45658. /** Fires an event when any of it's sub gizmos are dragged */
  45659. onDragStartObservable: Observable<unknown>;
  45660. /** Fires an event when any of it's sub gizmos are released from dragging */
  45661. onDragEndObservable: Observable<unknown>;
  45662. private _meshAttached;
  45663. attachedMesh: Nullable<AbstractMesh>;
  45664. /**
  45665. * Creates a RotationGizmo
  45666. * @param gizmoLayer The utility layer the gizmo will be added to
  45667. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45668. */
  45669. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45670. updateGizmoRotationToMatchAttachedMesh: boolean;
  45671. /**
  45672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45673. */
  45674. snapDistance: number;
  45675. /**
  45676. * Ratio for the scale of the gizmo (Default: 1)
  45677. */
  45678. scaleRatio: number;
  45679. /**
  45680. * Disposes of the gizmo
  45681. */
  45682. dispose(): void;
  45683. /**
  45684. * CustomMeshes are not supported by this gizmo
  45685. * @param mesh The mesh to replace the default mesh of the gizmo
  45686. */
  45687. setCustomMesh(mesh: Mesh): void;
  45688. }
  45689. }
  45690. declare module "babylonjs/Gizmos/gizmoManager" {
  45691. import { Observable } from "babylonjs/Misc/observable";
  45692. import { Nullable } from "babylonjs/types";
  45693. import { Scene, IDisposable } from "babylonjs/scene";
  45694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45695. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45696. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45697. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45698. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45699. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45700. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45701. /**
  45702. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45703. */
  45704. export class GizmoManager implements IDisposable {
  45705. private scene;
  45706. /**
  45707. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45708. */
  45709. gizmos: {
  45710. positionGizmo: Nullable<PositionGizmo>;
  45711. rotationGizmo: Nullable<RotationGizmo>;
  45712. scaleGizmo: Nullable<ScaleGizmo>;
  45713. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45714. };
  45715. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45716. clearGizmoOnEmptyPointerEvent: boolean;
  45717. /** Fires an event when the manager is attached to a mesh */
  45718. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45719. private _gizmosEnabled;
  45720. private _pointerObserver;
  45721. private _attachedMesh;
  45722. private _boundingBoxColor;
  45723. private _defaultUtilityLayer;
  45724. private _defaultKeepDepthUtilityLayer;
  45725. /**
  45726. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45727. */
  45728. boundingBoxDragBehavior: SixDofDragBehavior;
  45729. /**
  45730. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45731. */
  45732. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45733. /**
  45734. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45735. */
  45736. usePointerToAttachGizmos: boolean;
  45737. /**
  45738. * Utility layer that the bounding box gizmo belongs to
  45739. */
  45740. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45741. /**
  45742. * Utility layer that all gizmos besides bounding box belong to
  45743. */
  45744. readonly utilityLayer: UtilityLayerRenderer;
  45745. /**
  45746. * Instatiates a gizmo manager
  45747. * @param scene the scene to overlay the gizmos on top of
  45748. */
  45749. constructor(scene: Scene);
  45750. /**
  45751. * Attaches a set of gizmos to the specified mesh
  45752. * @param mesh The mesh the gizmo's should be attached to
  45753. */
  45754. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45755. /**
  45756. * If the position gizmo is enabled
  45757. */
  45758. positionGizmoEnabled: boolean;
  45759. /**
  45760. * If the rotation gizmo is enabled
  45761. */
  45762. rotationGizmoEnabled: boolean;
  45763. /**
  45764. * If the scale gizmo is enabled
  45765. */
  45766. scaleGizmoEnabled: boolean;
  45767. /**
  45768. * If the boundingBox gizmo is enabled
  45769. */
  45770. boundingBoxGizmoEnabled: boolean;
  45771. /**
  45772. * Disposes of the gizmo manager
  45773. */
  45774. dispose(): void;
  45775. }
  45776. }
  45777. declare module "babylonjs/Lights/directionalLight" {
  45778. import { Camera } from "babylonjs/Cameras/camera";
  45779. import { Scene } from "babylonjs/scene";
  45780. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45782. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45783. import { Effect } from "babylonjs/Materials/effect";
  45784. /**
  45785. * A directional light is defined by a direction (what a surprise!).
  45786. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45787. * 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.
  45788. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45789. */
  45790. export class DirectionalLight extends ShadowLight {
  45791. private _shadowFrustumSize;
  45792. /**
  45793. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45794. */
  45795. /**
  45796. * Specifies a fix frustum size for the shadow generation.
  45797. */
  45798. shadowFrustumSize: number;
  45799. private _shadowOrthoScale;
  45800. /**
  45801. * Gets the shadow projection scale against the optimal computed one.
  45802. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45803. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45804. */
  45805. /**
  45806. * Sets the shadow projection scale against the optimal computed one.
  45807. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45808. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45809. */
  45810. shadowOrthoScale: number;
  45811. /**
  45812. * Automatically compute the projection matrix to best fit (including all the casters)
  45813. * on each frame.
  45814. */
  45815. autoUpdateExtends: boolean;
  45816. private _orthoLeft;
  45817. private _orthoRight;
  45818. private _orthoTop;
  45819. private _orthoBottom;
  45820. /**
  45821. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45822. * The directional light is emitted from everywhere in the given direction.
  45823. * It can cast shadows.
  45824. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45825. * @param name The friendly name of the light
  45826. * @param direction The direction of the light
  45827. * @param scene The scene the light belongs to
  45828. */
  45829. constructor(name: string, direction: Vector3, scene: Scene);
  45830. /**
  45831. * Returns the string "DirectionalLight".
  45832. * @return The class name
  45833. */
  45834. getClassName(): string;
  45835. /**
  45836. * Returns the integer 1.
  45837. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45838. */
  45839. getTypeID(): number;
  45840. /**
  45841. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45842. * Returns the DirectionalLight Shadow projection matrix.
  45843. */
  45844. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45845. /**
  45846. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45847. * Returns the DirectionalLight Shadow projection matrix.
  45848. */
  45849. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45850. /**
  45851. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45852. * Returns the DirectionalLight Shadow projection matrix.
  45853. */
  45854. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45855. protected _buildUniformLayout(): void;
  45856. /**
  45857. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45858. * @param effect The effect to update
  45859. * @param lightIndex The index of the light in the effect to update
  45860. * @returns The directional light
  45861. */
  45862. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45863. /**
  45864. * Gets the minZ used for shadow according to both the scene and the light.
  45865. *
  45866. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45867. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45868. * @param activeCamera The camera we are returning the min for
  45869. * @returns the depth min z
  45870. */
  45871. getDepthMinZ(activeCamera: Camera): number;
  45872. /**
  45873. * Gets the maxZ used for shadow according to both the scene and the light.
  45874. *
  45875. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45876. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45877. * @param activeCamera The camera we are returning the max for
  45878. * @returns the depth max z
  45879. */
  45880. getDepthMaxZ(activeCamera: Camera): number;
  45881. /**
  45882. * Prepares the list of defines specific to the light type.
  45883. * @param defines the list of defines
  45884. * @param lightIndex defines the index of the light for the effect
  45885. */
  45886. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45887. }
  45888. }
  45889. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45890. import { Mesh } from "babylonjs/Meshes/mesh";
  45891. /**
  45892. * Class containing static functions to help procedurally build meshes
  45893. */
  45894. export class HemisphereBuilder {
  45895. /**
  45896. * Creates a hemisphere mesh
  45897. * @param name defines the name of the mesh
  45898. * @param options defines the options used to create the mesh
  45899. * @param scene defines the hosting scene
  45900. * @returns the hemisphere mesh
  45901. */
  45902. static CreateHemisphere(name: string, options: {
  45903. segments?: number;
  45904. diameter?: number;
  45905. sideOrientation?: number;
  45906. }, scene: any): Mesh;
  45907. }
  45908. }
  45909. declare module "babylonjs/Lights/spotLight" {
  45910. import { Nullable } from "babylonjs/types";
  45911. import { Scene } from "babylonjs/scene";
  45912. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45914. import { Effect } from "babylonjs/Materials/effect";
  45915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45916. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45917. /**
  45918. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45919. * These values define a cone of light starting from the position, emitting toward the direction.
  45920. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45921. * and the exponent defines the speed of the decay of the light with distance (reach).
  45922. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45923. */
  45924. export class SpotLight extends ShadowLight {
  45925. private _angle;
  45926. private _innerAngle;
  45927. private _cosHalfAngle;
  45928. private _lightAngleScale;
  45929. private _lightAngleOffset;
  45930. /**
  45931. * Gets the cone angle of the spot light in Radians.
  45932. */
  45933. /**
  45934. * Sets the cone angle of the spot light in Radians.
  45935. */
  45936. angle: number;
  45937. /**
  45938. * Only used in gltf falloff mode, this defines the angle where
  45939. * the directional falloff will start before cutting at angle which could be seen
  45940. * as outer angle.
  45941. */
  45942. /**
  45943. * Only used in gltf falloff mode, this defines the angle where
  45944. * the directional falloff will start before cutting at angle which could be seen
  45945. * as outer angle.
  45946. */
  45947. innerAngle: number;
  45948. private _shadowAngleScale;
  45949. /**
  45950. * Allows scaling the angle of the light for shadow generation only.
  45951. */
  45952. /**
  45953. * Allows scaling the angle of the light for shadow generation only.
  45954. */
  45955. shadowAngleScale: number;
  45956. /**
  45957. * The light decay speed with the distance from the emission spot.
  45958. */
  45959. exponent: number;
  45960. private _projectionTextureMatrix;
  45961. /**
  45962. * Allows reading the projecton texture
  45963. */
  45964. readonly projectionTextureMatrix: Matrix;
  45965. protected _projectionTextureLightNear: number;
  45966. /**
  45967. * Gets the near clip of the Spotlight for texture projection.
  45968. */
  45969. /**
  45970. * Sets the near clip of the Spotlight for texture projection.
  45971. */
  45972. projectionTextureLightNear: number;
  45973. protected _projectionTextureLightFar: number;
  45974. /**
  45975. * Gets the far clip of the Spotlight for texture projection.
  45976. */
  45977. /**
  45978. * Sets the far clip of the Spotlight for texture projection.
  45979. */
  45980. projectionTextureLightFar: number;
  45981. protected _projectionTextureUpDirection: Vector3;
  45982. /**
  45983. * Gets the Up vector of the Spotlight for texture projection.
  45984. */
  45985. /**
  45986. * Sets the Up vector of the Spotlight for texture projection.
  45987. */
  45988. projectionTextureUpDirection: Vector3;
  45989. private _projectionTexture;
  45990. /**
  45991. * Gets the projection texture of the light.
  45992. */
  45993. /**
  45994. * Sets the projection texture of the light.
  45995. */
  45996. projectionTexture: Nullable<BaseTexture>;
  45997. private _projectionTextureViewLightDirty;
  45998. private _projectionTextureProjectionLightDirty;
  45999. private _projectionTextureDirty;
  46000. private _projectionTextureViewTargetVector;
  46001. private _projectionTextureViewLightMatrix;
  46002. private _projectionTextureProjectionLightMatrix;
  46003. private _projectionTextureScalingMatrix;
  46004. /**
  46005. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46006. * It can cast shadows.
  46007. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46008. * @param name The light friendly name
  46009. * @param position The position of the spot light in the scene
  46010. * @param direction The direction of the light in the scene
  46011. * @param angle The cone angle of the light in Radians
  46012. * @param exponent The light decay speed with the distance from the emission spot
  46013. * @param scene The scene the lights belongs to
  46014. */
  46015. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46016. /**
  46017. * Returns the string "SpotLight".
  46018. * @returns the class name
  46019. */
  46020. getClassName(): string;
  46021. /**
  46022. * Returns the integer 2.
  46023. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46024. */
  46025. getTypeID(): number;
  46026. /**
  46027. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46028. */
  46029. protected _setDirection(value: Vector3): void;
  46030. /**
  46031. * Overrides the position setter to recompute the projection texture view light Matrix.
  46032. */
  46033. protected _setPosition(value: Vector3): void;
  46034. /**
  46035. * 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.
  46036. * Returns the SpotLight.
  46037. */
  46038. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46039. protected _computeProjectionTextureViewLightMatrix(): void;
  46040. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46041. /**
  46042. * Main function for light texture projection matrix computing.
  46043. */
  46044. protected _computeProjectionTextureMatrix(): void;
  46045. protected _buildUniformLayout(): void;
  46046. private _computeAngleValues;
  46047. /**
  46048. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46049. * @param effect The effect to update
  46050. * @param lightIndex The index of the light in the effect to update
  46051. * @returns The spot light
  46052. */
  46053. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46054. /**
  46055. * Disposes the light and the associated resources.
  46056. */
  46057. dispose(): void;
  46058. /**
  46059. * Prepares the list of defines specific to the light type.
  46060. * @param defines the list of defines
  46061. * @param lightIndex defines the index of the light for the effect
  46062. */
  46063. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46064. }
  46065. }
  46066. declare module "babylonjs/Gizmos/lightGizmo" {
  46067. import { Nullable } from "babylonjs/types";
  46068. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46069. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46070. import { Light } from "babylonjs/Lights/light";
  46071. /**
  46072. * Gizmo that enables viewing a light
  46073. */
  46074. export class LightGizmo extends Gizmo {
  46075. private _lightMesh;
  46076. private _material;
  46077. private cachedPosition;
  46078. private cachedForward;
  46079. /**
  46080. * Creates a LightGizmo
  46081. * @param gizmoLayer The utility layer the gizmo will be added to
  46082. */
  46083. constructor(gizmoLayer?: UtilityLayerRenderer);
  46084. private _light;
  46085. /**
  46086. * The light that the gizmo is attached to
  46087. */
  46088. light: Nullable<Light>;
  46089. /**
  46090. * @hidden
  46091. * Updates the gizmo to match the attached mesh's position/rotation
  46092. */
  46093. protected _update(): void;
  46094. private static _Scale;
  46095. /**
  46096. * Creates the lines for a light mesh
  46097. */
  46098. private static _createLightLines;
  46099. /**
  46100. * Disposes of the light gizmo
  46101. */
  46102. dispose(): void;
  46103. private static _CreateHemisphericLightMesh;
  46104. private static _CreatePointLightMesh;
  46105. private static _CreateSpotLightMesh;
  46106. private static _CreateDirectionalLightMesh;
  46107. }
  46108. }
  46109. declare module "babylonjs/Gizmos/index" {
  46110. export * from "babylonjs/Gizmos/axisDragGizmo";
  46111. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46112. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46113. export * from "babylonjs/Gizmos/gizmo";
  46114. export * from "babylonjs/Gizmos/gizmoManager";
  46115. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46116. export * from "babylonjs/Gizmos/positionGizmo";
  46117. export * from "babylonjs/Gizmos/rotationGizmo";
  46118. export * from "babylonjs/Gizmos/scaleGizmo";
  46119. export * from "babylonjs/Gizmos/lightGizmo";
  46120. export * from "babylonjs/Gizmos/planeDragGizmo";
  46121. }
  46122. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46123. /** @hidden */
  46124. export var backgroundFragmentDeclaration: {
  46125. name: string;
  46126. shader: string;
  46127. };
  46128. }
  46129. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46130. /** @hidden */
  46131. export var backgroundUboDeclaration: {
  46132. name: string;
  46133. shader: string;
  46134. };
  46135. }
  46136. declare module "babylonjs/Shaders/background.fragment" {
  46137. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46138. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46139. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46140. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46141. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46142. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46143. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46144. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46145. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46146. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46147. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46148. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46149. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46150. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46151. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46152. /** @hidden */
  46153. export var backgroundPixelShader: {
  46154. name: string;
  46155. shader: string;
  46156. };
  46157. }
  46158. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46159. /** @hidden */
  46160. export var backgroundVertexDeclaration: {
  46161. name: string;
  46162. shader: string;
  46163. };
  46164. }
  46165. declare module "babylonjs/Shaders/background.vertex" {
  46166. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46167. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46168. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46170. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46171. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46172. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46173. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46174. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46175. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46176. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46177. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46178. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46179. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46180. /** @hidden */
  46181. export var backgroundVertexShader: {
  46182. name: string;
  46183. shader: string;
  46184. };
  46185. }
  46186. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46187. import { Nullable, int, float } from "babylonjs/types";
  46188. import { Scene } from "babylonjs/scene";
  46189. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46192. import { Mesh } from "babylonjs/Meshes/mesh";
  46193. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46194. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46195. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46197. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46198. import { Color3 } from "babylonjs/Maths/math.color";
  46199. import "babylonjs/Shaders/background.fragment";
  46200. import "babylonjs/Shaders/background.vertex";
  46201. /**
  46202. * Background material used to create an efficient environement around your scene.
  46203. */
  46204. export class BackgroundMaterial extends PushMaterial {
  46205. /**
  46206. * Standard reflectance value at parallel view angle.
  46207. */
  46208. static StandardReflectance0: number;
  46209. /**
  46210. * Standard reflectance value at grazing angle.
  46211. */
  46212. static StandardReflectance90: number;
  46213. protected _primaryColor: Color3;
  46214. /**
  46215. * Key light Color (multiply against the environement texture)
  46216. */
  46217. primaryColor: Color3;
  46218. protected __perceptualColor: Nullable<Color3>;
  46219. /**
  46220. * Experimental Internal Use Only.
  46221. *
  46222. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46223. * This acts as a helper to set the primary color to a more "human friendly" value.
  46224. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46225. * output color as close as possible from the chosen value.
  46226. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46227. * part of lighting setup.)
  46228. */
  46229. _perceptualColor: Nullable<Color3>;
  46230. protected _primaryColorShadowLevel: float;
  46231. /**
  46232. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46233. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46234. */
  46235. primaryColorShadowLevel: float;
  46236. protected _primaryColorHighlightLevel: float;
  46237. /**
  46238. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46239. * The primary color is used at the level chosen to define what the white area would look.
  46240. */
  46241. primaryColorHighlightLevel: float;
  46242. protected _reflectionTexture: Nullable<BaseTexture>;
  46243. /**
  46244. * Reflection Texture used in the material.
  46245. * Should be author in a specific way for the best result (refer to the documentation).
  46246. */
  46247. reflectionTexture: Nullable<BaseTexture>;
  46248. protected _reflectionBlur: float;
  46249. /**
  46250. * Reflection Texture level of blur.
  46251. *
  46252. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46253. * texture twice.
  46254. */
  46255. reflectionBlur: float;
  46256. protected _diffuseTexture: Nullable<BaseTexture>;
  46257. /**
  46258. * Diffuse Texture used in the material.
  46259. * Should be author in a specific way for the best result (refer to the documentation).
  46260. */
  46261. diffuseTexture: Nullable<BaseTexture>;
  46262. protected _shadowLights: Nullable<IShadowLight[]>;
  46263. /**
  46264. * Specify the list of lights casting shadow on the material.
  46265. * All scene shadow lights will be included if null.
  46266. */
  46267. shadowLights: Nullable<IShadowLight[]>;
  46268. protected _shadowLevel: float;
  46269. /**
  46270. * Helps adjusting the shadow to a softer level if required.
  46271. * 0 means black shadows and 1 means no shadows.
  46272. */
  46273. shadowLevel: float;
  46274. protected _sceneCenter: Vector3;
  46275. /**
  46276. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46277. * It is usually zero but might be interesting to modify according to your setup.
  46278. */
  46279. sceneCenter: Vector3;
  46280. protected _opacityFresnel: boolean;
  46281. /**
  46282. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46283. * This helps ensuring a nice transition when the camera goes under the ground.
  46284. */
  46285. opacityFresnel: boolean;
  46286. protected _reflectionFresnel: boolean;
  46287. /**
  46288. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46289. * This helps adding a mirror texture on the ground.
  46290. */
  46291. reflectionFresnel: boolean;
  46292. protected _reflectionFalloffDistance: number;
  46293. /**
  46294. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46295. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46296. */
  46297. reflectionFalloffDistance: number;
  46298. protected _reflectionAmount: number;
  46299. /**
  46300. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46301. */
  46302. reflectionAmount: number;
  46303. protected _reflectionReflectance0: number;
  46304. /**
  46305. * This specifies the weight of the reflection at grazing angle.
  46306. */
  46307. reflectionReflectance0: number;
  46308. protected _reflectionReflectance90: number;
  46309. /**
  46310. * This specifies the weight of the reflection at a perpendicular point of view.
  46311. */
  46312. reflectionReflectance90: number;
  46313. /**
  46314. * Sets the reflection reflectance fresnel values according to the default standard
  46315. * empirically know to work well :-)
  46316. */
  46317. reflectionStandardFresnelWeight: number;
  46318. protected _useRGBColor: boolean;
  46319. /**
  46320. * Helps to directly use the maps channels instead of their level.
  46321. */
  46322. useRGBColor: boolean;
  46323. protected _enableNoise: boolean;
  46324. /**
  46325. * This helps reducing the banding effect that could occur on the background.
  46326. */
  46327. enableNoise: boolean;
  46328. /**
  46329. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46330. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46331. * Recommended to be keep at 1.0 except for special cases.
  46332. */
  46333. fovMultiplier: number;
  46334. private _fovMultiplier;
  46335. /**
  46336. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46337. */
  46338. useEquirectangularFOV: boolean;
  46339. private _maxSimultaneousLights;
  46340. /**
  46341. * Number of Simultaneous lights allowed on the material.
  46342. */
  46343. maxSimultaneousLights: int;
  46344. /**
  46345. * Default configuration related to image processing available in the Background Material.
  46346. */
  46347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46348. /**
  46349. * Keep track of the image processing observer to allow dispose and replace.
  46350. */
  46351. private _imageProcessingObserver;
  46352. /**
  46353. * Attaches a new image processing configuration to the PBR Material.
  46354. * @param configuration (if null the scene configuration will be use)
  46355. */
  46356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46357. /**
  46358. * Gets the image processing configuration used either in this material.
  46359. */
  46360. /**
  46361. * Sets the Default image processing configuration used either in the this material.
  46362. *
  46363. * If sets to null, the scene one is in use.
  46364. */
  46365. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46366. /**
  46367. * Gets wether the color curves effect is enabled.
  46368. */
  46369. /**
  46370. * Sets wether the color curves effect is enabled.
  46371. */
  46372. cameraColorCurvesEnabled: boolean;
  46373. /**
  46374. * Gets wether the color grading effect is enabled.
  46375. */
  46376. /**
  46377. * Gets wether the color grading effect is enabled.
  46378. */
  46379. cameraColorGradingEnabled: boolean;
  46380. /**
  46381. * Gets wether tonemapping is enabled or not.
  46382. */
  46383. /**
  46384. * Sets wether tonemapping is enabled or not
  46385. */
  46386. cameraToneMappingEnabled: boolean;
  46387. /**
  46388. * The camera exposure used on this material.
  46389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46390. * This corresponds to a photographic exposure.
  46391. */
  46392. /**
  46393. * The camera exposure used on this material.
  46394. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46395. * This corresponds to a photographic exposure.
  46396. */
  46397. cameraExposure: float;
  46398. /**
  46399. * Gets The camera contrast used on this material.
  46400. */
  46401. /**
  46402. * Sets The camera contrast used on this material.
  46403. */
  46404. cameraContrast: float;
  46405. /**
  46406. * Gets the Color Grading 2D Lookup Texture.
  46407. */
  46408. /**
  46409. * Sets the Color Grading 2D Lookup Texture.
  46410. */
  46411. cameraColorGradingTexture: Nullable<BaseTexture>;
  46412. /**
  46413. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46414. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46415. * 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;
  46416. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46417. */
  46418. /**
  46419. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46420. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46421. * 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;
  46422. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46423. */
  46424. cameraColorCurves: Nullable<ColorCurves>;
  46425. /**
  46426. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46427. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46428. */
  46429. switchToBGR: boolean;
  46430. private _renderTargets;
  46431. private _reflectionControls;
  46432. private _white;
  46433. private _primaryShadowColor;
  46434. private _primaryHighlightColor;
  46435. /**
  46436. * Instantiates a Background Material in the given scene
  46437. * @param name The friendly name of the material
  46438. * @param scene The scene to add the material to
  46439. */
  46440. constructor(name: string, scene: Scene);
  46441. /**
  46442. * Gets a boolean indicating that current material needs to register RTT
  46443. */
  46444. readonly hasRenderTargetTextures: boolean;
  46445. /**
  46446. * The entire material has been created in order to prevent overdraw.
  46447. * @returns false
  46448. */
  46449. needAlphaTesting(): boolean;
  46450. /**
  46451. * The entire material has been created in order to prevent overdraw.
  46452. * @returns true if blending is enable
  46453. */
  46454. needAlphaBlending(): boolean;
  46455. /**
  46456. * Checks wether the material is ready to be rendered for a given mesh.
  46457. * @param mesh The mesh to render
  46458. * @param subMesh The submesh to check against
  46459. * @param useInstances Specify wether or not the material is used with instances
  46460. * @returns true if all the dependencies are ready (Textures, Effects...)
  46461. */
  46462. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46463. /**
  46464. * Compute the primary color according to the chosen perceptual color.
  46465. */
  46466. private _computePrimaryColorFromPerceptualColor;
  46467. /**
  46468. * Compute the highlights and shadow colors according to their chosen levels.
  46469. */
  46470. private _computePrimaryColors;
  46471. /**
  46472. * Build the uniform buffer used in the material.
  46473. */
  46474. buildUniformLayout(): void;
  46475. /**
  46476. * Unbind the material.
  46477. */
  46478. unbind(): void;
  46479. /**
  46480. * Bind only the world matrix to the material.
  46481. * @param world The world matrix to bind.
  46482. */
  46483. bindOnlyWorldMatrix(world: Matrix): void;
  46484. /**
  46485. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46486. * @param world The world matrix to bind.
  46487. * @param subMesh The submesh to bind for.
  46488. */
  46489. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46490. /**
  46491. * Dispose the material.
  46492. * @param forceDisposeEffect Force disposal of the associated effect.
  46493. * @param forceDisposeTextures Force disposal of the associated textures.
  46494. */
  46495. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46496. /**
  46497. * Clones the material.
  46498. * @param name The cloned name.
  46499. * @returns The cloned material.
  46500. */
  46501. clone(name: string): BackgroundMaterial;
  46502. /**
  46503. * Serializes the current material to its JSON representation.
  46504. * @returns The JSON representation.
  46505. */
  46506. serialize(): any;
  46507. /**
  46508. * Gets the class name of the material
  46509. * @returns "BackgroundMaterial"
  46510. */
  46511. getClassName(): string;
  46512. /**
  46513. * Parse a JSON input to create back a background material.
  46514. * @param source The JSON data to parse
  46515. * @param scene The scene to create the parsed material in
  46516. * @param rootUrl The root url of the assets the material depends upon
  46517. * @returns the instantiated BackgroundMaterial.
  46518. */
  46519. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46520. }
  46521. }
  46522. declare module "babylonjs/Helpers/environmentHelper" {
  46523. import { Observable } from "babylonjs/Misc/observable";
  46524. import { Nullable } from "babylonjs/types";
  46525. import { Scene } from "babylonjs/scene";
  46526. import { Vector3 } from "babylonjs/Maths/math.vector";
  46527. import { Color3 } from "babylonjs/Maths/math.color";
  46528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46529. import { Mesh } from "babylonjs/Meshes/mesh";
  46530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46531. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46532. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46533. import "babylonjs/Meshes/Builders/planeBuilder";
  46534. import "babylonjs/Meshes/Builders/boxBuilder";
  46535. /**
  46536. * Represents the different options available during the creation of
  46537. * a Environment helper.
  46538. *
  46539. * This can control the default ground, skybox and image processing setup of your scene.
  46540. */
  46541. export interface IEnvironmentHelperOptions {
  46542. /**
  46543. * Specifies wether or not to create a ground.
  46544. * True by default.
  46545. */
  46546. createGround: boolean;
  46547. /**
  46548. * Specifies the ground size.
  46549. * 15 by default.
  46550. */
  46551. groundSize: number;
  46552. /**
  46553. * The texture used on the ground for the main color.
  46554. * Comes from the BabylonJS CDN by default.
  46555. *
  46556. * Remarks: Can be either a texture or a url.
  46557. */
  46558. groundTexture: string | BaseTexture;
  46559. /**
  46560. * The color mixed in the ground texture by default.
  46561. * BabylonJS clearColor by default.
  46562. */
  46563. groundColor: Color3;
  46564. /**
  46565. * Specifies the ground opacity.
  46566. * 1 by default.
  46567. */
  46568. groundOpacity: number;
  46569. /**
  46570. * Enables the ground to receive shadows.
  46571. * True by default.
  46572. */
  46573. enableGroundShadow: boolean;
  46574. /**
  46575. * Helps preventing the shadow to be fully black on the ground.
  46576. * 0.5 by default.
  46577. */
  46578. groundShadowLevel: number;
  46579. /**
  46580. * Creates a mirror texture attach to the ground.
  46581. * false by default.
  46582. */
  46583. enableGroundMirror: boolean;
  46584. /**
  46585. * Specifies the ground mirror size ratio.
  46586. * 0.3 by default as the default kernel is 64.
  46587. */
  46588. groundMirrorSizeRatio: number;
  46589. /**
  46590. * Specifies the ground mirror blur kernel size.
  46591. * 64 by default.
  46592. */
  46593. groundMirrorBlurKernel: number;
  46594. /**
  46595. * Specifies the ground mirror visibility amount.
  46596. * 1 by default
  46597. */
  46598. groundMirrorAmount: number;
  46599. /**
  46600. * Specifies the ground mirror reflectance weight.
  46601. * This uses the standard weight of the background material to setup the fresnel effect
  46602. * of the mirror.
  46603. * 1 by default.
  46604. */
  46605. groundMirrorFresnelWeight: number;
  46606. /**
  46607. * Specifies the ground mirror Falloff distance.
  46608. * This can helps reducing the size of the reflection.
  46609. * 0 by Default.
  46610. */
  46611. groundMirrorFallOffDistance: number;
  46612. /**
  46613. * Specifies the ground mirror texture type.
  46614. * Unsigned Int by Default.
  46615. */
  46616. groundMirrorTextureType: number;
  46617. /**
  46618. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46619. * the shown objects.
  46620. */
  46621. groundYBias: number;
  46622. /**
  46623. * Specifies wether or not to create a skybox.
  46624. * True by default.
  46625. */
  46626. createSkybox: boolean;
  46627. /**
  46628. * Specifies the skybox size.
  46629. * 20 by default.
  46630. */
  46631. skyboxSize: number;
  46632. /**
  46633. * The texture used on the skybox for the main color.
  46634. * Comes from the BabylonJS CDN by default.
  46635. *
  46636. * Remarks: Can be either a texture or a url.
  46637. */
  46638. skyboxTexture: string | BaseTexture;
  46639. /**
  46640. * The color mixed in the skybox texture by default.
  46641. * BabylonJS clearColor by default.
  46642. */
  46643. skyboxColor: Color3;
  46644. /**
  46645. * The background rotation around the Y axis of the scene.
  46646. * This helps aligning the key lights of your scene with the background.
  46647. * 0 by default.
  46648. */
  46649. backgroundYRotation: number;
  46650. /**
  46651. * Compute automatically the size of the elements to best fit with the scene.
  46652. */
  46653. sizeAuto: boolean;
  46654. /**
  46655. * Default position of the rootMesh if autoSize is not true.
  46656. */
  46657. rootPosition: Vector3;
  46658. /**
  46659. * Sets up the image processing in the scene.
  46660. * true by default.
  46661. */
  46662. setupImageProcessing: boolean;
  46663. /**
  46664. * The texture used as your environment texture in the scene.
  46665. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46666. *
  46667. * Remarks: Can be either a texture or a url.
  46668. */
  46669. environmentTexture: string | BaseTexture;
  46670. /**
  46671. * The value of the exposure to apply to the scene.
  46672. * 0.6 by default if setupImageProcessing is true.
  46673. */
  46674. cameraExposure: number;
  46675. /**
  46676. * The value of the contrast to apply to the scene.
  46677. * 1.6 by default if setupImageProcessing is true.
  46678. */
  46679. cameraContrast: number;
  46680. /**
  46681. * Specifies wether or not tonemapping should be enabled in the scene.
  46682. * true by default if setupImageProcessing is true.
  46683. */
  46684. toneMappingEnabled: boolean;
  46685. }
  46686. /**
  46687. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46688. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46689. * It also helps with the default setup of your imageProcessing configuration.
  46690. */
  46691. export class EnvironmentHelper {
  46692. /**
  46693. * Default ground texture URL.
  46694. */
  46695. private static _groundTextureCDNUrl;
  46696. /**
  46697. * Default skybox texture URL.
  46698. */
  46699. private static _skyboxTextureCDNUrl;
  46700. /**
  46701. * Default environment texture URL.
  46702. */
  46703. private static _environmentTextureCDNUrl;
  46704. /**
  46705. * Creates the default options for the helper.
  46706. */
  46707. private static _getDefaultOptions;
  46708. private _rootMesh;
  46709. /**
  46710. * Gets the root mesh created by the helper.
  46711. */
  46712. readonly rootMesh: Mesh;
  46713. private _skybox;
  46714. /**
  46715. * Gets the skybox created by the helper.
  46716. */
  46717. readonly skybox: Nullable<Mesh>;
  46718. private _skyboxTexture;
  46719. /**
  46720. * Gets the skybox texture created by the helper.
  46721. */
  46722. readonly skyboxTexture: Nullable<BaseTexture>;
  46723. private _skyboxMaterial;
  46724. /**
  46725. * Gets the skybox material created by the helper.
  46726. */
  46727. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46728. private _ground;
  46729. /**
  46730. * Gets the ground mesh created by the helper.
  46731. */
  46732. readonly ground: Nullable<Mesh>;
  46733. private _groundTexture;
  46734. /**
  46735. * Gets the ground texture created by the helper.
  46736. */
  46737. readonly groundTexture: Nullable<BaseTexture>;
  46738. private _groundMirror;
  46739. /**
  46740. * Gets the ground mirror created by the helper.
  46741. */
  46742. readonly groundMirror: Nullable<MirrorTexture>;
  46743. /**
  46744. * Gets the ground mirror render list to helps pushing the meshes
  46745. * you wish in the ground reflection.
  46746. */
  46747. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46748. private _groundMaterial;
  46749. /**
  46750. * Gets the ground material created by the helper.
  46751. */
  46752. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46753. /**
  46754. * Stores the creation options.
  46755. */
  46756. private readonly _scene;
  46757. private _options;
  46758. /**
  46759. * This observable will be notified with any error during the creation of the environment,
  46760. * mainly texture creation errors.
  46761. */
  46762. onErrorObservable: Observable<{
  46763. message?: string;
  46764. exception?: any;
  46765. }>;
  46766. /**
  46767. * constructor
  46768. * @param options Defines the options we want to customize the helper
  46769. * @param scene The scene to add the material to
  46770. */
  46771. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46772. /**
  46773. * Updates the background according to the new options
  46774. * @param options
  46775. */
  46776. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46777. /**
  46778. * Sets the primary color of all the available elements.
  46779. * @param color the main color to affect to the ground and the background
  46780. */
  46781. setMainColor(color: Color3): void;
  46782. /**
  46783. * Setup the image processing according to the specified options.
  46784. */
  46785. private _setupImageProcessing;
  46786. /**
  46787. * Setup the environment texture according to the specified options.
  46788. */
  46789. private _setupEnvironmentTexture;
  46790. /**
  46791. * Setup the background according to the specified options.
  46792. */
  46793. private _setupBackground;
  46794. /**
  46795. * Get the scene sizes according to the setup.
  46796. */
  46797. private _getSceneSize;
  46798. /**
  46799. * Setup the ground according to the specified options.
  46800. */
  46801. private _setupGround;
  46802. /**
  46803. * Setup the ground material according to the specified options.
  46804. */
  46805. private _setupGroundMaterial;
  46806. /**
  46807. * Setup the ground diffuse texture according to the specified options.
  46808. */
  46809. private _setupGroundDiffuseTexture;
  46810. /**
  46811. * Setup the ground mirror texture according to the specified options.
  46812. */
  46813. private _setupGroundMirrorTexture;
  46814. /**
  46815. * Setup the ground to receive the mirror texture.
  46816. */
  46817. private _setupMirrorInGroundMaterial;
  46818. /**
  46819. * Setup the skybox according to the specified options.
  46820. */
  46821. private _setupSkybox;
  46822. /**
  46823. * Setup the skybox material according to the specified options.
  46824. */
  46825. private _setupSkyboxMaterial;
  46826. /**
  46827. * Setup the skybox reflection texture according to the specified options.
  46828. */
  46829. private _setupSkyboxReflectionTexture;
  46830. private _errorHandler;
  46831. /**
  46832. * Dispose all the elements created by the Helper.
  46833. */
  46834. dispose(): void;
  46835. }
  46836. }
  46837. declare module "babylonjs/Helpers/photoDome" {
  46838. import { Observable } from "babylonjs/Misc/observable";
  46839. import { Nullable } from "babylonjs/types";
  46840. import { Scene } from "babylonjs/scene";
  46841. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46842. import { Mesh } from "babylonjs/Meshes/mesh";
  46843. import { Texture } from "babylonjs/Materials/Textures/texture";
  46844. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46845. import "babylonjs/Meshes/Builders/sphereBuilder";
  46846. /**
  46847. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46848. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46849. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46850. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46851. */
  46852. export class PhotoDome extends TransformNode {
  46853. /**
  46854. * Define the image as a Monoscopic panoramic 360 image.
  46855. */
  46856. static readonly MODE_MONOSCOPIC: number;
  46857. /**
  46858. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46859. */
  46860. static readonly MODE_TOPBOTTOM: number;
  46861. /**
  46862. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46863. */
  46864. static readonly MODE_SIDEBYSIDE: number;
  46865. private _useDirectMapping;
  46866. /**
  46867. * The texture being displayed on the sphere
  46868. */
  46869. protected _photoTexture: Texture;
  46870. /**
  46871. * Gets or sets the texture being displayed on the sphere
  46872. */
  46873. photoTexture: Texture;
  46874. /**
  46875. * Observable raised when an error occured while loading the 360 image
  46876. */
  46877. onLoadErrorObservable: Observable<string>;
  46878. /**
  46879. * The skybox material
  46880. */
  46881. protected _material: BackgroundMaterial;
  46882. /**
  46883. * The surface used for the skybox
  46884. */
  46885. protected _mesh: Mesh;
  46886. /**
  46887. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46888. * Also see the options.resolution property.
  46889. */
  46890. fovMultiplier: number;
  46891. private _imageMode;
  46892. /**
  46893. * Gets or set the current video mode for the video. It can be:
  46894. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46895. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46896. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46897. */
  46898. imageMode: number;
  46899. /**
  46900. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46901. * @param name Element's name, child elements will append suffixes for their own names.
  46902. * @param urlsOfPhoto defines the url of the photo to display
  46903. * @param options defines an object containing optional or exposed sub element properties
  46904. * @param onError defines a callback called when an error occured while loading the texture
  46905. */
  46906. constructor(name: string, urlOfPhoto: string, options: {
  46907. resolution?: number;
  46908. size?: number;
  46909. useDirectMapping?: boolean;
  46910. faceForward?: boolean;
  46911. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46912. private _onBeforeCameraRenderObserver;
  46913. private _changeImageMode;
  46914. /**
  46915. * Releases resources associated with this node.
  46916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46918. */
  46919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46920. }
  46921. }
  46922. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46923. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46924. /** @hidden */
  46925. export var rgbdDecodePixelShader: {
  46926. name: string;
  46927. shader: string;
  46928. };
  46929. }
  46930. declare module "babylonjs/Misc/brdfTextureTools" {
  46931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46932. import { Scene } from "babylonjs/scene";
  46933. import "babylonjs/Shaders/rgbdDecode.fragment";
  46934. /**
  46935. * Class used to host texture specific utilities
  46936. */
  46937. export class BRDFTextureTools {
  46938. /**
  46939. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46940. * @param texture the texture to expand.
  46941. */
  46942. private static _ExpandDefaultBRDFTexture;
  46943. /**
  46944. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46945. * @param scene defines the hosting scene
  46946. * @returns the environment BRDF texture
  46947. */
  46948. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46949. private static _environmentBRDFBase64Texture;
  46950. }
  46951. }
  46952. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46953. import { Nullable } from "babylonjs/types";
  46954. import { Color3 } from "babylonjs/Maths/math.color";
  46955. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46956. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46957. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46959. import { Engine } from "babylonjs/Engines/engine";
  46960. import { Scene } from "babylonjs/scene";
  46961. /**
  46962. * @hidden
  46963. */
  46964. export interface IMaterialClearCoatDefines {
  46965. CLEARCOAT: boolean;
  46966. CLEARCOAT_DEFAULTIOR: boolean;
  46967. CLEARCOAT_TEXTURE: boolean;
  46968. CLEARCOAT_TEXTUREDIRECTUV: number;
  46969. CLEARCOAT_BUMP: boolean;
  46970. CLEARCOAT_BUMPDIRECTUV: number;
  46971. CLEARCOAT_TINT: boolean;
  46972. CLEARCOAT_TINT_TEXTURE: boolean;
  46973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46974. /** @hidden */
  46975. _areTexturesDirty: boolean;
  46976. }
  46977. /**
  46978. * Define the code related to the clear coat parameters of the pbr material.
  46979. */
  46980. export class PBRClearCoatConfiguration {
  46981. /**
  46982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46983. * The default fits with a polyurethane material.
  46984. */
  46985. private static readonly _DefaultIndexOfRefraction;
  46986. private _isEnabled;
  46987. /**
  46988. * Defines if the clear coat is enabled in the material.
  46989. */
  46990. isEnabled: boolean;
  46991. /**
  46992. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46993. */
  46994. intensity: number;
  46995. /**
  46996. * Defines the clear coat layer roughness.
  46997. */
  46998. roughness: number;
  46999. private _indexOfRefraction;
  47000. /**
  47001. * Defines the index of refraction of the clear coat.
  47002. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47003. * The default fits with a polyurethane material.
  47004. * Changing the default value is more performance intensive.
  47005. */
  47006. indexOfRefraction: number;
  47007. private _texture;
  47008. /**
  47009. * Stores the clear coat values in a texture.
  47010. */
  47011. texture: Nullable<BaseTexture>;
  47012. private _bumpTexture;
  47013. /**
  47014. * Define the clear coat specific bump texture.
  47015. */
  47016. bumpTexture: Nullable<BaseTexture>;
  47017. private _isTintEnabled;
  47018. /**
  47019. * Defines if the clear coat tint is enabled in the material.
  47020. */
  47021. isTintEnabled: boolean;
  47022. /**
  47023. * Defines the clear coat tint of the material.
  47024. * This is only use if tint is enabled
  47025. */
  47026. tintColor: Color3;
  47027. /**
  47028. * Defines the distance at which the tint color should be found in the
  47029. * clear coat media.
  47030. * This is only use if tint is enabled
  47031. */
  47032. tintColorAtDistance: number;
  47033. /**
  47034. * Defines the clear coat layer thickness.
  47035. * This is only use if tint is enabled
  47036. */
  47037. tintThickness: number;
  47038. private _tintTexture;
  47039. /**
  47040. * Stores the clear tint values in a texture.
  47041. * rgb is tint
  47042. * a is a thickness factor
  47043. */
  47044. tintTexture: Nullable<BaseTexture>;
  47045. /** @hidden */
  47046. private _internalMarkAllSubMeshesAsTexturesDirty;
  47047. /** @hidden */
  47048. _markAllSubMeshesAsTexturesDirty(): void;
  47049. /**
  47050. * Instantiate a new istance of clear coat configuration.
  47051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47052. */
  47053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47054. /**
  47055. * Gets wehter the submesh is ready to be used or not.
  47056. * @param defines the list of "defines" to update.
  47057. * @param scene defines the scene the material belongs to.
  47058. * @param engine defines the engine the material belongs to.
  47059. * @param disableBumpMap defines wether the material disables bump or not.
  47060. * @returns - boolean indicating that the submesh is ready or not.
  47061. */
  47062. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47063. /**
  47064. * Checks to see if a texture is used in the material.
  47065. * @param defines the list of "defines" to update.
  47066. * @param scene defines the scene to the material belongs to.
  47067. */
  47068. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47069. /**
  47070. * Binds the material data.
  47071. * @param uniformBuffer defines the Uniform buffer to fill in.
  47072. * @param scene defines the scene the material belongs to.
  47073. * @param engine defines the engine the material belongs to.
  47074. * @param disableBumpMap defines wether the material disables bump or not.
  47075. * @param isFrozen defines wether the material is frozen or not.
  47076. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47077. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47078. */
  47079. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47080. /**
  47081. * Checks to see if a texture is used in the material.
  47082. * @param texture - Base texture to use.
  47083. * @returns - Boolean specifying if a texture is used in the material.
  47084. */
  47085. hasTexture(texture: BaseTexture): boolean;
  47086. /**
  47087. * Returns an array of the actively used textures.
  47088. * @param activeTextures Array of BaseTextures
  47089. */
  47090. getActiveTextures(activeTextures: BaseTexture[]): void;
  47091. /**
  47092. * Returns the animatable textures.
  47093. * @param animatables Array of animatable textures.
  47094. */
  47095. getAnimatables(animatables: IAnimatable[]): void;
  47096. /**
  47097. * Disposes the resources of the material.
  47098. * @param forceDisposeTextures - Forces the disposal of all textures.
  47099. */
  47100. dispose(forceDisposeTextures?: boolean): void;
  47101. /**
  47102. * Get the current class name of the texture useful for serialization or dynamic coding.
  47103. * @returns "PBRClearCoatConfiguration"
  47104. */
  47105. getClassName(): string;
  47106. /**
  47107. * Add fallbacks to the effect fallbacks list.
  47108. * @param defines defines the Base texture to use.
  47109. * @param fallbacks defines the current fallback list.
  47110. * @param currentRank defines the current fallback rank.
  47111. * @returns the new fallback rank.
  47112. */
  47113. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47114. /**
  47115. * Add the required uniforms to the current list.
  47116. * @param uniforms defines the current uniform list.
  47117. */
  47118. static AddUniforms(uniforms: string[]): void;
  47119. /**
  47120. * Add the required samplers to the current list.
  47121. * @param samplers defines the current sampler list.
  47122. */
  47123. static AddSamplers(samplers: string[]): void;
  47124. /**
  47125. * Add the required uniforms to the current buffer.
  47126. * @param uniformBuffer defines the current uniform buffer.
  47127. */
  47128. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47129. /**
  47130. * Makes a duplicate of the current configuration into another one.
  47131. * @param clearCoatConfiguration define the config where to copy the info
  47132. */
  47133. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47134. /**
  47135. * Serializes this clear coat configuration.
  47136. * @returns - An object with the serialized config.
  47137. */
  47138. serialize(): any;
  47139. /**
  47140. * Parses a anisotropy Configuration from a serialized object.
  47141. * @param source - Serialized object.
  47142. * @param scene Defines the scene we are parsing for
  47143. * @param rootUrl Defines the rootUrl to load from
  47144. */
  47145. parse(source: any, scene: Scene, rootUrl: string): void;
  47146. }
  47147. }
  47148. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47149. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47150. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47152. import { Vector2 } from "babylonjs/Maths/math.vector";
  47153. import { Scene } from "babylonjs/scene";
  47154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47155. import { Nullable } from "babylonjs/types";
  47156. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47157. /**
  47158. * @hidden
  47159. */
  47160. export interface IMaterialAnisotropicDefines {
  47161. ANISOTROPIC: boolean;
  47162. ANISOTROPIC_TEXTURE: boolean;
  47163. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47164. MAINUV1: boolean;
  47165. _areTexturesDirty: boolean;
  47166. _needUVs: boolean;
  47167. }
  47168. /**
  47169. * Define the code related to the anisotropic parameters of the pbr material.
  47170. */
  47171. export class PBRAnisotropicConfiguration {
  47172. private _isEnabled;
  47173. /**
  47174. * Defines if the anisotropy is enabled in the material.
  47175. */
  47176. isEnabled: boolean;
  47177. /**
  47178. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47179. */
  47180. intensity: number;
  47181. /**
  47182. * Defines if the effect is along the tangents, bitangents or in between.
  47183. * By default, the effect is "strectching" the highlights along the tangents.
  47184. */
  47185. direction: Vector2;
  47186. private _texture;
  47187. /**
  47188. * Stores the anisotropy values in a texture.
  47189. * rg is direction (like normal from -1 to 1)
  47190. * b is a intensity
  47191. */
  47192. texture: Nullable<BaseTexture>;
  47193. /** @hidden */
  47194. private _internalMarkAllSubMeshesAsTexturesDirty;
  47195. /** @hidden */
  47196. _markAllSubMeshesAsTexturesDirty(): void;
  47197. /**
  47198. * Instantiate a new istance of anisotropy configuration.
  47199. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47200. */
  47201. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47202. /**
  47203. * Specifies that the submesh is ready to be used.
  47204. * @param defines the list of "defines" to update.
  47205. * @param scene defines the scene the material belongs to.
  47206. * @returns - boolean indicating that the submesh is ready or not.
  47207. */
  47208. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47209. /**
  47210. * Checks to see if a texture is used in the material.
  47211. * @param defines the list of "defines" to update.
  47212. * @param mesh the mesh we are preparing the defines for.
  47213. * @param scene defines the scene the material belongs to.
  47214. */
  47215. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47216. /**
  47217. * Binds the material data.
  47218. * @param uniformBuffer defines the Uniform buffer to fill in.
  47219. * @param scene defines the scene the material belongs to.
  47220. * @param isFrozen defines wether the material is frozen or not.
  47221. */
  47222. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47223. /**
  47224. * Checks to see if a texture is used in the material.
  47225. * @param texture - Base texture to use.
  47226. * @returns - Boolean specifying if a texture is used in the material.
  47227. */
  47228. hasTexture(texture: BaseTexture): boolean;
  47229. /**
  47230. * Returns an array of the actively used textures.
  47231. * @param activeTextures Array of BaseTextures
  47232. */
  47233. getActiveTextures(activeTextures: BaseTexture[]): void;
  47234. /**
  47235. * Returns the animatable textures.
  47236. * @param animatables Array of animatable textures.
  47237. */
  47238. getAnimatables(animatables: IAnimatable[]): void;
  47239. /**
  47240. * Disposes the resources of the material.
  47241. * @param forceDisposeTextures - Forces the disposal of all textures.
  47242. */
  47243. dispose(forceDisposeTextures?: boolean): void;
  47244. /**
  47245. * Get the current class name of the texture useful for serialization or dynamic coding.
  47246. * @returns "PBRAnisotropicConfiguration"
  47247. */
  47248. getClassName(): string;
  47249. /**
  47250. * Add fallbacks to the effect fallbacks list.
  47251. * @param defines defines the Base texture to use.
  47252. * @param fallbacks defines the current fallback list.
  47253. * @param currentRank defines the current fallback rank.
  47254. * @returns the new fallback rank.
  47255. */
  47256. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47257. /**
  47258. * Add the required uniforms to the current list.
  47259. * @param uniforms defines the current uniform list.
  47260. */
  47261. static AddUniforms(uniforms: string[]): void;
  47262. /**
  47263. * Add the required uniforms to the current buffer.
  47264. * @param uniformBuffer defines the current uniform buffer.
  47265. */
  47266. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47267. /**
  47268. * Add the required samplers to the current list.
  47269. * @param samplers defines the current sampler list.
  47270. */
  47271. static AddSamplers(samplers: string[]): void;
  47272. /**
  47273. * Makes a duplicate of the current configuration into another one.
  47274. * @param anisotropicConfiguration define the config where to copy the info
  47275. */
  47276. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47277. /**
  47278. * Serializes this anisotropy configuration.
  47279. * @returns - An object with the serialized config.
  47280. */
  47281. serialize(): any;
  47282. /**
  47283. * Parses a anisotropy Configuration from a serialized object.
  47284. * @param source - Serialized object.
  47285. * @param scene Defines the scene we are parsing for
  47286. * @param rootUrl Defines the rootUrl to load from
  47287. */
  47288. parse(source: any, scene: Scene, rootUrl: string): void;
  47289. }
  47290. }
  47291. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47292. import { Scene } from "babylonjs/scene";
  47293. /**
  47294. * @hidden
  47295. */
  47296. export interface IMaterialBRDFDefines {
  47297. BRDF_V_HEIGHT_CORRELATED: boolean;
  47298. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47299. SPHERICAL_HARMONICS: boolean;
  47300. /** @hidden */
  47301. _areMiscDirty: boolean;
  47302. }
  47303. /**
  47304. * Define the code related to the BRDF parameters of the pbr material.
  47305. */
  47306. export class PBRBRDFConfiguration {
  47307. /**
  47308. * Default value used for the energy conservation.
  47309. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47310. */
  47311. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47312. /**
  47313. * Default value used for the Smith Visibility Height Correlated mode.
  47314. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47315. */
  47316. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47317. /**
  47318. * Default value used for the IBL diffuse part.
  47319. * This can help switching back to the polynomials mode globally which is a tiny bit
  47320. * less GPU intensive at the drawback of a lower quality.
  47321. */
  47322. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47323. private _useEnergyConservation;
  47324. /**
  47325. * Defines if the material uses energy conservation.
  47326. */
  47327. useEnergyConservation: boolean;
  47328. private _useSmithVisibilityHeightCorrelated;
  47329. /**
  47330. * LEGACY Mode set to false
  47331. * Defines if the material uses height smith correlated visibility term.
  47332. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47333. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47334. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47335. * Not relying on height correlated will also disable energy conservation.
  47336. */
  47337. useSmithVisibilityHeightCorrelated: boolean;
  47338. private _useSphericalHarmonics;
  47339. /**
  47340. * LEGACY Mode set to false
  47341. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47342. * diffuse part of the IBL.
  47343. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47344. * to the ground truth.
  47345. */
  47346. useSphericalHarmonics: boolean;
  47347. /** @hidden */
  47348. private _internalMarkAllSubMeshesAsMiscDirty;
  47349. /** @hidden */
  47350. _markAllSubMeshesAsMiscDirty(): void;
  47351. /**
  47352. * Instantiate a new istance of clear coat configuration.
  47353. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47354. */
  47355. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47356. /**
  47357. * Checks to see if a texture is used in the material.
  47358. * @param defines the list of "defines" to update.
  47359. */
  47360. prepareDefines(defines: IMaterialBRDFDefines): void;
  47361. /**
  47362. * Get the current class name of the texture useful for serialization or dynamic coding.
  47363. * @returns "PBRClearCoatConfiguration"
  47364. */
  47365. getClassName(): string;
  47366. /**
  47367. * Makes a duplicate of the current configuration into another one.
  47368. * @param brdfConfiguration define the config where to copy the info
  47369. */
  47370. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47371. /**
  47372. * Serializes this BRDF configuration.
  47373. * @returns - An object with the serialized config.
  47374. */
  47375. serialize(): any;
  47376. /**
  47377. * Parses a anisotropy Configuration from a serialized object.
  47378. * @param source - Serialized object.
  47379. * @param scene Defines the scene we are parsing for
  47380. * @param rootUrl Defines the rootUrl to load from
  47381. */
  47382. parse(source: any, scene: Scene, rootUrl: string): void;
  47383. }
  47384. }
  47385. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47386. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47387. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47388. import { Color3 } from "babylonjs/Maths/math.color";
  47389. import { Scene } from "babylonjs/scene";
  47390. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47391. import { Nullable } from "babylonjs/types";
  47392. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47393. /**
  47394. * @hidden
  47395. */
  47396. export interface IMaterialSheenDefines {
  47397. SHEEN: boolean;
  47398. SHEEN_TEXTURE: boolean;
  47399. SHEEN_TEXTUREDIRECTUV: number;
  47400. SHEEN_LINKWITHALBEDO: boolean;
  47401. /** @hidden */
  47402. _areTexturesDirty: boolean;
  47403. }
  47404. /**
  47405. * Define the code related to the Sheen parameters of the pbr material.
  47406. */
  47407. export class PBRSheenConfiguration {
  47408. private _isEnabled;
  47409. /**
  47410. * Defines if the material uses sheen.
  47411. */
  47412. isEnabled: boolean;
  47413. private _linkSheenWithAlbedo;
  47414. /**
  47415. * Defines if the sheen is linked to the sheen color.
  47416. */
  47417. linkSheenWithAlbedo: boolean;
  47418. /**
  47419. * Defines the sheen intensity.
  47420. */
  47421. intensity: number;
  47422. /**
  47423. * Defines the sheen color.
  47424. */
  47425. color: Color3;
  47426. private _texture;
  47427. /**
  47428. * Stores the sheen tint values in a texture.
  47429. * rgb is tint
  47430. * a is a intensity
  47431. */
  47432. texture: Nullable<BaseTexture>;
  47433. /** @hidden */
  47434. private _internalMarkAllSubMeshesAsTexturesDirty;
  47435. /** @hidden */
  47436. _markAllSubMeshesAsTexturesDirty(): void;
  47437. /**
  47438. * Instantiate a new istance of clear coat configuration.
  47439. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47440. */
  47441. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47442. /**
  47443. * Specifies that the submesh is ready to be used.
  47444. * @param defines the list of "defines" to update.
  47445. * @param scene defines the scene the material belongs to.
  47446. * @returns - boolean indicating that the submesh is ready or not.
  47447. */
  47448. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47449. /**
  47450. * Checks to see if a texture is used in the material.
  47451. * @param defines the list of "defines" to update.
  47452. * @param scene defines the scene the material belongs to.
  47453. */
  47454. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47455. /**
  47456. * Binds the material data.
  47457. * @param uniformBuffer defines the Uniform buffer to fill in.
  47458. * @param scene defines the scene the material belongs to.
  47459. * @param isFrozen defines wether the material is frozen or not.
  47460. */
  47461. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47462. /**
  47463. * Checks to see if a texture is used in the material.
  47464. * @param texture - Base texture to use.
  47465. * @returns - Boolean specifying if a texture is used in the material.
  47466. */
  47467. hasTexture(texture: BaseTexture): boolean;
  47468. /**
  47469. * Returns an array of the actively used textures.
  47470. * @param activeTextures Array of BaseTextures
  47471. */
  47472. getActiveTextures(activeTextures: BaseTexture[]): void;
  47473. /**
  47474. * Returns the animatable textures.
  47475. * @param animatables Array of animatable textures.
  47476. */
  47477. getAnimatables(animatables: IAnimatable[]): void;
  47478. /**
  47479. * Disposes the resources of the material.
  47480. * @param forceDisposeTextures - Forces the disposal of all textures.
  47481. */
  47482. dispose(forceDisposeTextures?: boolean): void;
  47483. /**
  47484. * Get the current class name of the texture useful for serialization or dynamic coding.
  47485. * @returns "PBRSheenConfiguration"
  47486. */
  47487. getClassName(): string;
  47488. /**
  47489. * Add fallbacks to the effect fallbacks list.
  47490. * @param defines defines the Base texture to use.
  47491. * @param fallbacks defines the current fallback list.
  47492. * @param currentRank defines the current fallback rank.
  47493. * @returns the new fallback rank.
  47494. */
  47495. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47496. /**
  47497. * Add the required uniforms to the current list.
  47498. * @param uniforms defines the current uniform list.
  47499. */
  47500. static AddUniforms(uniforms: string[]): void;
  47501. /**
  47502. * Add the required uniforms to the current buffer.
  47503. * @param uniformBuffer defines the current uniform buffer.
  47504. */
  47505. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47506. /**
  47507. * Add the required samplers to the current list.
  47508. * @param samplers defines the current sampler list.
  47509. */
  47510. static AddSamplers(samplers: string[]): void;
  47511. /**
  47512. * Makes a duplicate of the current configuration into another one.
  47513. * @param sheenConfiguration define the config where to copy the info
  47514. */
  47515. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47516. /**
  47517. * Serializes this BRDF configuration.
  47518. * @returns - An object with the serialized config.
  47519. */
  47520. serialize(): any;
  47521. /**
  47522. * Parses a anisotropy Configuration from a serialized object.
  47523. * @param source - Serialized object.
  47524. * @param scene Defines the scene we are parsing for
  47525. * @param rootUrl Defines the rootUrl to load from
  47526. */
  47527. parse(source: any, scene: Scene, rootUrl: string): void;
  47528. }
  47529. }
  47530. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47531. import { Nullable } from "babylonjs/types";
  47532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47533. import { Color3 } from "babylonjs/Maths/math.color";
  47534. import { SmartArray } from "babylonjs/Misc/smartArray";
  47535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47536. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47537. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47538. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47539. import { Engine } from "babylonjs/Engines/engine";
  47540. import { Scene } from "babylonjs/scene";
  47541. /**
  47542. * @hidden
  47543. */
  47544. export interface IMaterialSubSurfaceDefines {
  47545. SUBSURFACE: boolean;
  47546. SS_REFRACTION: boolean;
  47547. SS_TRANSLUCENCY: boolean;
  47548. SS_SCATERRING: boolean;
  47549. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47550. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47551. SS_REFRACTIONMAP_3D: boolean;
  47552. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47553. SS_LODINREFRACTIONALPHA: boolean;
  47554. SS_GAMMAREFRACTION: boolean;
  47555. SS_RGBDREFRACTION: boolean;
  47556. SS_LINEARSPECULARREFRACTION: boolean;
  47557. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47558. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47559. /** @hidden */
  47560. _areTexturesDirty: boolean;
  47561. }
  47562. /**
  47563. * Define the code related to the sub surface parameters of the pbr material.
  47564. */
  47565. export class PBRSubSurfaceConfiguration {
  47566. private _isRefractionEnabled;
  47567. /**
  47568. * Defines if the refraction is enabled in the material.
  47569. */
  47570. isRefractionEnabled: boolean;
  47571. private _isTranslucencyEnabled;
  47572. /**
  47573. * Defines if the translucency is enabled in the material.
  47574. */
  47575. isTranslucencyEnabled: boolean;
  47576. private _isScatteringEnabled;
  47577. /**
  47578. * Defines the refraction intensity of the material.
  47579. * The refraction when enabled replaces the Diffuse part of the material.
  47580. * The intensity helps transitionning between diffuse and refraction.
  47581. */
  47582. refractionIntensity: number;
  47583. /**
  47584. * Defines the translucency intensity of the material.
  47585. * When translucency has been enabled, this defines how much of the "translucency"
  47586. * is addded to the diffuse part of the material.
  47587. */
  47588. translucencyIntensity: number;
  47589. /**
  47590. * Defines the scattering intensity of the material.
  47591. * When scattering has been enabled, this defines how much of the "scattered light"
  47592. * is addded to the diffuse part of the material.
  47593. */
  47594. scatteringIntensity: number;
  47595. private _thicknessTexture;
  47596. /**
  47597. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47598. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47599. * 0 would mean minimumThickness
  47600. * 1 would mean maximumThickness
  47601. * The other channels might be use as a mask to vary the different effects intensity.
  47602. */
  47603. thicknessTexture: Nullable<BaseTexture>;
  47604. private _refractionTexture;
  47605. /**
  47606. * Defines the texture to use for refraction.
  47607. */
  47608. refractionTexture: Nullable<BaseTexture>;
  47609. private _indexOfRefraction;
  47610. /**
  47611. * Defines the index of refraction used in the material.
  47612. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47613. */
  47614. indexOfRefraction: number;
  47615. private _invertRefractionY;
  47616. /**
  47617. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47618. */
  47619. invertRefractionY: boolean;
  47620. private _linkRefractionWithTransparency;
  47621. /**
  47622. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47623. * Materials half opaque for instance using refraction could benefit from this control.
  47624. */
  47625. linkRefractionWithTransparency: boolean;
  47626. /**
  47627. * Defines the minimum thickness stored in the thickness map.
  47628. * If no thickness map is defined, this value will be used to simulate thickness.
  47629. */
  47630. minimumThickness: number;
  47631. /**
  47632. * Defines the maximum thickness stored in the thickness map.
  47633. */
  47634. maximumThickness: number;
  47635. /**
  47636. * Defines the volume tint of the material.
  47637. * This is used for both translucency and scattering.
  47638. */
  47639. tintColor: Color3;
  47640. /**
  47641. * Defines the distance at which the tint color should be found in the media.
  47642. * This is used for refraction only.
  47643. */
  47644. tintColorAtDistance: number;
  47645. /**
  47646. * Defines how far each channel transmit through the media.
  47647. * It is defined as a color to simplify it selection.
  47648. */
  47649. diffusionDistance: Color3;
  47650. private _useMaskFromThicknessTexture;
  47651. /**
  47652. * Stores the intensity of the different subsurface effects in the thickness texture.
  47653. * * the green channel is the translucency intensity.
  47654. * * the blue channel is the scattering intensity.
  47655. * * the alpha channel is the refraction intensity.
  47656. */
  47657. useMaskFromThicknessTexture: boolean;
  47658. /** @hidden */
  47659. private _internalMarkAllSubMeshesAsTexturesDirty;
  47660. /** @hidden */
  47661. _markAllSubMeshesAsTexturesDirty(): void;
  47662. /**
  47663. * Instantiate a new istance of sub surface configuration.
  47664. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47665. */
  47666. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47667. /**
  47668. * Gets wehter the submesh is ready to be used or not.
  47669. * @param defines the list of "defines" to update.
  47670. * @param scene defines the scene the material belongs to.
  47671. * @returns - boolean indicating that the submesh is ready or not.
  47672. */
  47673. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47674. /**
  47675. * Checks to see if a texture is used in the material.
  47676. * @param defines the list of "defines" to update.
  47677. * @param scene defines the scene to the material belongs to.
  47678. */
  47679. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47680. /**
  47681. * Binds the material data.
  47682. * @param uniformBuffer defines the Uniform buffer to fill in.
  47683. * @param scene defines the scene the material belongs to.
  47684. * @param engine defines the engine the material belongs to.
  47685. * @param isFrozen defines wether the material is frozen or not.
  47686. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47687. */
  47688. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47689. /**
  47690. * Unbinds the material from the mesh.
  47691. * @param activeEffect defines the effect that should be unbound from.
  47692. * @returns true if unbound, otherwise false
  47693. */
  47694. unbind(activeEffect: Effect): boolean;
  47695. /**
  47696. * Returns the texture used for refraction or null if none is used.
  47697. * @param scene defines the scene the material belongs to.
  47698. * @returns - Refraction texture if present. If no refraction texture and refraction
  47699. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47700. */
  47701. private _getRefractionTexture;
  47702. /**
  47703. * Returns true if alpha blending should be disabled.
  47704. */
  47705. readonly disableAlphaBlending: boolean;
  47706. /**
  47707. * Fills the list of render target textures.
  47708. * @param renderTargets the list of render targets to update
  47709. */
  47710. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47711. /**
  47712. * Checks to see if a texture is used in the material.
  47713. * @param texture - Base texture to use.
  47714. * @returns - Boolean specifying if a texture is used in the material.
  47715. */
  47716. hasTexture(texture: BaseTexture): boolean;
  47717. /**
  47718. * Gets a boolean indicating that current material needs to register RTT
  47719. * @returns true if this uses a render target otherwise false.
  47720. */
  47721. hasRenderTargetTextures(): boolean;
  47722. /**
  47723. * Returns an array of the actively used textures.
  47724. * @param activeTextures Array of BaseTextures
  47725. */
  47726. getActiveTextures(activeTextures: BaseTexture[]): void;
  47727. /**
  47728. * Returns the animatable textures.
  47729. * @param animatables Array of animatable textures.
  47730. */
  47731. getAnimatables(animatables: IAnimatable[]): void;
  47732. /**
  47733. * Disposes the resources of the material.
  47734. * @param forceDisposeTextures - Forces the disposal of all textures.
  47735. */
  47736. dispose(forceDisposeTextures?: boolean): void;
  47737. /**
  47738. * Get the current class name of the texture useful for serialization or dynamic coding.
  47739. * @returns "PBRSubSurfaceConfiguration"
  47740. */
  47741. getClassName(): string;
  47742. /**
  47743. * Add fallbacks to the effect fallbacks list.
  47744. * @param defines defines the Base texture to use.
  47745. * @param fallbacks defines the current fallback list.
  47746. * @param currentRank defines the current fallback rank.
  47747. * @returns the new fallback rank.
  47748. */
  47749. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47750. /**
  47751. * Add the required uniforms to the current list.
  47752. * @param uniforms defines the current uniform list.
  47753. */
  47754. static AddUniforms(uniforms: string[]): void;
  47755. /**
  47756. * Add the required samplers to the current list.
  47757. * @param samplers defines the current sampler list.
  47758. */
  47759. static AddSamplers(samplers: string[]): void;
  47760. /**
  47761. * Add the required uniforms to the current buffer.
  47762. * @param uniformBuffer defines the current uniform buffer.
  47763. */
  47764. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47765. /**
  47766. * Makes a duplicate of the current configuration into another one.
  47767. * @param configuration define the config where to copy the info
  47768. */
  47769. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47770. /**
  47771. * Serializes this Sub Surface configuration.
  47772. * @returns - An object with the serialized config.
  47773. */
  47774. serialize(): any;
  47775. /**
  47776. * Parses a anisotropy Configuration from a serialized object.
  47777. * @param source - Serialized object.
  47778. * @param scene Defines the scene we are parsing for
  47779. * @param rootUrl Defines the rootUrl to load from
  47780. */
  47781. parse(source: any, scene: Scene, rootUrl: string): void;
  47782. }
  47783. }
  47784. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47785. /** @hidden */
  47786. export var pbrFragmentDeclaration: {
  47787. name: string;
  47788. shader: string;
  47789. };
  47790. }
  47791. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47792. /** @hidden */
  47793. export var pbrUboDeclaration: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47799. /** @hidden */
  47800. export var pbrFragmentExtraDeclaration: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47806. /** @hidden */
  47807. export var pbrFragmentSamplersDeclaration: {
  47808. name: string;
  47809. shader: string;
  47810. };
  47811. }
  47812. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47813. /** @hidden */
  47814. export var pbrHelperFunctions: {
  47815. name: string;
  47816. shader: string;
  47817. };
  47818. }
  47819. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47820. /** @hidden */
  47821. export var harmonicsFunctions: {
  47822. name: string;
  47823. shader: string;
  47824. };
  47825. }
  47826. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47827. /** @hidden */
  47828. export var pbrDirectLightingSetupFunctions: {
  47829. name: string;
  47830. shader: string;
  47831. };
  47832. }
  47833. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47834. /** @hidden */
  47835. export var pbrDirectLightingFalloffFunctions: {
  47836. name: string;
  47837. shader: string;
  47838. };
  47839. }
  47840. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47841. /** @hidden */
  47842. export var pbrBRDFFunctions: {
  47843. name: string;
  47844. shader: string;
  47845. };
  47846. }
  47847. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47848. /** @hidden */
  47849. export var pbrDirectLightingFunctions: {
  47850. name: string;
  47851. shader: string;
  47852. };
  47853. }
  47854. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47855. /** @hidden */
  47856. export var pbrIBLFunctions: {
  47857. name: string;
  47858. shader: string;
  47859. };
  47860. }
  47861. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47862. /** @hidden */
  47863. export var pbrDebug: {
  47864. name: string;
  47865. shader: string;
  47866. };
  47867. }
  47868. declare module "babylonjs/Shaders/pbr.fragment" {
  47869. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47870. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47871. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47872. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47873. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47874. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47875. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47876. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47877. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47878. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47879. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47880. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47881. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47882. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47883. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47884. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47885. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47886. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47887. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47888. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47889. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47890. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47891. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47892. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47893. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47894. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47895. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47896. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47897. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47898. /** @hidden */
  47899. export var pbrPixelShader: {
  47900. name: string;
  47901. shader: string;
  47902. };
  47903. }
  47904. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47905. /** @hidden */
  47906. export var pbrVertexDeclaration: {
  47907. name: string;
  47908. shader: string;
  47909. };
  47910. }
  47911. declare module "babylonjs/Shaders/pbr.vertex" {
  47912. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47913. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47914. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47915. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47917. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47918. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47919. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47920. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47921. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47922. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47924. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47925. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47926. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47927. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47928. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47929. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47930. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47931. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47932. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47933. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47934. /** @hidden */
  47935. export var pbrVertexShader: {
  47936. name: string;
  47937. shader: string;
  47938. };
  47939. }
  47940. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47941. import { Nullable } from "babylonjs/types";
  47942. import { Scene } from "babylonjs/scene";
  47943. import { Matrix } from "babylonjs/Maths/math.vector";
  47944. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47946. import { Mesh } from "babylonjs/Meshes/mesh";
  47947. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47948. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47949. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47950. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47951. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47952. import { Color3 } from "babylonjs/Maths/math.color";
  47953. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47954. import { Material } from "babylonjs/Materials/material";
  47955. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47956. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47957. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47958. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47959. import "babylonjs/Shaders/pbr.fragment";
  47960. import "babylonjs/Shaders/pbr.vertex";
  47961. /**
  47962. * Manages the defines for the PBR Material.
  47963. * @hidden
  47964. */
  47965. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47966. PBR: boolean;
  47967. MAINUV1: boolean;
  47968. MAINUV2: boolean;
  47969. UV1: boolean;
  47970. UV2: boolean;
  47971. ALBEDO: boolean;
  47972. ALBEDODIRECTUV: number;
  47973. VERTEXCOLOR: boolean;
  47974. AMBIENT: boolean;
  47975. AMBIENTDIRECTUV: number;
  47976. AMBIENTINGRAYSCALE: boolean;
  47977. OPACITY: boolean;
  47978. VERTEXALPHA: boolean;
  47979. OPACITYDIRECTUV: number;
  47980. OPACITYRGB: boolean;
  47981. ALPHATEST: boolean;
  47982. DEPTHPREPASS: boolean;
  47983. ALPHABLEND: boolean;
  47984. ALPHAFROMALBEDO: boolean;
  47985. ALPHATESTVALUE: string;
  47986. SPECULAROVERALPHA: boolean;
  47987. RADIANCEOVERALPHA: boolean;
  47988. ALPHAFRESNEL: boolean;
  47989. LINEARALPHAFRESNEL: boolean;
  47990. PREMULTIPLYALPHA: boolean;
  47991. EMISSIVE: boolean;
  47992. EMISSIVEDIRECTUV: number;
  47993. REFLECTIVITY: boolean;
  47994. REFLECTIVITYDIRECTUV: number;
  47995. SPECULARTERM: boolean;
  47996. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47997. MICROSURFACEAUTOMATIC: boolean;
  47998. LODBASEDMICROSFURACE: boolean;
  47999. MICROSURFACEMAP: boolean;
  48000. MICROSURFACEMAPDIRECTUV: number;
  48001. METALLICWORKFLOW: boolean;
  48002. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48003. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48004. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48005. AOSTOREINMETALMAPRED: boolean;
  48006. ENVIRONMENTBRDF: boolean;
  48007. ENVIRONMENTBRDF_RGBD: boolean;
  48008. NORMAL: boolean;
  48009. TANGENT: boolean;
  48010. BUMP: boolean;
  48011. BUMPDIRECTUV: number;
  48012. OBJECTSPACE_NORMALMAP: boolean;
  48013. PARALLAX: boolean;
  48014. PARALLAXOCCLUSION: boolean;
  48015. NORMALXYSCALE: boolean;
  48016. LIGHTMAP: boolean;
  48017. LIGHTMAPDIRECTUV: number;
  48018. USELIGHTMAPASSHADOWMAP: boolean;
  48019. GAMMALIGHTMAP: boolean;
  48020. REFLECTION: boolean;
  48021. REFLECTIONMAP_3D: boolean;
  48022. REFLECTIONMAP_SPHERICAL: boolean;
  48023. REFLECTIONMAP_PLANAR: boolean;
  48024. REFLECTIONMAP_CUBIC: boolean;
  48025. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48026. REFLECTIONMAP_PROJECTION: boolean;
  48027. REFLECTIONMAP_SKYBOX: boolean;
  48028. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48029. REFLECTIONMAP_EXPLICIT: boolean;
  48030. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48031. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48032. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48033. INVERTCUBICMAP: boolean;
  48034. USESPHERICALFROMREFLECTIONMAP: boolean;
  48035. USEIRRADIANCEMAP: boolean;
  48036. SPHERICAL_HARMONICS: boolean;
  48037. USESPHERICALINVERTEX: boolean;
  48038. REFLECTIONMAP_OPPOSITEZ: boolean;
  48039. LODINREFLECTIONALPHA: boolean;
  48040. GAMMAREFLECTION: boolean;
  48041. RGBDREFLECTION: boolean;
  48042. LINEARSPECULARREFLECTION: boolean;
  48043. RADIANCEOCCLUSION: boolean;
  48044. HORIZONOCCLUSION: boolean;
  48045. INSTANCES: boolean;
  48046. NUM_BONE_INFLUENCERS: number;
  48047. BonesPerMesh: number;
  48048. BONETEXTURE: boolean;
  48049. NONUNIFORMSCALING: boolean;
  48050. MORPHTARGETS: boolean;
  48051. MORPHTARGETS_NORMAL: boolean;
  48052. MORPHTARGETS_TANGENT: boolean;
  48053. MORPHTARGETS_UV: boolean;
  48054. NUM_MORPH_INFLUENCERS: number;
  48055. IMAGEPROCESSING: boolean;
  48056. VIGNETTE: boolean;
  48057. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48058. VIGNETTEBLENDMODEOPAQUE: boolean;
  48059. TONEMAPPING: boolean;
  48060. TONEMAPPING_ACES: boolean;
  48061. CONTRAST: boolean;
  48062. COLORCURVES: boolean;
  48063. COLORGRADING: boolean;
  48064. COLORGRADING3D: boolean;
  48065. SAMPLER3DGREENDEPTH: boolean;
  48066. SAMPLER3DBGRMAP: boolean;
  48067. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48068. EXPOSURE: boolean;
  48069. MULTIVIEW: boolean;
  48070. USEPHYSICALLIGHTFALLOFF: boolean;
  48071. USEGLTFLIGHTFALLOFF: boolean;
  48072. TWOSIDEDLIGHTING: boolean;
  48073. SHADOWFLOAT: boolean;
  48074. CLIPPLANE: boolean;
  48075. CLIPPLANE2: boolean;
  48076. CLIPPLANE3: boolean;
  48077. CLIPPLANE4: boolean;
  48078. POINTSIZE: boolean;
  48079. FOG: boolean;
  48080. LOGARITHMICDEPTH: boolean;
  48081. FORCENORMALFORWARD: boolean;
  48082. SPECULARAA: boolean;
  48083. CLEARCOAT: boolean;
  48084. CLEARCOAT_DEFAULTIOR: boolean;
  48085. CLEARCOAT_TEXTURE: boolean;
  48086. CLEARCOAT_TEXTUREDIRECTUV: number;
  48087. CLEARCOAT_BUMP: boolean;
  48088. CLEARCOAT_BUMPDIRECTUV: number;
  48089. CLEARCOAT_TINT: boolean;
  48090. CLEARCOAT_TINT_TEXTURE: boolean;
  48091. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48092. ANISOTROPIC: boolean;
  48093. ANISOTROPIC_TEXTURE: boolean;
  48094. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48095. BRDF_V_HEIGHT_CORRELATED: boolean;
  48096. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48097. SHEEN: boolean;
  48098. SHEEN_TEXTURE: boolean;
  48099. SHEEN_TEXTUREDIRECTUV: number;
  48100. SHEEN_LINKWITHALBEDO: boolean;
  48101. SUBSURFACE: boolean;
  48102. SS_REFRACTION: boolean;
  48103. SS_TRANSLUCENCY: boolean;
  48104. SS_SCATERRING: boolean;
  48105. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48106. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48107. SS_REFRACTIONMAP_3D: boolean;
  48108. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48109. SS_LODINREFRACTIONALPHA: boolean;
  48110. SS_GAMMAREFRACTION: boolean;
  48111. SS_RGBDREFRACTION: boolean;
  48112. SS_LINEARSPECULARREFRACTION: boolean;
  48113. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48114. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48115. UNLIT: boolean;
  48116. DEBUGMODE: number;
  48117. /**
  48118. * Initializes the PBR Material defines.
  48119. */
  48120. constructor();
  48121. /**
  48122. * Resets the PBR Material defines.
  48123. */
  48124. reset(): void;
  48125. }
  48126. /**
  48127. * The Physically based material base class of BJS.
  48128. *
  48129. * This offers the main features of a standard PBR material.
  48130. * For more information, please refer to the documentation :
  48131. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48132. */
  48133. export abstract class PBRBaseMaterial extends PushMaterial {
  48134. /**
  48135. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48136. */
  48137. static readonly PBRMATERIAL_OPAQUE: number;
  48138. /**
  48139. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48140. */
  48141. static readonly PBRMATERIAL_ALPHATEST: number;
  48142. /**
  48143. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48144. */
  48145. static readonly PBRMATERIAL_ALPHABLEND: number;
  48146. /**
  48147. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48148. * They are also discarded below the alpha cutoff threshold to improve performances.
  48149. */
  48150. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48151. /**
  48152. * Defines the default value of how much AO map is occluding the analytical lights
  48153. * (point spot...).
  48154. */
  48155. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48156. /**
  48157. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48158. */
  48159. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48160. /**
  48161. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48162. * to enhance interoperability with other engines.
  48163. */
  48164. static readonly LIGHTFALLOFF_GLTF: number;
  48165. /**
  48166. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48167. * to enhance interoperability with other materials.
  48168. */
  48169. static readonly LIGHTFALLOFF_STANDARD: number;
  48170. /**
  48171. * Intensity of the direct lights e.g. the four lights available in your scene.
  48172. * This impacts both the direct diffuse and specular highlights.
  48173. */
  48174. protected _directIntensity: number;
  48175. /**
  48176. * Intensity of the emissive part of the material.
  48177. * This helps controlling the emissive effect without modifying the emissive color.
  48178. */
  48179. protected _emissiveIntensity: number;
  48180. /**
  48181. * Intensity of the environment e.g. how much the environment will light the object
  48182. * either through harmonics for rough material or through the refelction for shiny ones.
  48183. */
  48184. protected _environmentIntensity: number;
  48185. /**
  48186. * This is a special control allowing the reduction of the specular highlights coming from the
  48187. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48188. */
  48189. protected _specularIntensity: number;
  48190. /**
  48191. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48192. */
  48193. private _lightingInfos;
  48194. /**
  48195. * Debug Control allowing disabling the bump map on this material.
  48196. */
  48197. protected _disableBumpMap: boolean;
  48198. /**
  48199. * AKA Diffuse Texture in standard nomenclature.
  48200. */
  48201. protected _albedoTexture: Nullable<BaseTexture>;
  48202. /**
  48203. * AKA Occlusion Texture in other nomenclature.
  48204. */
  48205. protected _ambientTexture: Nullable<BaseTexture>;
  48206. /**
  48207. * AKA Occlusion Texture Intensity in other nomenclature.
  48208. */
  48209. protected _ambientTextureStrength: number;
  48210. /**
  48211. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48212. * 1 means it completely occludes it
  48213. * 0 mean it has no impact
  48214. */
  48215. protected _ambientTextureImpactOnAnalyticalLights: number;
  48216. /**
  48217. * Stores the alpha values in a texture.
  48218. */
  48219. protected _opacityTexture: Nullable<BaseTexture>;
  48220. /**
  48221. * Stores the reflection values in a texture.
  48222. */
  48223. protected _reflectionTexture: Nullable<BaseTexture>;
  48224. /**
  48225. * Stores the emissive values in a texture.
  48226. */
  48227. protected _emissiveTexture: Nullable<BaseTexture>;
  48228. /**
  48229. * AKA Specular texture in other nomenclature.
  48230. */
  48231. protected _reflectivityTexture: Nullable<BaseTexture>;
  48232. /**
  48233. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48234. */
  48235. protected _metallicTexture: Nullable<BaseTexture>;
  48236. /**
  48237. * Specifies the metallic scalar of the metallic/roughness workflow.
  48238. * Can also be used to scale the metalness values of the metallic texture.
  48239. */
  48240. protected _metallic: Nullable<number>;
  48241. /**
  48242. * Specifies the roughness scalar of the metallic/roughness workflow.
  48243. * Can also be used to scale the roughness values of the metallic texture.
  48244. */
  48245. protected _roughness: Nullable<number>;
  48246. /**
  48247. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48248. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48249. */
  48250. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48251. /**
  48252. * Stores surface normal data used to displace a mesh in a texture.
  48253. */
  48254. protected _bumpTexture: Nullable<BaseTexture>;
  48255. /**
  48256. * Stores the pre-calculated light information of a mesh in a texture.
  48257. */
  48258. protected _lightmapTexture: Nullable<BaseTexture>;
  48259. /**
  48260. * The color of a material in ambient lighting.
  48261. */
  48262. protected _ambientColor: Color3;
  48263. /**
  48264. * AKA Diffuse Color in other nomenclature.
  48265. */
  48266. protected _albedoColor: Color3;
  48267. /**
  48268. * AKA Specular Color in other nomenclature.
  48269. */
  48270. protected _reflectivityColor: Color3;
  48271. /**
  48272. * The color applied when light is reflected from a material.
  48273. */
  48274. protected _reflectionColor: Color3;
  48275. /**
  48276. * The color applied when light is emitted from a material.
  48277. */
  48278. protected _emissiveColor: Color3;
  48279. /**
  48280. * AKA Glossiness in other nomenclature.
  48281. */
  48282. protected _microSurface: number;
  48283. /**
  48284. * Specifies that the material will use the light map as a show map.
  48285. */
  48286. protected _useLightmapAsShadowmap: boolean;
  48287. /**
  48288. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48289. * makes the reflect vector face the model (under horizon).
  48290. */
  48291. protected _useHorizonOcclusion: boolean;
  48292. /**
  48293. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48294. * too much the area relying on ambient texture to define their ambient occlusion.
  48295. */
  48296. protected _useRadianceOcclusion: boolean;
  48297. /**
  48298. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48299. */
  48300. protected _useAlphaFromAlbedoTexture: boolean;
  48301. /**
  48302. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48303. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48304. */
  48305. protected _useSpecularOverAlpha: boolean;
  48306. /**
  48307. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48308. */
  48309. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48310. /**
  48311. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48312. */
  48313. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48314. /**
  48315. * Specifies if the metallic texture contains the roughness information in its green channel.
  48316. */
  48317. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48318. /**
  48319. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48320. */
  48321. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48322. /**
  48323. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48324. */
  48325. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48326. /**
  48327. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48328. */
  48329. protected _useAmbientInGrayScale: boolean;
  48330. /**
  48331. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48332. * The material will try to infer what glossiness each pixel should be.
  48333. */
  48334. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48335. /**
  48336. * Defines the falloff type used in this material.
  48337. * It by default is Physical.
  48338. */
  48339. protected _lightFalloff: number;
  48340. /**
  48341. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48342. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48343. */
  48344. protected _useRadianceOverAlpha: boolean;
  48345. /**
  48346. * Allows using an object space normal map (instead of tangent space).
  48347. */
  48348. protected _useObjectSpaceNormalMap: boolean;
  48349. /**
  48350. * Allows using the bump map in parallax mode.
  48351. */
  48352. protected _useParallax: boolean;
  48353. /**
  48354. * Allows using the bump map in parallax occlusion mode.
  48355. */
  48356. protected _useParallaxOcclusion: boolean;
  48357. /**
  48358. * Controls the scale bias of the parallax mode.
  48359. */
  48360. protected _parallaxScaleBias: number;
  48361. /**
  48362. * If sets to true, disables all the lights affecting the material.
  48363. */
  48364. protected _disableLighting: boolean;
  48365. /**
  48366. * Number of Simultaneous lights allowed on the material.
  48367. */
  48368. protected _maxSimultaneousLights: number;
  48369. /**
  48370. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48371. */
  48372. protected _invertNormalMapX: boolean;
  48373. /**
  48374. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48375. */
  48376. protected _invertNormalMapY: boolean;
  48377. /**
  48378. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48379. */
  48380. protected _twoSidedLighting: boolean;
  48381. /**
  48382. * Defines the alpha limits in alpha test mode.
  48383. */
  48384. protected _alphaCutOff: number;
  48385. /**
  48386. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48387. */
  48388. protected _forceAlphaTest: boolean;
  48389. /**
  48390. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48391. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48392. */
  48393. protected _useAlphaFresnel: boolean;
  48394. /**
  48395. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48396. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48397. */
  48398. protected _useLinearAlphaFresnel: boolean;
  48399. /**
  48400. * The transparency mode of the material.
  48401. */
  48402. protected _transparencyMode: Nullable<number>;
  48403. /**
  48404. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48405. * from cos thetav and roughness:
  48406. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48407. */
  48408. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48409. /**
  48410. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48411. */
  48412. protected _forceIrradianceInFragment: boolean;
  48413. /**
  48414. * Force normal to face away from face.
  48415. */
  48416. protected _forceNormalForward: boolean;
  48417. /**
  48418. * Enables specular anti aliasing in the PBR shader.
  48419. * It will both interacts on the Geometry for analytical and IBL lighting.
  48420. * It also prefilter the roughness map based on the bump values.
  48421. */
  48422. protected _enableSpecularAntiAliasing: boolean;
  48423. /**
  48424. * Default configuration related to image processing available in the PBR Material.
  48425. */
  48426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48427. /**
  48428. * Keep track of the image processing observer to allow dispose and replace.
  48429. */
  48430. private _imageProcessingObserver;
  48431. /**
  48432. * Attaches a new image processing configuration to the PBR Material.
  48433. * @param configuration
  48434. */
  48435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48436. /**
  48437. * Stores the available render targets.
  48438. */
  48439. private _renderTargets;
  48440. /**
  48441. * Sets the global ambient color for the material used in lighting calculations.
  48442. */
  48443. private _globalAmbientColor;
  48444. /**
  48445. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48446. */
  48447. private _useLogarithmicDepth;
  48448. /**
  48449. * If set to true, no lighting calculations will be applied.
  48450. */
  48451. private _unlit;
  48452. private _debugMode;
  48453. /**
  48454. * @hidden
  48455. * This is reserved for the inspector.
  48456. * Defines the material debug mode.
  48457. * It helps seeing only some components of the material while troubleshooting.
  48458. */
  48459. debugMode: number;
  48460. /**
  48461. * @hidden
  48462. * This is reserved for the inspector.
  48463. * Specify from where on screen the debug mode should start.
  48464. * The value goes from -1 (full screen) to 1 (not visible)
  48465. * It helps with side by side comparison against the final render
  48466. * This defaults to -1
  48467. */
  48468. private debugLimit;
  48469. /**
  48470. * @hidden
  48471. * This is reserved for the inspector.
  48472. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48473. * You can use the factor to better multiply the final value.
  48474. */
  48475. private debugFactor;
  48476. /**
  48477. * Defines the clear coat layer parameters for the material.
  48478. */
  48479. readonly clearCoat: PBRClearCoatConfiguration;
  48480. /**
  48481. * Defines the anisotropic parameters for the material.
  48482. */
  48483. readonly anisotropy: PBRAnisotropicConfiguration;
  48484. /**
  48485. * Defines the BRDF parameters for the material.
  48486. */
  48487. readonly brdf: PBRBRDFConfiguration;
  48488. /**
  48489. * Defines the Sheen parameters for the material.
  48490. */
  48491. readonly sheen: PBRSheenConfiguration;
  48492. /**
  48493. * Defines the SubSurface parameters for the material.
  48494. */
  48495. readonly subSurface: PBRSubSurfaceConfiguration;
  48496. /**
  48497. * Custom callback helping to override the default shader used in the material.
  48498. */
  48499. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48500. /**
  48501. * Instantiates a new PBRMaterial instance.
  48502. *
  48503. * @param name The material name
  48504. * @param scene The scene the material will be use in.
  48505. */
  48506. constructor(name: string, scene: Scene);
  48507. /**
  48508. * Gets a boolean indicating that current material needs to register RTT
  48509. */
  48510. readonly hasRenderTargetTextures: boolean;
  48511. /**
  48512. * Gets the name of the material class.
  48513. */
  48514. getClassName(): string;
  48515. /**
  48516. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48517. */
  48518. /**
  48519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48520. */
  48521. useLogarithmicDepth: boolean;
  48522. /**
  48523. * Gets the current transparency mode.
  48524. */
  48525. /**
  48526. * Sets the transparency mode of the material.
  48527. *
  48528. * | Value | Type | Description |
  48529. * | ----- | ----------------------------------- | ----------- |
  48530. * | 0 | OPAQUE | |
  48531. * | 1 | ALPHATEST | |
  48532. * | 2 | ALPHABLEND | |
  48533. * | 3 | ALPHATESTANDBLEND | |
  48534. *
  48535. */
  48536. transparencyMode: Nullable<number>;
  48537. /**
  48538. * Returns true if alpha blending should be disabled.
  48539. */
  48540. private readonly _disableAlphaBlending;
  48541. /**
  48542. * Specifies whether or not this material should be rendered in alpha blend mode.
  48543. */
  48544. needAlphaBlending(): boolean;
  48545. /**
  48546. * Specifies if the mesh will require alpha blending.
  48547. * @param mesh - BJS mesh.
  48548. */
  48549. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48550. /**
  48551. * Specifies whether or not this material should be rendered in alpha test mode.
  48552. */
  48553. needAlphaTesting(): boolean;
  48554. /**
  48555. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48556. */
  48557. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48558. /**
  48559. * Gets the texture used for the alpha test.
  48560. */
  48561. getAlphaTestTexture(): Nullable<BaseTexture>;
  48562. /**
  48563. * Specifies that the submesh is ready to be used.
  48564. * @param mesh - BJS mesh.
  48565. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48566. * @param useInstances - Specifies that instances should be used.
  48567. * @returns - boolean indicating that the submesh is ready or not.
  48568. */
  48569. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48570. /**
  48571. * Specifies if the material uses metallic roughness workflow.
  48572. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48573. */
  48574. isMetallicWorkflow(): boolean;
  48575. private _prepareEffect;
  48576. private _prepareDefines;
  48577. /**
  48578. * Force shader compilation
  48579. */
  48580. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48581. clipPlane: boolean;
  48582. }>): void;
  48583. /**
  48584. * Initializes the uniform buffer layout for the shader.
  48585. */
  48586. buildUniformLayout(): void;
  48587. /**
  48588. * Unbinds the material from the mesh
  48589. */
  48590. unbind(): void;
  48591. /**
  48592. * Binds the submesh data.
  48593. * @param world - The world matrix.
  48594. * @param mesh - The BJS mesh.
  48595. * @param subMesh - A submesh of the BJS mesh.
  48596. */
  48597. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48598. /**
  48599. * Returns the animatable textures.
  48600. * @returns - Array of animatable textures.
  48601. */
  48602. getAnimatables(): IAnimatable[];
  48603. /**
  48604. * Returns the texture used for reflections.
  48605. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48606. */
  48607. private _getReflectionTexture;
  48608. /**
  48609. * Returns an array of the actively used textures.
  48610. * @returns - Array of BaseTextures
  48611. */
  48612. getActiveTextures(): BaseTexture[];
  48613. /**
  48614. * Checks to see if a texture is used in the material.
  48615. * @param texture - Base texture to use.
  48616. * @returns - Boolean specifying if a texture is used in the material.
  48617. */
  48618. hasTexture(texture: BaseTexture): boolean;
  48619. /**
  48620. * Disposes the resources of the material.
  48621. * @param forceDisposeEffect - Forces the disposal of effects.
  48622. * @param forceDisposeTextures - Forces the disposal of all textures.
  48623. */
  48624. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48625. }
  48626. }
  48627. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48628. import { Nullable } from "babylonjs/types";
  48629. import { Scene } from "babylonjs/scene";
  48630. import { Color3 } from "babylonjs/Maths/math.color";
  48631. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48632. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48633. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48634. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48635. /**
  48636. * The Physically based material of BJS.
  48637. *
  48638. * This offers the main features of a standard PBR material.
  48639. * For more information, please refer to the documentation :
  48640. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48641. */
  48642. export class PBRMaterial extends PBRBaseMaterial {
  48643. /**
  48644. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48645. */
  48646. static readonly PBRMATERIAL_OPAQUE: number;
  48647. /**
  48648. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48649. */
  48650. static readonly PBRMATERIAL_ALPHATEST: number;
  48651. /**
  48652. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48653. */
  48654. static readonly PBRMATERIAL_ALPHABLEND: number;
  48655. /**
  48656. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48657. * They are also discarded below the alpha cutoff threshold to improve performances.
  48658. */
  48659. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48660. /**
  48661. * Defines the default value of how much AO map is occluding the analytical lights
  48662. * (point spot...).
  48663. */
  48664. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48665. /**
  48666. * Intensity of the direct lights e.g. the four lights available in your scene.
  48667. * This impacts both the direct diffuse and specular highlights.
  48668. */
  48669. directIntensity: number;
  48670. /**
  48671. * Intensity of the emissive part of the material.
  48672. * This helps controlling the emissive effect without modifying the emissive color.
  48673. */
  48674. emissiveIntensity: number;
  48675. /**
  48676. * Intensity of the environment e.g. how much the environment will light the object
  48677. * either through harmonics for rough material or through the refelction for shiny ones.
  48678. */
  48679. environmentIntensity: number;
  48680. /**
  48681. * This is a special control allowing the reduction of the specular highlights coming from the
  48682. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48683. */
  48684. specularIntensity: number;
  48685. /**
  48686. * Debug Control allowing disabling the bump map on this material.
  48687. */
  48688. disableBumpMap: boolean;
  48689. /**
  48690. * AKA Diffuse Texture in standard nomenclature.
  48691. */
  48692. albedoTexture: BaseTexture;
  48693. /**
  48694. * AKA Occlusion Texture in other nomenclature.
  48695. */
  48696. ambientTexture: BaseTexture;
  48697. /**
  48698. * AKA Occlusion Texture Intensity in other nomenclature.
  48699. */
  48700. ambientTextureStrength: number;
  48701. /**
  48702. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48703. * 1 means it completely occludes it
  48704. * 0 mean it has no impact
  48705. */
  48706. ambientTextureImpactOnAnalyticalLights: number;
  48707. /**
  48708. * Stores the alpha values in a texture.
  48709. */
  48710. opacityTexture: BaseTexture;
  48711. /**
  48712. * Stores the reflection values in a texture.
  48713. */
  48714. reflectionTexture: Nullable<BaseTexture>;
  48715. /**
  48716. * Stores the emissive values in a texture.
  48717. */
  48718. emissiveTexture: BaseTexture;
  48719. /**
  48720. * AKA Specular texture in other nomenclature.
  48721. */
  48722. reflectivityTexture: BaseTexture;
  48723. /**
  48724. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48725. */
  48726. metallicTexture: BaseTexture;
  48727. /**
  48728. * Specifies the metallic scalar of the metallic/roughness workflow.
  48729. * Can also be used to scale the metalness values of the metallic texture.
  48730. */
  48731. metallic: Nullable<number>;
  48732. /**
  48733. * Specifies the roughness scalar of the metallic/roughness workflow.
  48734. * Can also be used to scale the roughness values of the metallic texture.
  48735. */
  48736. roughness: Nullable<number>;
  48737. /**
  48738. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48739. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48740. */
  48741. microSurfaceTexture: BaseTexture;
  48742. /**
  48743. * Stores surface normal data used to displace a mesh in a texture.
  48744. */
  48745. bumpTexture: BaseTexture;
  48746. /**
  48747. * Stores the pre-calculated light information of a mesh in a texture.
  48748. */
  48749. lightmapTexture: BaseTexture;
  48750. /**
  48751. * Stores the refracted light information in a texture.
  48752. */
  48753. refractionTexture: Nullable<BaseTexture>;
  48754. /**
  48755. * The color of a material in ambient lighting.
  48756. */
  48757. ambientColor: Color3;
  48758. /**
  48759. * AKA Diffuse Color in other nomenclature.
  48760. */
  48761. albedoColor: Color3;
  48762. /**
  48763. * AKA Specular Color in other nomenclature.
  48764. */
  48765. reflectivityColor: Color3;
  48766. /**
  48767. * The color reflected from the material.
  48768. */
  48769. reflectionColor: Color3;
  48770. /**
  48771. * The color emitted from the material.
  48772. */
  48773. emissiveColor: Color3;
  48774. /**
  48775. * AKA Glossiness in other nomenclature.
  48776. */
  48777. microSurface: number;
  48778. /**
  48779. * source material index of refraction (IOR)' / 'destination material IOR.
  48780. */
  48781. indexOfRefraction: number;
  48782. /**
  48783. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48784. */
  48785. invertRefractionY: boolean;
  48786. /**
  48787. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48788. * Materials half opaque for instance using refraction could benefit from this control.
  48789. */
  48790. linkRefractionWithTransparency: boolean;
  48791. /**
  48792. * If true, the light map contains occlusion information instead of lighting info.
  48793. */
  48794. useLightmapAsShadowmap: boolean;
  48795. /**
  48796. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48797. */
  48798. useAlphaFromAlbedoTexture: boolean;
  48799. /**
  48800. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48801. */
  48802. forceAlphaTest: boolean;
  48803. /**
  48804. * Defines the alpha limits in alpha test mode.
  48805. */
  48806. alphaCutOff: number;
  48807. /**
  48808. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48810. */
  48811. useSpecularOverAlpha: boolean;
  48812. /**
  48813. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48814. */
  48815. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48816. /**
  48817. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48818. */
  48819. useRoughnessFromMetallicTextureAlpha: boolean;
  48820. /**
  48821. * Specifies if the metallic texture contains the roughness information in its green channel.
  48822. */
  48823. useRoughnessFromMetallicTextureGreen: boolean;
  48824. /**
  48825. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48826. */
  48827. useMetallnessFromMetallicTextureBlue: boolean;
  48828. /**
  48829. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48830. */
  48831. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48832. /**
  48833. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48834. */
  48835. useAmbientInGrayScale: boolean;
  48836. /**
  48837. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48838. * The material will try to infer what glossiness each pixel should be.
  48839. */
  48840. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48841. /**
  48842. * BJS is using an harcoded light falloff based on a manually sets up range.
  48843. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48844. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48845. */
  48846. /**
  48847. * BJS is using an harcoded light falloff based on a manually sets up range.
  48848. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48849. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48850. */
  48851. usePhysicalLightFalloff: boolean;
  48852. /**
  48853. * In order to support the falloff compatibility with gltf, a special mode has been added
  48854. * to reproduce the gltf light falloff.
  48855. */
  48856. /**
  48857. * In order to support the falloff compatibility with gltf, a special mode has been added
  48858. * to reproduce the gltf light falloff.
  48859. */
  48860. useGLTFLightFalloff: boolean;
  48861. /**
  48862. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48863. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48864. */
  48865. useRadianceOverAlpha: boolean;
  48866. /**
  48867. * Allows using an object space normal map (instead of tangent space).
  48868. */
  48869. useObjectSpaceNormalMap: boolean;
  48870. /**
  48871. * Allows using the bump map in parallax mode.
  48872. */
  48873. useParallax: boolean;
  48874. /**
  48875. * Allows using the bump map in parallax occlusion mode.
  48876. */
  48877. useParallaxOcclusion: boolean;
  48878. /**
  48879. * Controls the scale bias of the parallax mode.
  48880. */
  48881. parallaxScaleBias: number;
  48882. /**
  48883. * If sets to true, disables all the lights affecting the material.
  48884. */
  48885. disableLighting: boolean;
  48886. /**
  48887. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48888. */
  48889. forceIrradianceInFragment: boolean;
  48890. /**
  48891. * Number of Simultaneous lights allowed on the material.
  48892. */
  48893. maxSimultaneousLights: number;
  48894. /**
  48895. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48896. */
  48897. invertNormalMapX: boolean;
  48898. /**
  48899. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48900. */
  48901. invertNormalMapY: boolean;
  48902. /**
  48903. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48904. */
  48905. twoSidedLighting: boolean;
  48906. /**
  48907. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48908. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48909. */
  48910. useAlphaFresnel: boolean;
  48911. /**
  48912. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48913. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48914. */
  48915. useLinearAlphaFresnel: boolean;
  48916. /**
  48917. * Let user defines the brdf lookup texture used for IBL.
  48918. * A default 8bit version is embedded but you could point at :
  48919. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48920. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48921. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48922. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48923. */
  48924. environmentBRDFTexture: Nullable<BaseTexture>;
  48925. /**
  48926. * Force normal to face away from face.
  48927. */
  48928. forceNormalForward: boolean;
  48929. /**
  48930. * Enables specular anti aliasing in the PBR shader.
  48931. * It will both interacts on the Geometry for analytical and IBL lighting.
  48932. * It also prefilter the roughness map based on the bump values.
  48933. */
  48934. enableSpecularAntiAliasing: boolean;
  48935. /**
  48936. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48937. * makes the reflect vector face the model (under horizon).
  48938. */
  48939. useHorizonOcclusion: boolean;
  48940. /**
  48941. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48942. * too much the area relying on ambient texture to define their ambient occlusion.
  48943. */
  48944. useRadianceOcclusion: boolean;
  48945. /**
  48946. * If set to true, no lighting calculations will be applied.
  48947. */
  48948. unlit: boolean;
  48949. /**
  48950. * Gets the image processing configuration used either in this material.
  48951. */
  48952. /**
  48953. * Sets the Default image processing configuration used either in the this material.
  48954. *
  48955. * If sets to null, the scene one is in use.
  48956. */
  48957. imageProcessingConfiguration: ImageProcessingConfiguration;
  48958. /**
  48959. * Gets wether the color curves effect is enabled.
  48960. */
  48961. /**
  48962. * Sets wether the color curves effect is enabled.
  48963. */
  48964. cameraColorCurvesEnabled: boolean;
  48965. /**
  48966. * Gets wether the color grading effect is enabled.
  48967. */
  48968. /**
  48969. * Gets wether the color grading effect is enabled.
  48970. */
  48971. cameraColorGradingEnabled: boolean;
  48972. /**
  48973. * Gets wether tonemapping is enabled or not.
  48974. */
  48975. /**
  48976. * Sets wether tonemapping is enabled or not
  48977. */
  48978. cameraToneMappingEnabled: boolean;
  48979. /**
  48980. * The camera exposure used on this material.
  48981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48982. * This corresponds to a photographic exposure.
  48983. */
  48984. /**
  48985. * The camera exposure used on this material.
  48986. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48987. * This corresponds to a photographic exposure.
  48988. */
  48989. cameraExposure: number;
  48990. /**
  48991. * Gets The camera contrast used on this material.
  48992. */
  48993. /**
  48994. * Sets The camera contrast used on this material.
  48995. */
  48996. cameraContrast: number;
  48997. /**
  48998. * Gets the Color Grading 2D Lookup Texture.
  48999. */
  49000. /**
  49001. * Sets the Color Grading 2D Lookup Texture.
  49002. */
  49003. cameraColorGradingTexture: Nullable<BaseTexture>;
  49004. /**
  49005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49007. * 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;
  49008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49009. */
  49010. /**
  49011. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49012. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49013. * 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;
  49014. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49015. */
  49016. cameraColorCurves: Nullable<ColorCurves>;
  49017. /**
  49018. * Instantiates a new PBRMaterial instance.
  49019. *
  49020. * @param name The material name
  49021. * @param scene The scene the material will be use in.
  49022. */
  49023. constructor(name: string, scene: Scene);
  49024. /**
  49025. * Returns the name of this material class.
  49026. */
  49027. getClassName(): string;
  49028. /**
  49029. * Makes a duplicate of the current material.
  49030. * @param name - name to use for the new material.
  49031. */
  49032. clone(name: string): PBRMaterial;
  49033. /**
  49034. * Serializes this PBR Material.
  49035. * @returns - An object with the serialized material.
  49036. */
  49037. serialize(): any;
  49038. /**
  49039. * Parses a PBR Material from a serialized object.
  49040. * @param source - Serialized object.
  49041. * @param scene - BJS scene instance.
  49042. * @param rootUrl - url for the scene object
  49043. * @returns - PBRMaterial
  49044. */
  49045. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49046. }
  49047. }
  49048. declare module "babylonjs/Misc/dds" {
  49049. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49050. import { Engine } from "babylonjs/Engines/engine";
  49051. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49052. import { Nullable } from "babylonjs/types";
  49053. import { Scene } from "babylonjs/scene";
  49054. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49055. /**
  49056. * Direct draw surface info
  49057. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49058. */
  49059. export interface DDSInfo {
  49060. /**
  49061. * Width of the texture
  49062. */
  49063. width: number;
  49064. /**
  49065. * Width of the texture
  49066. */
  49067. height: number;
  49068. /**
  49069. * Number of Mipmaps for the texture
  49070. * @see https://en.wikipedia.org/wiki/Mipmap
  49071. */
  49072. mipmapCount: number;
  49073. /**
  49074. * If the textures format is a known fourCC format
  49075. * @see https://www.fourcc.org/
  49076. */
  49077. isFourCC: boolean;
  49078. /**
  49079. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49080. */
  49081. isRGB: boolean;
  49082. /**
  49083. * If the texture is a lumincance format
  49084. */
  49085. isLuminance: boolean;
  49086. /**
  49087. * If this is a cube texture
  49088. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49089. */
  49090. isCube: boolean;
  49091. /**
  49092. * If the texture is a compressed format eg. FOURCC_DXT1
  49093. */
  49094. isCompressed: boolean;
  49095. /**
  49096. * The dxgiFormat of the texture
  49097. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49098. */
  49099. dxgiFormat: number;
  49100. /**
  49101. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49102. */
  49103. textureType: number;
  49104. /**
  49105. * Sphericle polynomial created for the dds texture
  49106. */
  49107. sphericalPolynomial?: SphericalPolynomial;
  49108. }
  49109. /**
  49110. * Class used to provide DDS decompression tools
  49111. */
  49112. export class DDSTools {
  49113. /**
  49114. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49115. */
  49116. static StoreLODInAlphaChannel: boolean;
  49117. /**
  49118. * Gets DDS information from an array buffer
  49119. * @param arrayBuffer defines the array buffer to read data from
  49120. * @returns the DDS information
  49121. */
  49122. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49123. private static _FloatView;
  49124. private static _Int32View;
  49125. private static _ToHalfFloat;
  49126. private static _FromHalfFloat;
  49127. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49128. private static _GetHalfFloatRGBAArrayBuffer;
  49129. private static _GetFloatRGBAArrayBuffer;
  49130. private static _GetFloatAsUIntRGBAArrayBuffer;
  49131. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49132. private static _GetRGBAArrayBuffer;
  49133. private static _ExtractLongWordOrder;
  49134. private static _GetRGBArrayBuffer;
  49135. private static _GetLuminanceArrayBuffer;
  49136. /**
  49137. * Uploads DDS Levels to a Babylon Texture
  49138. * @hidden
  49139. */
  49140. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49141. }
  49142. module "babylonjs/Engines/engine" {
  49143. interface Engine {
  49144. /**
  49145. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49146. * @param rootUrl defines the url where the file to load is located
  49147. * @param scene defines the current scene
  49148. * @param lodScale defines scale to apply to the mip map selection
  49149. * @param lodOffset defines offset to apply to the mip map selection
  49150. * @param onLoad defines an optional callback raised when the texture is loaded
  49151. * @param onError defines an optional callback raised if there is an issue to load the texture
  49152. * @param format defines the format of the data
  49153. * @param forcedExtension defines the extension to use to pick the right loader
  49154. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49155. * @returns the cube texture as an InternalTexture
  49156. */
  49157. 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;
  49158. }
  49159. }
  49160. }
  49161. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49162. import { Nullable } from "babylonjs/types";
  49163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49164. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49165. /**
  49166. * Implementation of the DDS Texture Loader.
  49167. * @hidden
  49168. */
  49169. export class _DDSTextureLoader implements IInternalTextureLoader {
  49170. /**
  49171. * Defines wether the loader supports cascade loading the different faces.
  49172. */
  49173. readonly supportCascades: boolean;
  49174. /**
  49175. * This returns if the loader support the current file information.
  49176. * @param extension defines the file extension of the file being loaded
  49177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49178. * @param fallback defines the fallback internal texture if any
  49179. * @param isBase64 defines whether the texture is encoded as a base64
  49180. * @param isBuffer defines whether the texture data are stored as a buffer
  49181. * @returns true if the loader can load the specified file
  49182. */
  49183. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49184. /**
  49185. * Transform the url before loading if required.
  49186. * @param rootUrl the url of the texture
  49187. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49188. * @returns the transformed texture
  49189. */
  49190. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49191. /**
  49192. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49193. * @param rootUrl the url of the texture
  49194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49195. * @returns the fallback texture
  49196. */
  49197. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49198. /**
  49199. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49200. * @param data contains the texture data
  49201. * @param texture defines the BabylonJS internal texture
  49202. * @param createPolynomials will be true if polynomials have been requested
  49203. * @param onLoad defines the callback to trigger once the texture is ready
  49204. * @param onError defines the callback to trigger in case of error
  49205. */
  49206. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49207. /**
  49208. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49209. * @param data contains the texture data
  49210. * @param texture defines the BabylonJS internal texture
  49211. * @param callback defines the method to call once ready to upload
  49212. */
  49213. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49214. }
  49215. }
  49216. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49217. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49218. /** @hidden */
  49219. export var rgbdEncodePixelShader: {
  49220. name: string;
  49221. shader: string;
  49222. };
  49223. }
  49224. declare module "babylonjs/Misc/environmentTextureTools" {
  49225. import { Nullable } from "babylonjs/types";
  49226. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49227. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49228. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49229. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49230. import "babylonjs/Shaders/rgbdEncode.fragment";
  49231. import "babylonjs/Shaders/rgbdDecode.fragment";
  49232. /**
  49233. * Raw texture data and descriptor sufficient for WebGL texture upload
  49234. */
  49235. export interface EnvironmentTextureInfo {
  49236. /**
  49237. * Version of the environment map
  49238. */
  49239. version: number;
  49240. /**
  49241. * Width of image
  49242. */
  49243. width: number;
  49244. /**
  49245. * Irradiance information stored in the file.
  49246. */
  49247. irradiance: any;
  49248. /**
  49249. * Specular information stored in the file.
  49250. */
  49251. specular: any;
  49252. }
  49253. /**
  49254. * Sets of helpers addressing the serialization and deserialization of environment texture
  49255. * stored in a BabylonJS env file.
  49256. * Those files are usually stored as .env files.
  49257. */
  49258. export class EnvironmentTextureTools {
  49259. /**
  49260. * Magic number identifying the env file.
  49261. */
  49262. private static _MagicBytes;
  49263. /**
  49264. * Gets the environment info from an env file.
  49265. * @param data The array buffer containing the .env bytes.
  49266. * @returns the environment file info (the json header) if successfully parsed.
  49267. */
  49268. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49269. /**
  49270. * Creates an environment texture from a loaded cube texture.
  49271. * @param texture defines the cube texture to convert in env file
  49272. * @return a promise containing the environment data if succesfull.
  49273. */
  49274. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49275. /**
  49276. * Creates a JSON representation of the spherical data.
  49277. * @param texture defines the texture containing the polynomials
  49278. * @return the JSON representation of the spherical info
  49279. */
  49280. private static _CreateEnvTextureIrradiance;
  49281. /**
  49282. * Uploads the texture info contained in the env file to the GPU.
  49283. * @param texture defines the internal texture to upload to
  49284. * @param arrayBuffer defines the buffer cotaining the data to load
  49285. * @param info defines the texture info retrieved through the GetEnvInfo method
  49286. * @returns a promise
  49287. */
  49288. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49289. /**
  49290. * Uploads the levels of image data to the GPU.
  49291. * @param texture defines the internal texture to upload to
  49292. * @param imageData defines the array buffer views of image data [mipmap][face]
  49293. * @returns a promise
  49294. */
  49295. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49296. /**
  49297. * Uploads spherical polynomials information to the texture.
  49298. * @param texture defines the texture we are trying to upload the information to
  49299. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49300. */
  49301. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49302. /** @hidden */
  49303. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49304. }
  49305. }
  49306. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49307. import { Nullable } from "babylonjs/types";
  49308. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49309. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49310. /**
  49311. * Implementation of the ENV Texture Loader.
  49312. * @hidden
  49313. */
  49314. export class _ENVTextureLoader implements IInternalTextureLoader {
  49315. /**
  49316. * Defines wether the loader supports cascade loading the different faces.
  49317. */
  49318. readonly supportCascades: boolean;
  49319. /**
  49320. * This returns if the loader support the current file information.
  49321. * @param extension defines the file extension of the file being loaded
  49322. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49323. * @param fallback defines the fallback internal texture if any
  49324. * @param isBase64 defines whether the texture is encoded as a base64
  49325. * @param isBuffer defines whether the texture data are stored as a buffer
  49326. * @returns true if the loader can load the specified file
  49327. */
  49328. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49329. /**
  49330. * Transform the url before loading if required.
  49331. * @param rootUrl the url of the texture
  49332. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49333. * @returns the transformed texture
  49334. */
  49335. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49336. /**
  49337. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49338. * @param rootUrl the url of the texture
  49339. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49340. * @returns the fallback texture
  49341. */
  49342. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49343. /**
  49344. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49345. * @param data contains the texture data
  49346. * @param texture defines the BabylonJS internal texture
  49347. * @param createPolynomials will be true if polynomials have been requested
  49348. * @param onLoad defines the callback to trigger once the texture is ready
  49349. * @param onError defines the callback to trigger in case of error
  49350. */
  49351. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49352. /**
  49353. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49354. * @param data contains the texture data
  49355. * @param texture defines the BabylonJS internal texture
  49356. * @param callback defines the method to call once ready to upload
  49357. */
  49358. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49359. }
  49360. }
  49361. declare module "babylonjs/Misc/khronosTextureContainer" {
  49362. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49363. /**
  49364. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49365. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49366. */
  49367. export class KhronosTextureContainer {
  49368. /** contents of the KTX container file */
  49369. arrayBuffer: any;
  49370. private static HEADER_LEN;
  49371. private static COMPRESSED_2D;
  49372. private static COMPRESSED_3D;
  49373. private static TEX_2D;
  49374. private static TEX_3D;
  49375. /**
  49376. * Gets the openGL type
  49377. */
  49378. glType: number;
  49379. /**
  49380. * Gets the openGL type size
  49381. */
  49382. glTypeSize: number;
  49383. /**
  49384. * Gets the openGL format
  49385. */
  49386. glFormat: number;
  49387. /**
  49388. * Gets the openGL internal format
  49389. */
  49390. glInternalFormat: number;
  49391. /**
  49392. * Gets the base internal format
  49393. */
  49394. glBaseInternalFormat: number;
  49395. /**
  49396. * Gets image width in pixel
  49397. */
  49398. pixelWidth: number;
  49399. /**
  49400. * Gets image height in pixel
  49401. */
  49402. pixelHeight: number;
  49403. /**
  49404. * Gets image depth in pixels
  49405. */
  49406. pixelDepth: number;
  49407. /**
  49408. * Gets the number of array elements
  49409. */
  49410. numberOfArrayElements: number;
  49411. /**
  49412. * Gets the number of faces
  49413. */
  49414. numberOfFaces: number;
  49415. /**
  49416. * Gets the number of mipmap levels
  49417. */
  49418. numberOfMipmapLevels: number;
  49419. /**
  49420. * Gets the bytes of key value data
  49421. */
  49422. bytesOfKeyValueData: number;
  49423. /**
  49424. * Gets the load type
  49425. */
  49426. loadType: number;
  49427. /**
  49428. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49429. */
  49430. isInvalid: boolean;
  49431. /**
  49432. * Creates a new KhronosTextureContainer
  49433. * @param arrayBuffer contents of the KTX container file
  49434. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49435. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49436. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49437. */
  49438. constructor(
  49439. /** contents of the KTX container file */
  49440. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49441. /**
  49442. * Uploads KTX content to a Babylon Texture.
  49443. * It is assumed that the texture has already been created & is currently bound
  49444. * @hidden
  49445. */
  49446. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49447. private _upload2DCompressedLevels;
  49448. }
  49449. }
  49450. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49451. import { Nullable } from "babylonjs/types";
  49452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49454. /**
  49455. * Implementation of the KTX Texture Loader.
  49456. * @hidden
  49457. */
  49458. export class _KTXTextureLoader implements IInternalTextureLoader {
  49459. /**
  49460. * Defines wether the loader supports cascade loading the different faces.
  49461. */
  49462. readonly supportCascades: boolean;
  49463. /**
  49464. * This returns if the loader support the current file information.
  49465. * @param extension defines the file extension of the file being loaded
  49466. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49467. * @param fallback defines the fallback internal texture if any
  49468. * @param isBase64 defines whether the texture is encoded as a base64
  49469. * @param isBuffer defines whether the texture data are stored as a buffer
  49470. * @returns true if the loader can load the specified file
  49471. */
  49472. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49473. /**
  49474. * Transform the url before loading if required.
  49475. * @param rootUrl the url of the texture
  49476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49477. * @returns the transformed texture
  49478. */
  49479. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49480. /**
  49481. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49482. * @param rootUrl the url of the texture
  49483. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49484. * @returns the fallback texture
  49485. */
  49486. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49487. /**
  49488. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49489. * @param data contains the texture data
  49490. * @param texture defines the BabylonJS internal texture
  49491. * @param createPolynomials will be true if polynomials have been requested
  49492. * @param onLoad defines the callback to trigger once the texture is ready
  49493. * @param onError defines the callback to trigger in case of error
  49494. */
  49495. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49496. /**
  49497. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49498. * @param data contains the texture data
  49499. * @param texture defines the BabylonJS internal texture
  49500. * @param callback defines the method to call once ready to upload
  49501. */
  49502. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49503. }
  49504. }
  49505. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49506. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49507. import { Scene } from "babylonjs/scene";
  49508. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49509. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49510. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49511. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49512. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49513. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49515. /**
  49516. * Options for the default xr helper
  49517. */
  49518. export class WebXRDefaultExperienceOptions {
  49519. /**
  49520. * Floor meshes that should be used for teleporting
  49521. */
  49522. floorMeshes: Array<AbstractMesh>;
  49523. }
  49524. /**
  49525. * Default experience which provides a similar setup to the previous webVRExperience
  49526. */
  49527. export class WebXRDefaultExperience {
  49528. /**
  49529. * Base experience
  49530. */
  49531. baseExperience: WebXRExperienceHelper;
  49532. /**
  49533. * Input experience extension
  49534. */
  49535. input: WebXRInput;
  49536. /**
  49537. * Loads the controller models
  49538. */
  49539. controllerModelLoader: WebXRControllerModelLoader;
  49540. /**
  49541. * Enables laser pointer and selection
  49542. */
  49543. pointerSelection: WebXRControllerPointerSelection;
  49544. /**
  49545. * Enables teleportation
  49546. */
  49547. teleportation: WebXRControllerTeleportation;
  49548. /**
  49549. * Enables ui for enetering/exiting xr
  49550. */
  49551. enterExitUI: WebXREnterExitUI;
  49552. /**
  49553. * Default output canvas xr should render to
  49554. */
  49555. outputCanvas: WebXRManagedOutputCanvas;
  49556. /**
  49557. * Creates the default xr experience
  49558. * @param scene scene
  49559. * @param options options for basic configuration
  49560. * @returns resulting WebXRDefaultExperience
  49561. */
  49562. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49563. private constructor();
  49564. /**
  49565. * DIsposes of the experience helper
  49566. */
  49567. dispose(): void;
  49568. }
  49569. }
  49570. declare module "babylonjs/Helpers/sceneHelpers" {
  49571. import { Nullable } from "babylonjs/types";
  49572. import { Mesh } from "babylonjs/Meshes/mesh";
  49573. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49574. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49575. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49576. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49577. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49578. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49579. import "babylonjs/Meshes/Builders/boxBuilder";
  49580. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49581. /** @hidden */
  49582. export var _forceSceneHelpersToBundle: boolean;
  49583. module "babylonjs/scene" {
  49584. interface Scene {
  49585. /**
  49586. * Creates a default light for the scene.
  49587. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49588. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49589. */
  49590. createDefaultLight(replace?: boolean): void;
  49591. /**
  49592. * Creates a default camera for the scene.
  49593. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49594. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49595. * @param replace has default false, when true replaces the active camera in the scene
  49596. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49597. */
  49598. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49599. /**
  49600. * Creates a default camera and a default light.
  49601. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49602. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49603. * @param replace has the default false, when true replaces the active camera/light in the scene
  49604. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49605. */
  49606. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49607. /**
  49608. * Creates a new sky box
  49609. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49610. * @param environmentTexture defines the texture to use as environment texture
  49611. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49612. * @param scale defines the overall scale of the skybox
  49613. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49614. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49615. * @returns a new mesh holding the sky box
  49616. */
  49617. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49618. /**
  49619. * Creates a new environment
  49620. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49621. * @param options defines the options you can use to configure the environment
  49622. * @returns the new EnvironmentHelper
  49623. */
  49624. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49625. /**
  49626. * Creates a new VREXperienceHelper
  49627. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49628. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49629. * @returns a new VREXperienceHelper
  49630. */
  49631. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49632. /**
  49633. * Creates a new WebXRDefaultExperience
  49634. * @see http://doc.babylonjs.com/how_to/webxr
  49635. * @param options experience options
  49636. * @returns a promise for a new WebXRDefaultExperience
  49637. */
  49638. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49639. }
  49640. }
  49641. }
  49642. declare module "babylonjs/Helpers/videoDome" {
  49643. import { Scene } from "babylonjs/scene";
  49644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49645. import { Mesh } from "babylonjs/Meshes/mesh";
  49646. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49647. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49648. import "babylonjs/Meshes/Builders/sphereBuilder";
  49649. /**
  49650. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49651. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49652. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49653. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49654. */
  49655. export class VideoDome extends TransformNode {
  49656. /**
  49657. * Define the video source as a Monoscopic panoramic 360 video.
  49658. */
  49659. static readonly MODE_MONOSCOPIC: number;
  49660. /**
  49661. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49662. */
  49663. static readonly MODE_TOPBOTTOM: number;
  49664. /**
  49665. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49666. */
  49667. static readonly MODE_SIDEBYSIDE: number;
  49668. private _useDirectMapping;
  49669. /**
  49670. * The video texture being displayed on the sphere
  49671. */
  49672. protected _videoTexture: VideoTexture;
  49673. /**
  49674. * Gets the video texture being displayed on the sphere
  49675. */
  49676. readonly videoTexture: VideoTexture;
  49677. /**
  49678. * The skybox material
  49679. */
  49680. protected _material: BackgroundMaterial;
  49681. /**
  49682. * The surface used for the skybox
  49683. */
  49684. protected _mesh: Mesh;
  49685. /**
  49686. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49687. * Also see the options.resolution property.
  49688. */
  49689. fovMultiplier: number;
  49690. private _videoMode;
  49691. /**
  49692. * Gets or set the current video mode for the video. It can be:
  49693. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49694. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49695. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49696. */
  49697. videoMode: number;
  49698. /**
  49699. * Oberserver used in Stereoscopic VR Mode.
  49700. */
  49701. private _onBeforeCameraRenderObserver;
  49702. /**
  49703. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49704. * @param name Element's name, child elements will append suffixes for their own names.
  49705. * @param urlsOrVideo defines the url(s) or the video element to use
  49706. * @param options An object containing optional or exposed sub element properties
  49707. */
  49708. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49709. resolution?: number;
  49710. clickToPlay?: boolean;
  49711. autoPlay?: boolean;
  49712. loop?: boolean;
  49713. size?: number;
  49714. poster?: string;
  49715. faceForward?: boolean;
  49716. useDirectMapping?: boolean;
  49717. }, scene: Scene);
  49718. private _changeVideoMode;
  49719. /**
  49720. * Releases resources associated with this node.
  49721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49723. */
  49724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49725. }
  49726. }
  49727. declare module "babylonjs/Helpers/index" {
  49728. export * from "babylonjs/Helpers/environmentHelper";
  49729. export * from "babylonjs/Helpers/photoDome";
  49730. export * from "babylonjs/Helpers/sceneHelpers";
  49731. export * from "babylonjs/Helpers/videoDome";
  49732. }
  49733. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49734. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49735. import { IDisposable } from "babylonjs/scene";
  49736. import { Engine } from "babylonjs/Engines/engine";
  49737. /**
  49738. * This class can be used to get instrumentation data from a Babylon engine
  49739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49740. */
  49741. export class EngineInstrumentation implements IDisposable {
  49742. /**
  49743. * Define the instrumented engine.
  49744. */
  49745. engine: Engine;
  49746. private _captureGPUFrameTime;
  49747. private _gpuFrameTimeToken;
  49748. private _gpuFrameTime;
  49749. private _captureShaderCompilationTime;
  49750. private _shaderCompilationTime;
  49751. private _onBeginFrameObserver;
  49752. private _onEndFrameObserver;
  49753. private _onBeforeShaderCompilationObserver;
  49754. private _onAfterShaderCompilationObserver;
  49755. /**
  49756. * Gets the perf counter used for GPU frame time
  49757. */
  49758. readonly gpuFrameTimeCounter: PerfCounter;
  49759. /**
  49760. * Gets the GPU frame time capture status
  49761. */
  49762. /**
  49763. * Enable or disable the GPU frame time capture
  49764. */
  49765. captureGPUFrameTime: boolean;
  49766. /**
  49767. * Gets the perf counter used for shader compilation time
  49768. */
  49769. readonly shaderCompilationTimeCounter: PerfCounter;
  49770. /**
  49771. * Gets the shader compilation time capture status
  49772. */
  49773. /**
  49774. * Enable or disable the shader compilation time capture
  49775. */
  49776. captureShaderCompilationTime: boolean;
  49777. /**
  49778. * Instantiates a new engine instrumentation.
  49779. * This class can be used to get instrumentation data from a Babylon engine
  49780. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49781. * @param engine Defines the engine to instrument
  49782. */
  49783. constructor(
  49784. /**
  49785. * Define the instrumented engine.
  49786. */
  49787. engine: Engine);
  49788. /**
  49789. * Dispose and release associated resources.
  49790. */
  49791. dispose(): void;
  49792. }
  49793. }
  49794. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49795. import { Scene, IDisposable } from "babylonjs/scene";
  49796. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49797. /**
  49798. * This class can be used to get instrumentation data from a Babylon engine
  49799. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49800. */
  49801. export class SceneInstrumentation implements IDisposable {
  49802. /**
  49803. * Defines the scene to instrument
  49804. */
  49805. scene: Scene;
  49806. private _captureActiveMeshesEvaluationTime;
  49807. private _activeMeshesEvaluationTime;
  49808. private _captureRenderTargetsRenderTime;
  49809. private _renderTargetsRenderTime;
  49810. private _captureFrameTime;
  49811. private _frameTime;
  49812. private _captureRenderTime;
  49813. private _renderTime;
  49814. private _captureInterFrameTime;
  49815. private _interFrameTime;
  49816. private _captureParticlesRenderTime;
  49817. private _particlesRenderTime;
  49818. private _captureSpritesRenderTime;
  49819. private _spritesRenderTime;
  49820. private _capturePhysicsTime;
  49821. private _physicsTime;
  49822. private _captureAnimationsTime;
  49823. private _animationsTime;
  49824. private _captureCameraRenderTime;
  49825. private _cameraRenderTime;
  49826. private _onBeforeActiveMeshesEvaluationObserver;
  49827. private _onAfterActiveMeshesEvaluationObserver;
  49828. private _onBeforeRenderTargetsRenderObserver;
  49829. private _onAfterRenderTargetsRenderObserver;
  49830. private _onAfterRenderObserver;
  49831. private _onBeforeDrawPhaseObserver;
  49832. private _onAfterDrawPhaseObserver;
  49833. private _onBeforeAnimationsObserver;
  49834. private _onBeforeParticlesRenderingObserver;
  49835. private _onAfterParticlesRenderingObserver;
  49836. private _onBeforeSpritesRenderingObserver;
  49837. private _onAfterSpritesRenderingObserver;
  49838. private _onBeforePhysicsObserver;
  49839. private _onAfterPhysicsObserver;
  49840. private _onAfterAnimationsObserver;
  49841. private _onBeforeCameraRenderObserver;
  49842. private _onAfterCameraRenderObserver;
  49843. /**
  49844. * Gets the perf counter used for active meshes evaluation time
  49845. */
  49846. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49847. /**
  49848. * Gets the active meshes evaluation time capture status
  49849. */
  49850. /**
  49851. * Enable or disable the active meshes evaluation time capture
  49852. */
  49853. captureActiveMeshesEvaluationTime: boolean;
  49854. /**
  49855. * Gets the perf counter used for render targets render time
  49856. */
  49857. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49858. /**
  49859. * Gets the render targets render time capture status
  49860. */
  49861. /**
  49862. * Enable or disable the render targets render time capture
  49863. */
  49864. captureRenderTargetsRenderTime: boolean;
  49865. /**
  49866. * Gets the perf counter used for particles render time
  49867. */
  49868. readonly particlesRenderTimeCounter: PerfCounter;
  49869. /**
  49870. * Gets the particles render time capture status
  49871. */
  49872. /**
  49873. * Enable or disable the particles render time capture
  49874. */
  49875. captureParticlesRenderTime: boolean;
  49876. /**
  49877. * Gets the perf counter used for sprites render time
  49878. */
  49879. readonly spritesRenderTimeCounter: PerfCounter;
  49880. /**
  49881. * Gets the sprites render time capture status
  49882. */
  49883. /**
  49884. * Enable or disable the sprites render time capture
  49885. */
  49886. captureSpritesRenderTime: boolean;
  49887. /**
  49888. * Gets the perf counter used for physics time
  49889. */
  49890. readonly physicsTimeCounter: PerfCounter;
  49891. /**
  49892. * Gets the physics time capture status
  49893. */
  49894. /**
  49895. * Enable or disable the physics time capture
  49896. */
  49897. capturePhysicsTime: boolean;
  49898. /**
  49899. * Gets the perf counter used for animations time
  49900. */
  49901. readonly animationsTimeCounter: PerfCounter;
  49902. /**
  49903. * Gets the animations time capture status
  49904. */
  49905. /**
  49906. * Enable or disable the animations time capture
  49907. */
  49908. captureAnimationsTime: boolean;
  49909. /**
  49910. * Gets the perf counter used for frame time capture
  49911. */
  49912. readonly frameTimeCounter: PerfCounter;
  49913. /**
  49914. * Gets the frame time capture status
  49915. */
  49916. /**
  49917. * Enable or disable the frame time capture
  49918. */
  49919. captureFrameTime: boolean;
  49920. /**
  49921. * Gets the perf counter used for inter-frames time capture
  49922. */
  49923. readonly interFrameTimeCounter: PerfCounter;
  49924. /**
  49925. * Gets the inter-frames time capture status
  49926. */
  49927. /**
  49928. * Enable or disable the inter-frames time capture
  49929. */
  49930. captureInterFrameTime: boolean;
  49931. /**
  49932. * Gets the perf counter used for render time capture
  49933. */
  49934. readonly renderTimeCounter: PerfCounter;
  49935. /**
  49936. * Gets the render time capture status
  49937. */
  49938. /**
  49939. * Enable or disable the render time capture
  49940. */
  49941. captureRenderTime: boolean;
  49942. /**
  49943. * Gets the perf counter used for camera render time capture
  49944. */
  49945. readonly cameraRenderTimeCounter: PerfCounter;
  49946. /**
  49947. * Gets the camera render time capture status
  49948. */
  49949. /**
  49950. * Enable or disable the camera render time capture
  49951. */
  49952. captureCameraRenderTime: boolean;
  49953. /**
  49954. * Gets the perf counter used for draw calls
  49955. */
  49956. readonly drawCallsCounter: PerfCounter;
  49957. /**
  49958. * Instantiates a new scene instrumentation.
  49959. * This class can be used to get instrumentation data from a Babylon engine
  49960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49961. * @param scene Defines the scene to instrument
  49962. */
  49963. constructor(
  49964. /**
  49965. * Defines the scene to instrument
  49966. */
  49967. scene: Scene);
  49968. /**
  49969. * Dispose and release associated resources.
  49970. */
  49971. dispose(): void;
  49972. }
  49973. }
  49974. declare module "babylonjs/Instrumentation/index" {
  49975. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49976. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49977. export * from "babylonjs/Instrumentation/timeToken";
  49978. }
  49979. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49980. /** @hidden */
  49981. export var glowMapGenerationPixelShader: {
  49982. name: string;
  49983. shader: string;
  49984. };
  49985. }
  49986. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49987. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49988. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49989. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49990. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49991. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49992. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49993. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49994. /** @hidden */
  49995. export var glowMapGenerationVertexShader: {
  49996. name: string;
  49997. shader: string;
  49998. };
  49999. }
  50000. declare module "babylonjs/Layers/effectLayer" {
  50001. import { Observable } from "babylonjs/Misc/observable";
  50002. import { Nullable } from "babylonjs/types";
  50003. import { Camera } from "babylonjs/Cameras/camera";
  50004. import { Scene } from "babylonjs/scene";
  50005. import { ISize } from "babylonjs/Maths/math.size";
  50006. import { Color4 } from "babylonjs/Maths/math.color";
  50007. import { Engine } from "babylonjs/Engines/engine";
  50008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50010. import { Mesh } from "babylonjs/Meshes/mesh";
  50011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50012. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50013. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50014. import { Effect } from "babylonjs/Materials/effect";
  50015. import { Material } from "babylonjs/Materials/material";
  50016. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50017. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50018. /**
  50019. * Effect layer options. This helps customizing the behaviour
  50020. * of the effect layer.
  50021. */
  50022. export interface IEffectLayerOptions {
  50023. /**
  50024. * Multiplication factor apply to the canvas size to compute the render target size
  50025. * used to generated the objects (the smaller the faster).
  50026. */
  50027. mainTextureRatio: number;
  50028. /**
  50029. * Enforces a fixed size texture to ensure effect stability across devices.
  50030. */
  50031. mainTextureFixedSize?: number;
  50032. /**
  50033. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50034. */
  50035. alphaBlendingMode: number;
  50036. /**
  50037. * The camera attached to the layer.
  50038. */
  50039. camera: Nullable<Camera>;
  50040. /**
  50041. * The rendering group to draw the layer in.
  50042. */
  50043. renderingGroupId: number;
  50044. }
  50045. /**
  50046. * The effect layer Helps adding post process effect blended with the main pass.
  50047. *
  50048. * This can be for instance use to generate glow or higlight effects on the scene.
  50049. *
  50050. * The effect layer class can not be used directly and is intented to inherited from to be
  50051. * customized per effects.
  50052. */
  50053. export abstract class EffectLayer {
  50054. private _vertexBuffers;
  50055. private _indexBuffer;
  50056. private _cachedDefines;
  50057. private _effectLayerMapGenerationEffect;
  50058. private _effectLayerOptions;
  50059. private _mergeEffect;
  50060. protected _scene: Scene;
  50061. protected _engine: Engine;
  50062. protected _maxSize: number;
  50063. protected _mainTextureDesiredSize: ISize;
  50064. protected _mainTexture: RenderTargetTexture;
  50065. protected _shouldRender: boolean;
  50066. protected _postProcesses: PostProcess[];
  50067. protected _textures: BaseTexture[];
  50068. protected _emissiveTextureAndColor: {
  50069. texture: Nullable<BaseTexture>;
  50070. color: Color4;
  50071. };
  50072. /**
  50073. * The name of the layer
  50074. */
  50075. name: string;
  50076. /**
  50077. * The clear color of the texture used to generate the glow map.
  50078. */
  50079. neutralColor: Color4;
  50080. /**
  50081. * Specifies wether the highlight layer is enabled or not.
  50082. */
  50083. isEnabled: boolean;
  50084. /**
  50085. * Gets the camera attached to the layer.
  50086. */
  50087. readonly camera: Nullable<Camera>;
  50088. /**
  50089. * Gets the rendering group id the layer should render in.
  50090. */
  50091. renderingGroupId: number;
  50092. /**
  50093. * An event triggered when the effect layer has been disposed.
  50094. */
  50095. onDisposeObservable: Observable<EffectLayer>;
  50096. /**
  50097. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50098. */
  50099. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50100. /**
  50101. * An event triggered when the generated texture is being merged in the scene.
  50102. */
  50103. onBeforeComposeObservable: Observable<EffectLayer>;
  50104. /**
  50105. * An event triggered when the generated texture has been merged in the scene.
  50106. */
  50107. onAfterComposeObservable: Observable<EffectLayer>;
  50108. /**
  50109. * An event triggered when the efffect layer changes its size.
  50110. */
  50111. onSizeChangedObservable: Observable<EffectLayer>;
  50112. /** @hidden */
  50113. static _SceneComponentInitialization: (scene: Scene) => void;
  50114. /**
  50115. * Instantiates a new effect Layer and references it in the scene.
  50116. * @param name The name of the layer
  50117. * @param scene The scene to use the layer in
  50118. */
  50119. constructor(
  50120. /** The Friendly of the effect in the scene */
  50121. name: string, scene: Scene);
  50122. /**
  50123. * Get the effect name of the layer.
  50124. * @return The effect name
  50125. */
  50126. abstract getEffectName(): string;
  50127. /**
  50128. * Checks for the readiness of the element composing the layer.
  50129. * @param subMesh the mesh to check for
  50130. * @param useInstances specify wether or not to use instances to render the mesh
  50131. * @return true if ready otherwise, false
  50132. */
  50133. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50134. /**
  50135. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50136. * @returns true if the effect requires stencil during the main canvas render pass.
  50137. */
  50138. abstract needStencil(): boolean;
  50139. /**
  50140. * Create the merge effect. This is the shader use to blit the information back
  50141. * to the main canvas at the end of the scene rendering.
  50142. * @returns The effect containing the shader used to merge the effect on the main canvas
  50143. */
  50144. protected abstract _createMergeEffect(): Effect;
  50145. /**
  50146. * Creates the render target textures and post processes used in the effect layer.
  50147. */
  50148. protected abstract _createTextureAndPostProcesses(): void;
  50149. /**
  50150. * Implementation specific of rendering the generating effect on the main canvas.
  50151. * @param effect The effect used to render through
  50152. */
  50153. protected abstract _internalRender(effect: Effect): void;
  50154. /**
  50155. * Sets the required values for both the emissive texture and and the main color.
  50156. */
  50157. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50158. /**
  50159. * Free any resources and references associated to a mesh.
  50160. * Internal use
  50161. * @param mesh The mesh to free.
  50162. */
  50163. abstract _disposeMesh(mesh: Mesh): void;
  50164. /**
  50165. * Serializes this layer (Glow or Highlight for example)
  50166. * @returns a serialized layer object
  50167. */
  50168. abstract serialize?(): any;
  50169. /**
  50170. * Initializes the effect layer with the required options.
  50171. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50172. */
  50173. protected _init(options: Partial<IEffectLayerOptions>): void;
  50174. /**
  50175. * Generates the index buffer of the full screen quad blending to the main canvas.
  50176. */
  50177. private _generateIndexBuffer;
  50178. /**
  50179. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50180. */
  50181. private _generateVertexBuffer;
  50182. /**
  50183. * Sets the main texture desired size which is the closest power of two
  50184. * of the engine canvas size.
  50185. */
  50186. private _setMainTextureSize;
  50187. /**
  50188. * Creates the main texture for the effect layer.
  50189. */
  50190. protected _createMainTexture(): void;
  50191. /**
  50192. * Adds specific effects defines.
  50193. * @param defines The defines to add specifics to.
  50194. */
  50195. protected _addCustomEffectDefines(defines: string[]): void;
  50196. /**
  50197. * Checks for the readiness of the element composing the layer.
  50198. * @param subMesh the mesh to check for
  50199. * @param useInstances specify wether or not to use instances to render the mesh
  50200. * @param emissiveTexture the associated emissive texture used to generate the glow
  50201. * @return true if ready otherwise, false
  50202. */
  50203. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50204. /**
  50205. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50206. */
  50207. render(): void;
  50208. /**
  50209. * Determine if a given mesh will be used in the current effect.
  50210. * @param mesh mesh to test
  50211. * @returns true if the mesh will be used
  50212. */
  50213. hasMesh(mesh: AbstractMesh): boolean;
  50214. /**
  50215. * Returns true if the layer contains information to display, otherwise false.
  50216. * @returns true if the glow layer should be rendered
  50217. */
  50218. shouldRender(): boolean;
  50219. /**
  50220. * Returns true if the mesh should render, otherwise false.
  50221. * @param mesh The mesh to render
  50222. * @returns true if it should render otherwise false
  50223. */
  50224. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50225. /**
  50226. * Returns true if the mesh can be rendered, otherwise false.
  50227. * @param mesh The mesh to render
  50228. * @param material The material used on the mesh
  50229. * @returns true if it can be rendered otherwise false
  50230. */
  50231. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50232. /**
  50233. * Returns true if the mesh should render, otherwise false.
  50234. * @param mesh The mesh to render
  50235. * @returns true if it should render otherwise false
  50236. */
  50237. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50238. /**
  50239. * Renders the submesh passed in parameter to the generation map.
  50240. */
  50241. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50242. /**
  50243. * Rebuild the required buffers.
  50244. * @hidden Internal use only.
  50245. */
  50246. _rebuild(): void;
  50247. /**
  50248. * Dispose only the render target textures and post process.
  50249. */
  50250. private _disposeTextureAndPostProcesses;
  50251. /**
  50252. * Dispose the highlight layer and free resources.
  50253. */
  50254. dispose(): void;
  50255. /**
  50256. * Gets the class name of the effect layer
  50257. * @returns the string with the class name of the effect layer
  50258. */
  50259. getClassName(): string;
  50260. /**
  50261. * Creates an effect layer from parsed effect layer data
  50262. * @param parsedEffectLayer defines effect layer data
  50263. * @param scene defines the current scene
  50264. * @param rootUrl defines the root URL containing the effect layer information
  50265. * @returns a parsed effect Layer
  50266. */
  50267. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50268. }
  50269. }
  50270. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50271. import { Scene } from "babylonjs/scene";
  50272. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50273. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50274. import { AbstractScene } from "babylonjs/abstractScene";
  50275. module "babylonjs/abstractScene" {
  50276. interface AbstractScene {
  50277. /**
  50278. * The list of effect layers (highlights/glow) added to the scene
  50279. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50280. * @see http://doc.babylonjs.com/how_to/glow_layer
  50281. */
  50282. effectLayers: Array<EffectLayer>;
  50283. /**
  50284. * Removes the given effect layer from this scene.
  50285. * @param toRemove defines the effect layer to remove
  50286. * @returns the index of the removed effect layer
  50287. */
  50288. removeEffectLayer(toRemove: EffectLayer): number;
  50289. /**
  50290. * Adds the given effect layer to this scene
  50291. * @param newEffectLayer defines the effect layer to add
  50292. */
  50293. addEffectLayer(newEffectLayer: EffectLayer): void;
  50294. }
  50295. }
  50296. /**
  50297. * Defines the layer scene component responsible to manage any effect layers
  50298. * in a given scene.
  50299. */
  50300. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50301. /**
  50302. * The component name helpfull to identify the component in the list of scene components.
  50303. */
  50304. readonly name: string;
  50305. /**
  50306. * The scene the component belongs to.
  50307. */
  50308. scene: Scene;
  50309. private _engine;
  50310. private _renderEffects;
  50311. private _needStencil;
  50312. private _previousStencilState;
  50313. /**
  50314. * Creates a new instance of the component for the given scene
  50315. * @param scene Defines the scene to register the component in
  50316. */
  50317. constructor(scene: Scene);
  50318. /**
  50319. * Registers the component in a given scene
  50320. */
  50321. register(): void;
  50322. /**
  50323. * Rebuilds the elements related to this component in case of
  50324. * context lost for instance.
  50325. */
  50326. rebuild(): void;
  50327. /**
  50328. * Serializes the component data to the specified json object
  50329. * @param serializationObject The object to serialize to
  50330. */
  50331. serialize(serializationObject: any): void;
  50332. /**
  50333. * Adds all the elements from the container to the scene
  50334. * @param container the container holding the elements
  50335. */
  50336. addFromContainer(container: AbstractScene): void;
  50337. /**
  50338. * Removes all the elements in the container from the scene
  50339. * @param container contains the elements to remove
  50340. * @param dispose if the removed element should be disposed (default: false)
  50341. */
  50342. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50343. /**
  50344. * Disposes the component and the associated ressources.
  50345. */
  50346. dispose(): void;
  50347. private _isReadyForMesh;
  50348. private _renderMainTexture;
  50349. private _setStencil;
  50350. private _setStencilBack;
  50351. private _draw;
  50352. private _drawCamera;
  50353. private _drawRenderingGroup;
  50354. }
  50355. }
  50356. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50357. /** @hidden */
  50358. export var glowMapMergePixelShader: {
  50359. name: string;
  50360. shader: string;
  50361. };
  50362. }
  50363. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50364. /** @hidden */
  50365. export var glowMapMergeVertexShader: {
  50366. name: string;
  50367. shader: string;
  50368. };
  50369. }
  50370. declare module "babylonjs/Layers/glowLayer" {
  50371. import { Nullable } from "babylonjs/types";
  50372. import { Camera } from "babylonjs/Cameras/camera";
  50373. import { Scene } from "babylonjs/scene";
  50374. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50376. import { Mesh } from "babylonjs/Meshes/mesh";
  50377. import { Texture } from "babylonjs/Materials/Textures/texture";
  50378. import { Effect } from "babylonjs/Materials/effect";
  50379. import { Material } from "babylonjs/Materials/material";
  50380. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50381. import { Color4 } from "babylonjs/Maths/math.color";
  50382. import "babylonjs/Shaders/glowMapMerge.fragment";
  50383. import "babylonjs/Shaders/glowMapMerge.vertex";
  50384. import "babylonjs/Layers/effectLayerSceneComponent";
  50385. module "babylonjs/abstractScene" {
  50386. interface AbstractScene {
  50387. /**
  50388. * Return a the first highlight layer of the scene with a given name.
  50389. * @param name The name of the highlight layer to look for.
  50390. * @return The highlight layer if found otherwise null.
  50391. */
  50392. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50393. }
  50394. }
  50395. /**
  50396. * Glow layer options. This helps customizing the behaviour
  50397. * of the glow layer.
  50398. */
  50399. export interface IGlowLayerOptions {
  50400. /**
  50401. * Multiplication factor apply to the canvas size to compute the render target size
  50402. * used to generated the glowing objects (the smaller the faster).
  50403. */
  50404. mainTextureRatio: number;
  50405. /**
  50406. * Enforces a fixed size texture to ensure resize independant blur.
  50407. */
  50408. mainTextureFixedSize?: number;
  50409. /**
  50410. * How big is the kernel of the blur texture.
  50411. */
  50412. blurKernelSize: number;
  50413. /**
  50414. * The camera attached to the layer.
  50415. */
  50416. camera: Nullable<Camera>;
  50417. /**
  50418. * Enable MSAA by chosing the number of samples.
  50419. */
  50420. mainTextureSamples?: number;
  50421. /**
  50422. * The rendering group to draw the layer in.
  50423. */
  50424. renderingGroupId: number;
  50425. }
  50426. /**
  50427. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50428. *
  50429. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50430. * glowy meshes to your scene.
  50431. *
  50432. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50433. */
  50434. export class GlowLayer extends EffectLayer {
  50435. /**
  50436. * Effect Name of the layer.
  50437. */
  50438. static readonly EffectName: string;
  50439. /**
  50440. * The default blur kernel size used for the glow.
  50441. */
  50442. static DefaultBlurKernelSize: number;
  50443. /**
  50444. * The default texture size ratio used for the glow.
  50445. */
  50446. static DefaultTextureRatio: number;
  50447. /**
  50448. * Sets the kernel size of the blur.
  50449. */
  50450. /**
  50451. * Gets the kernel size of the blur.
  50452. */
  50453. blurKernelSize: number;
  50454. /**
  50455. * Sets the glow intensity.
  50456. */
  50457. /**
  50458. * Gets the glow intensity.
  50459. */
  50460. intensity: number;
  50461. private _options;
  50462. private _intensity;
  50463. private _horizontalBlurPostprocess1;
  50464. private _verticalBlurPostprocess1;
  50465. private _horizontalBlurPostprocess2;
  50466. private _verticalBlurPostprocess2;
  50467. private _blurTexture1;
  50468. private _blurTexture2;
  50469. private _postProcesses1;
  50470. private _postProcesses2;
  50471. private _includedOnlyMeshes;
  50472. private _excludedMeshes;
  50473. /**
  50474. * Callback used to let the user override the color selection on a per mesh basis
  50475. */
  50476. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50477. /**
  50478. * Callback used to let the user override the texture selection on a per mesh basis
  50479. */
  50480. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50481. /**
  50482. * Instantiates a new glow Layer and references it to the scene.
  50483. * @param name The name of the layer
  50484. * @param scene The scene to use the layer in
  50485. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50486. */
  50487. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50488. /**
  50489. * Get the effect name of the layer.
  50490. * @return The effect name
  50491. */
  50492. getEffectName(): string;
  50493. /**
  50494. * Create the merge effect. This is the shader use to blit the information back
  50495. * to the main canvas at the end of the scene rendering.
  50496. */
  50497. protected _createMergeEffect(): Effect;
  50498. /**
  50499. * Creates the render target textures and post processes used in the glow layer.
  50500. */
  50501. protected _createTextureAndPostProcesses(): void;
  50502. /**
  50503. * Checks for the readiness of the element composing the layer.
  50504. * @param subMesh the mesh to check for
  50505. * @param useInstances specify wether or not to use instances to render the mesh
  50506. * @param emissiveTexture the associated emissive texture used to generate the glow
  50507. * @return true if ready otherwise, false
  50508. */
  50509. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50510. /**
  50511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50512. */
  50513. needStencil(): boolean;
  50514. /**
  50515. * Returns true if the mesh can be rendered, otherwise false.
  50516. * @param mesh The mesh to render
  50517. * @param material The material used on the mesh
  50518. * @returns true if it can be rendered otherwise false
  50519. */
  50520. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50521. /**
  50522. * Implementation specific of rendering the generating effect on the main canvas.
  50523. * @param effect The effect used to render through
  50524. */
  50525. protected _internalRender(effect: Effect): void;
  50526. /**
  50527. * Sets the required values for both the emissive texture and and the main color.
  50528. */
  50529. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50530. /**
  50531. * Returns true if the mesh should render, otherwise false.
  50532. * @param mesh The mesh to render
  50533. * @returns true if it should render otherwise false
  50534. */
  50535. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50536. /**
  50537. * Adds specific effects defines.
  50538. * @param defines The defines to add specifics to.
  50539. */
  50540. protected _addCustomEffectDefines(defines: string[]): void;
  50541. /**
  50542. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50543. * @param mesh The mesh to exclude from the glow layer
  50544. */
  50545. addExcludedMesh(mesh: Mesh): void;
  50546. /**
  50547. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50548. * @param mesh The mesh to remove
  50549. */
  50550. removeExcludedMesh(mesh: Mesh): void;
  50551. /**
  50552. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50553. * @param mesh The mesh to include in the glow layer
  50554. */
  50555. addIncludedOnlyMesh(mesh: Mesh): void;
  50556. /**
  50557. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50558. * @param mesh The mesh to remove
  50559. */
  50560. removeIncludedOnlyMesh(mesh: Mesh): void;
  50561. /**
  50562. * Determine if a given mesh will be used in the glow layer
  50563. * @param mesh The mesh to test
  50564. * @returns true if the mesh will be highlighted by the current glow layer
  50565. */
  50566. hasMesh(mesh: AbstractMesh): boolean;
  50567. /**
  50568. * Free any resources and references associated to a mesh.
  50569. * Internal use
  50570. * @param mesh The mesh to free.
  50571. * @hidden
  50572. */
  50573. _disposeMesh(mesh: Mesh): void;
  50574. /**
  50575. * Gets the class name of the effect layer
  50576. * @returns the string with the class name of the effect layer
  50577. */
  50578. getClassName(): string;
  50579. /**
  50580. * Serializes this glow layer
  50581. * @returns a serialized glow layer object
  50582. */
  50583. serialize(): any;
  50584. /**
  50585. * Creates a Glow Layer from parsed glow layer data
  50586. * @param parsedGlowLayer defines glow layer data
  50587. * @param scene defines the current scene
  50588. * @param rootUrl defines the root URL containing the glow layer information
  50589. * @returns a parsed Glow Layer
  50590. */
  50591. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50592. }
  50593. }
  50594. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50595. /** @hidden */
  50596. export var glowBlurPostProcessPixelShader: {
  50597. name: string;
  50598. shader: string;
  50599. };
  50600. }
  50601. declare module "babylonjs/Layers/highlightLayer" {
  50602. import { Observable } from "babylonjs/Misc/observable";
  50603. import { Nullable } from "babylonjs/types";
  50604. import { Camera } from "babylonjs/Cameras/camera";
  50605. import { Scene } from "babylonjs/scene";
  50606. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50608. import { Mesh } from "babylonjs/Meshes/mesh";
  50609. import { Effect } from "babylonjs/Materials/effect";
  50610. import { Material } from "babylonjs/Materials/material";
  50611. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50612. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50613. import "babylonjs/Shaders/glowMapMerge.fragment";
  50614. import "babylonjs/Shaders/glowMapMerge.vertex";
  50615. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50616. module "babylonjs/abstractScene" {
  50617. interface AbstractScene {
  50618. /**
  50619. * Return a the first highlight layer of the scene with a given name.
  50620. * @param name The name of the highlight layer to look for.
  50621. * @return The highlight layer if found otherwise null.
  50622. */
  50623. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50624. }
  50625. }
  50626. /**
  50627. * Highlight layer options. This helps customizing the behaviour
  50628. * of the highlight layer.
  50629. */
  50630. export interface IHighlightLayerOptions {
  50631. /**
  50632. * Multiplication factor apply to the canvas size to compute the render target size
  50633. * used to generated the glowing objects (the smaller the faster).
  50634. */
  50635. mainTextureRatio: number;
  50636. /**
  50637. * Enforces a fixed size texture to ensure resize independant blur.
  50638. */
  50639. mainTextureFixedSize?: number;
  50640. /**
  50641. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50642. * of the picture to blur (the smaller the faster).
  50643. */
  50644. blurTextureSizeRatio: number;
  50645. /**
  50646. * How big in texel of the blur texture is the vertical blur.
  50647. */
  50648. blurVerticalSize: number;
  50649. /**
  50650. * How big in texel of the blur texture is the horizontal blur.
  50651. */
  50652. blurHorizontalSize: number;
  50653. /**
  50654. * Alpha blending mode used to apply the blur. Default is combine.
  50655. */
  50656. alphaBlendingMode: number;
  50657. /**
  50658. * The camera attached to the layer.
  50659. */
  50660. camera: Nullable<Camera>;
  50661. /**
  50662. * Should we display highlight as a solid stroke?
  50663. */
  50664. isStroke?: boolean;
  50665. /**
  50666. * The rendering group to draw the layer in.
  50667. */
  50668. renderingGroupId: number;
  50669. }
  50670. /**
  50671. * The highlight layer Helps adding a glow effect around a mesh.
  50672. *
  50673. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50674. * glowy meshes to your scene.
  50675. *
  50676. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50677. */
  50678. export class HighlightLayer extends EffectLayer {
  50679. name: string;
  50680. /**
  50681. * Effect Name of the highlight layer.
  50682. */
  50683. static readonly EffectName: string;
  50684. /**
  50685. * The neutral color used during the preparation of the glow effect.
  50686. * This is black by default as the blend operation is a blend operation.
  50687. */
  50688. static NeutralColor: Color4;
  50689. /**
  50690. * Stencil value used for glowing meshes.
  50691. */
  50692. static GlowingMeshStencilReference: number;
  50693. /**
  50694. * Stencil value used for the other meshes in the scene.
  50695. */
  50696. static NormalMeshStencilReference: number;
  50697. /**
  50698. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50699. */
  50700. innerGlow: boolean;
  50701. /**
  50702. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50703. */
  50704. outerGlow: boolean;
  50705. /**
  50706. * Specifies the horizontal size of the blur.
  50707. */
  50708. /**
  50709. * Gets the horizontal size of the blur.
  50710. */
  50711. blurHorizontalSize: number;
  50712. /**
  50713. * Specifies the vertical size of the blur.
  50714. */
  50715. /**
  50716. * Gets the vertical size of the blur.
  50717. */
  50718. blurVerticalSize: number;
  50719. /**
  50720. * An event triggered when the highlight layer is being blurred.
  50721. */
  50722. onBeforeBlurObservable: Observable<HighlightLayer>;
  50723. /**
  50724. * An event triggered when the highlight layer has been blurred.
  50725. */
  50726. onAfterBlurObservable: Observable<HighlightLayer>;
  50727. private _instanceGlowingMeshStencilReference;
  50728. private _options;
  50729. private _downSamplePostprocess;
  50730. private _horizontalBlurPostprocess;
  50731. private _verticalBlurPostprocess;
  50732. private _blurTexture;
  50733. private _meshes;
  50734. private _excludedMeshes;
  50735. /**
  50736. * Instantiates a new highlight Layer and references it to the scene..
  50737. * @param name The name of the layer
  50738. * @param scene The scene to use the layer in
  50739. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50740. */
  50741. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50742. /**
  50743. * Get the effect name of the layer.
  50744. * @return The effect name
  50745. */
  50746. getEffectName(): string;
  50747. /**
  50748. * Create the merge effect. This is the shader use to blit the information back
  50749. * to the main canvas at the end of the scene rendering.
  50750. */
  50751. protected _createMergeEffect(): Effect;
  50752. /**
  50753. * Creates the render target textures and post processes used in the highlight layer.
  50754. */
  50755. protected _createTextureAndPostProcesses(): void;
  50756. /**
  50757. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50758. */
  50759. needStencil(): boolean;
  50760. /**
  50761. * Checks for the readiness of the element composing the layer.
  50762. * @param subMesh the mesh to check for
  50763. * @param useInstances specify wether or not to use instances to render the mesh
  50764. * @param emissiveTexture the associated emissive texture used to generate the glow
  50765. * @return true if ready otherwise, false
  50766. */
  50767. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50768. /**
  50769. * Implementation specific of rendering the generating effect on the main canvas.
  50770. * @param effect The effect used to render through
  50771. */
  50772. protected _internalRender(effect: Effect): void;
  50773. /**
  50774. * Returns true if the layer contains information to display, otherwise false.
  50775. */
  50776. shouldRender(): boolean;
  50777. /**
  50778. * Returns true if the mesh should render, otherwise false.
  50779. * @param mesh The mesh to render
  50780. * @returns true if it should render otherwise false
  50781. */
  50782. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50783. /**
  50784. * Sets the required values for both the emissive texture and and the main color.
  50785. */
  50786. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50787. /**
  50788. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50789. * @param mesh The mesh to exclude from the highlight layer
  50790. */
  50791. addExcludedMesh(mesh: Mesh): void;
  50792. /**
  50793. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50794. * @param mesh The mesh to highlight
  50795. */
  50796. removeExcludedMesh(mesh: Mesh): void;
  50797. /**
  50798. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50799. * @param mesh mesh to test
  50800. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50801. */
  50802. hasMesh(mesh: AbstractMesh): boolean;
  50803. /**
  50804. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50805. * @param mesh The mesh to highlight
  50806. * @param color The color of the highlight
  50807. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50808. */
  50809. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50810. /**
  50811. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50812. * @param mesh The mesh to highlight
  50813. */
  50814. removeMesh(mesh: Mesh): void;
  50815. /**
  50816. * Force the stencil to the normal expected value for none glowing parts
  50817. */
  50818. private _defaultStencilReference;
  50819. /**
  50820. * Free any resources and references associated to a mesh.
  50821. * Internal use
  50822. * @param mesh The mesh to free.
  50823. * @hidden
  50824. */
  50825. _disposeMesh(mesh: Mesh): void;
  50826. /**
  50827. * Dispose the highlight layer and free resources.
  50828. */
  50829. dispose(): void;
  50830. /**
  50831. * Gets the class name of the effect layer
  50832. * @returns the string with the class name of the effect layer
  50833. */
  50834. getClassName(): string;
  50835. /**
  50836. * Serializes this Highlight layer
  50837. * @returns a serialized Highlight layer object
  50838. */
  50839. serialize(): any;
  50840. /**
  50841. * Creates a Highlight layer from parsed Highlight layer data
  50842. * @param parsedHightlightLayer defines the Highlight layer data
  50843. * @param scene defines the current scene
  50844. * @param rootUrl defines the root URL containing the Highlight layer information
  50845. * @returns a parsed Highlight layer
  50846. */
  50847. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50848. }
  50849. }
  50850. declare module "babylonjs/Layers/layerSceneComponent" {
  50851. import { Scene } from "babylonjs/scene";
  50852. import { ISceneComponent } from "babylonjs/sceneComponent";
  50853. import { Layer } from "babylonjs/Layers/layer";
  50854. import { AbstractScene } from "babylonjs/abstractScene";
  50855. module "babylonjs/abstractScene" {
  50856. interface AbstractScene {
  50857. /**
  50858. * The list of layers (background and foreground) of the scene
  50859. */
  50860. layers: Array<Layer>;
  50861. }
  50862. }
  50863. /**
  50864. * Defines the layer scene component responsible to manage any layers
  50865. * in a given scene.
  50866. */
  50867. export class LayerSceneComponent implements ISceneComponent {
  50868. /**
  50869. * The component name helpfull to identify the component in the list of scene components.
  50870. */
  50871. readonly name: string;
  50872. /**
  50873. * The scene the component belongs to.
  50874. */
  50875. scene: Scene;
  50876. private _engine;
  50877. /**
  50878. * Creates a new instance of the component for the given scene
  50879. * @param scene Defines the scene to register the component in
  50880. */
  50881. constructor(scene: Scene);
  50882. /**
  50883. * Registers the component in a given scene
  50884. */
  50885. register(): void;
  50886. /**
  50887. * Rebuilds the elements related to this component in case of
  50888. * context lost for instance.
  50889. */
  50890. rebuild(): void;
  50891. /**
  50892. * Disposes the component and the associated ressources.
  50893. */
  50894. dispose(): void;
  50895. private _draw;
  50896. private _drawCameraPredicate;
  50897. private _drawCameraBackground;
  50898. private _drawCameraForeground;
  50899. private _drawRenderTargetPredicate;
  50900. private _drawRenderTargetBackground;
  50901. private _drawRenderTargetForeground;
  50902. /**
  50903. * Adds all the elements from the container to the scene
  50904. * @param container the container holding the elements
  50905. */
  50906. addFromContainer(container: AbstractScene): void;
  50907. /**
  50908. * Removes all the elements in the container from the scene
  50909. * @param container contains the elements to remove
  50910. * @param dispose if the removed element should be disposed (default: false)
  50911. */
  50912. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50913. }
  50914. }
  50915. declare module "babylonjs/Shaders/layer.fragment" {
  50916. /** @hidden */
  50917. export var layerPixelShader: {
  50918. name: string;
  50919. shader: string;
  50920. };
  50921. }
  50922. declare module "babylonjs/Shaders/layer.vertex" {
  50923. /** @hidden */
  50924. export var layerVertexShader: {
  50925. name: string;
  50926. shader: string;
  50927. };
  50928. }
  50929. declare module "babylonjs/Layers/layer" {
  50930. import { Observable } from "babylonjs/Misc/observable";
  50931. import { Nullable } from "babylonjs/types";
  50932. import { Scene } from "babylonjs/scene";
  50933. import { Vector2 } from "babylonjs/Maths/math.vector";
  50934. import { Color4 } from "babylonjs/Maths/math.color";
  50935. import { Texture } from "babylonjs/Materials/Textures/texture";
  50936. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50937. import "babylonjs/Shaders/layer.fragment";
  50938. import "babylonjs/Shaders/layer.vertex";
  50939. /**
  50940. * This represents a full screen 2d layer.
  50941. * This can be useful to display a picture in the background of your scene for instance.
  50942. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50943. */
  50944. export class Layer {
  50945. /**
  50946. * Define the name of the layer.
  50947. */
  50948. name: string;
  50949. /**
  50950. * Define the texture the layer should display.
  50951. */
  50952. texture: Nullable<Texture>;
  50953. /**
  50954. * Is the layer in background or foreground.
  50955. */
  50956. isBackground: boolean;
  50957. /**
  50958. * Define the color of the layer (instead of texture).
  50959. */
  50960. color: Color4;
  50961. /**
  50962. * Define the scale of the layer in order to zoom in out of the texture.
  50963. */
  50964. scale: Vector2;
  50965. /**
  50966. * Define an offset for the layer in order to shift the texture.
  50967. */
  50968. offset: Vector2;
  50969. /**
  50970. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50971. */
  50972. alphaBlendingMode: number;
  50973. /**
  50974. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50975. * Alpha test will not mix with the background color in case of transparency.
  50976. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50977. */
  50978. alphaTest: boolean;
  50979. /**
  50980. * Define a mask to restrict the layer to only some of the scene cameras.
  50981. */
  50982. layerMask: number;
  50983. /**
  50984. * Define the list of render target the layer is visible into.
  50985. */
  50986. renderTargetTextures: RenderTargetTexture[];
  50987. /**
  50988. * Define if the layer is only used in renderTarget or if it also
  50989. * renders in the main frame buffer of the canvas.
  50990. */
  50991. renderOnlyInRenderTargetTextures: boolean;
  50992. private _scene;
  50993. private _vertexBuffers;
  50994. private _indexBuffer;
  50995. private _effect;
  50996. private _alphaTestEffect;
  50997. /**
  50998. * An event triggered when the layer is disposed.
  50999. */
  51000. onDisposeObservable: Observable<Layer>;
  51001. private _onDisposeObserver;
  51002. /**
  51003. * Back compatibility with callback before the onDisposeObservable existed.
  51004. * The set callback will be triggered when the layer has been disposed.
  51005. */
  51006. onDispose: () => void;
  51007. /**
  51008. * An event triggered before rendering the scene
  51009. */
  51010. onBeforeRenderObservable: Observable<Layer>;
  51011. private _onBeforeRenderObserver;
  51012. /**
  51013. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51014. * The set callback will be triggered just before rendering the layer.
  51015. */
  51016. onBeforeRender: () => void;
  51017. /**
  51018. * An event triggered after rendering the scene
  51019. */
  51020. onAfterRenderObservable: Observable<Layer>;
  51021. private _onAfterRenderObserver;
  51022. /**
  51023. * Back compatibility with callback before the onAfterRenderObservable existed.
  51024. * The set callback will be triggered just after rendering the layer.
  51025. */
  51026. onAfterRender: () => void;
  51027. /**
  51028. * Instantiates a new layer.
  51029. * This represents a full screen 2d layer.
  51030. * This can be useful to display a picture in the background of your scene for instance.
  51031. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51032. * @param name Define the name of the layer in the scene
  51033. * @param imgUrl Define the url of the texture to display in the layer
  51034. * @param scene Define the scene the layer belongs to
  51035. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51036. * @param color Defines a color for the layer
  51037. */
  51038. constructor(
  51039. /**
  51040. * Define the name of the layer.
  51041. */
  51042. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51043. private _createIndexBuffer;
  51044. /** @hidden */
  51045. _rebuild(): void;
  51046. /**
  51047. * Renders the layer in the scene.
  51048. */
  51049. render(): void;
  51050. /**
  51051. * Disposes and releases the associated ressources.
  51052. */
  51053. dispose(): void;
  51054. }
  51055. }
  51056. declare module "babylonjs/Layers/index" {
  51057. export * from "babylonjs/Layers/effectLayer";
  51058. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51059. export * from "babylonjs/Layers/glowLayer";
  51060. export * from "babylonjs/Layers/highlightLayer";
  51061. export * from "babylonjs/Layers/layer";
  51062. export * from "babylonjs/Layers/layerSceneComponent";
  51063. }
  51064. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51065. /** @hidden */
  51066. export var lensFlarePixelShader: {
  51067. name: string;
  51068. shader: string;
  51069. };
  51070. }
  51071. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51072. /** @hidden */
  51073. export var lensFlareVertexShader: {
  51074. name: string;
  51075. shader: string;
  51076. };
  51077. }
  51078. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51079. import { Scene } from "babylonjs/scene";
  51080. import { Vector3 } from "babylonjs/Maths/math.vector";
  51081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51082. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51083. import "babylonjs/Shaders/lensFlare.fragment";
  51084. import "babylonjs/Shaders/lensFlare.vertex";
  51085. import { Viewport } from "babylonjs/Maths/math.viewport";
  51086. /**
  51087. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51088. * It is usually composed of several `lensFlare`.
  51089. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51090. */
  51091. export class LensFlareSystem {
  51092. /**
  51093. * Define the name of the lens flare system
  51094. */
  51095. name: string;
  51096. /**
  51097. * List of lens flares used in this system.
  51098. */
  51099. lensFlares: LensFlare[];
  51100. /**
  51101. * Define a limit from the border the lens flare can be visible.
  51102. */
  51103. borderLimit: number;
  51104. /**
  51105. * Define a viewport border we do not want to see the lens flare in.
  51106. */
  51107. viewportBorder: number;
  51108. /**
  51109. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51110. */
  51111. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51112. /**
  51113. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51114. */
  51115. layerMask: number;
  51116. /**
  51117. * Define the id of the lens flare system in the scene.
  51118. * (equal to name by default)
  51119. */
  51120. id: string;
  51121. private _scene;
  51122. private _emitter;
  51123. private _vertexBuffers;
  51124. private _indexBuffer;
  51125. private _effect;
  51126. private _positionX;
  51127. private _positionY;
  51128. private _isEnabled;
  51129. /** @hidden */
  51130. static _SceneComponentInitialization: (scene: Scene) => void;
  51131. /**
  51132. * Instantiates a lens flare system.
  51133. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51134. * It is usually composed of several `lensFlare`.
  51135. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51136. * @param name Define the name of the lens flare system in the scene
  51137. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51138. * @param scene Define the scene the lens flare system belongs to
  51139. */
  51140. constructor(
  51141. /**
  51142. * Define the name of the lens flare system
  51143. */
  51144. name: string, emitter: any, scene: Scene);
  51145. /**
  51146. * Define if the lens flare system is enabled.
  51147. */
  51148. isEnabled: boolean;
  51149. /**
  51150. * Get the scene the effects belongs to.
  51151. * @returns the scene holding the lens flare system
  51152. */
  51153. getScene(): Scene;
  51154. /**
  51155. * Get the emitter of the lens flare system.
  51156. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51157. * @returns the emitter of the lens flare system
  51158. */
  51159. getEmitter(): any;
  51160. /**
  51161. * Set the emitter of the lens flare system.
  51162. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51163. * @param newEmitter Define the new emitter of the system
  51164. */
  51165. setEmitter(newEmitter: any): void;
  51166. /**
  51167. * Get the lens flare system emitter position.
  51168. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51169. * @returns the position
  51170. */
  51171. getEmitterPosition(): Vector3;
  51172. /**
  51173. * @hidden
  51174. */
  51175. computeEffectivePosition(globalViewport: Viewport): boolean;
  51176. /** @hidden */
  51177. _isVisible(): boolean;
  51178. /**
  51179. * @hidden
  51180. */
  51181. render(): boolean;
  51182. /**
  51183. * Dispose and release the lens flare with its associated resources.
  51184. */
  51185. dispose(): void;
  51186. /**
  51187. * Parse a lens flare system from a JSON repressentation
  51188. * @param parsedLensFlareSystem Define the JSON to parse
  51189. * @param scene Define the scene the parsed system should be instantiated in
  51190. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51191. * @returns the parsed system
  51192. */
  51193. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51194. /**
  51195. * Serialize the current Lens Flare System into a JSON representation.
  51196. * @returns the serialized JSON
  51197. */
  51198. serialize(): any;
  51199. }
  51200. }
  51201. declare module "babylonjs/LensFlares/lensFlare" {
  51202. import { Nullable } from "babylonjs/types";
  51203. import { Color3 } from "babylonjs/Maths/math.color";
  51204. import { Texture } from "babylonjs/Materials/Textures/texture";
  51205. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51206. /**
  51207. * This represents one of the lens effect in a `lensFlareSystem`.
  51208. * It controls one of the indiviual texture used in the effect.
  51209. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51210. */
  51211. export class LensFlare {
  51212. /**
  51213. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51214. */
  51215. size: number;
  51216. /**
  51217. * 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.
  51218. */
  51219. position: number;
  51220. /**
  51221. * Define the lens color.
  51222. */
  51223. color: Color3;
  51224. /**
  51225. * Define the lens texture.
  51226. */
  51227. texture: Nullable<Texture>;
  51228. /**
  51229. * Define the alpha mode to render this particular lens.
  51230. */
  51231. alphaMode: number;
  51232. private _system;
  51233. /**
  51234. * Creates a new Lens Flare.
  51235. * This represents one of the lens effect in a `lensFlareSystem`.
  51236. * It controls one of the indiviual texture used in the effect.
  51237. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51238. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51239. * @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.
  51240. * @param color Define the lens color
  51241. * @param imgUrl Define the lens texture url
  51242. * @param system Define the `lensFlareSystem` this flare is part of
  51243. * @returns The newly created Lens Flare
  51244. */
  51245. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51246. /**
  51247. * Instantiates a new Lens Flare.
  51248. * This represents one of the lens effect in a `lensFlareSystem`.
  51249. * It controls one of the indiviual texture used in the effect.
  51250. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51251. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51252. * @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.
  51253. * @param color Define the lens color
  51254. * @param imgUrl Define the lens texture url
  51255. * @param system Define the `lensFlareSystem` this flare is part of
  51256. */
  51257. constructor(
  51258. /**
  51259. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51260. */
  51261. size: number,
  51262. /**
  51263. * 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.
  51264. */
  51265. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51266. /**
  51267. * Dispose and release the lens flare with its associated resources.
  51268. */
  51269. dispose(): void;
  51270. }
  51271. }
  51272. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51273. import { Nullable } from "babylonjs/types";
  51274. import { Scene } from "babylonjs/scene";
  51275. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51276. import { AbstractScene } from "babylonjs/abstractScene";
  51277. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51278. module "babylonjs/abstractScene" {
  51279. interface AbstractScene {
  51280. /**
  51281. * The list of lens flare system added to the scene
  51282. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51283. */
  51284. lensFlareSystems: Array<LensFlareSystem>;
  51285. /**
  51286. * Removes the given lens flare system from this scene.
  51287. * @param toRemove The lens flare system to remove
  51288. * @returns The index of the removed lens flare system
  51289. */
  51290. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51291. /**
  51292. * Adds the given lens flare system to this scene
  51293. * @param newLensFlareSystem The lens flare system to add
  51294. */
  51295. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51296. /**
  51297. * Gets a lens flare system using its name
  51298. * @param name defines the name to look for
  51299. * @returns the lens flare system or null if not found
  51300. */
  51301. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51302. /**
  51303. * Gets a lens flare system using its id
  51304. * @param id defines the id to look for
  51305. * @returns the lens flare system or null if not found
  51306. */
  51307. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51308. }
  51309. }
  51310. /**
  51311. * Defines the lens flare scene component responsible to manage any lens flares
  51312. * in a given scene.
  51313. */
  51314. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51315. /**
  51316. * The component name helpfull to identify the component in the list of scene components.
  51317. */
  51318. readonly name: string;
  51319. /**
  51320. * The scene the component belongs to.
  51321. */
  51322. scene: Scene;
  51323. /**
  51324. * Creates a new instance of the component for the given scene
  51325. * @param scene Defines the scene to register the component in
  51326. */
  51327. constructor(scene: Scene);
  51328. /**
  51329. * Registers the component in a given scene
  51330. */
  51331. register(): void;
  51332. /**
  51333. * Rebuilds the elements related to this component in case of
  51334. * context lost for instance.
  51335. */
  51336. rebuild(): void;
  51337. /**
  51338. * Adds all the elements from the container to the scene
  51339. * @param container the container holding the elements
  51340. */
  51341. addFromContainer(container: AbstractScene): void;
  51342. /**
  51343. * Removes all the elements in the container from the scene
  51344. * @param container contains the elements to remove
  51345. * @param dispose if the removed element should be disposed (default: false)
  51346. */
  51347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51348. /**
  51349. * Serializes the component data to the specified json object
  51350. * @param serializationObject The object to serialize to
  51351. */
  51352. serialize(serializationObject: any): void;
  51353. /**
  51354. * Disposes the component and the associated ressources.
  51355. */
  51356. dispose(): void;
  51357. private _draw;
  51358. }
  51359. }
  51360. declare module "babylonjs/LensFlares/index" {
  51361. export * from "babylonjs/LensFlares/lensFlare";
  51362. export * from "babylonjs/LensFlares/lensFlareSystem";
  51363. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51364. }
  51365. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51366. import { Scene } from "babylonjs/scene";
  51367. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51368. import { AbstractScene } from "babylonjs/abstractScene";
  51369. /**
  51370. * Defines the shadow generator component responsible to manage any shadow generators
  51371. * in a given scene.
  51372. */
  51373. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51374. /**
  51375. * The component name helpfull to identify the component in the list of scene components.
  51376. */
  51377. readonly name: string;
  51378. /**
  51379. * The scene the component belongs to.
  51380. */
  51381. scene: Scene;
  51382. /**
  51383. * Creates a new instance of the component for the given scene
  51384. * @param scene Defines the scene to register the component in
  51385. */
  51386. constructor(scene: Scene);
  51387. /**
  51388. * Registers the component in a given scene
  51389. */
  51390. register(): void;
  51391. /**
  51392. * Rebuilds the elements related to this component in case of
  51393. * context lost for instance.
  51394. */
  51395. rebuild(): void;
  51396. /**
  51397. * Serializes the component data to the specified json object
  51398. * @param serializationObject The object to serialize to
  51399. */
  51400. serialize(serializationObject: any): void;
  51401. /**
  51402. * Adds all the elements from the container to the scene
  51403. * @param container the container holding the elements
  51404. */
  51405. addFromContainer(container: AbstractScene): void;
  51406. /**
  51407. * Removes all the elements in the container from the scene
  51408. * @param container contains the elements to remove
  51409. * @param dispose if the removed element should be disposed (default: false)
  51410. */
  51411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51412. /**
  51413. * Rebuilds the elements related to this component in case of
  51414. * context lost for instance.
  51415. */
  51416. dispose(): void;
  51417. private _gatherRenderTargets;
  51418. }
  51419. }
  51420. declare module "babylonjs/Lights/Shadows/index" {
  51421. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51422. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51423. }
  51424. declare module "babylonjs/Lights/pointLight" {
  51425. import { Scene } from "babylonjs/scene";
  51426. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51428. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51429. import { Effect } from "babylonjs/Materials/effect";
  51430. /**
  51431. * A point light is a light defined by an unique point in world space.
  51432. * The light is emitted in every direction from this point.
  51433. * A good example of a point light is a standard light bulb.
  51434. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51435. */
  51436. export class PointLight extends ShadowLight {
  51437. private _shadowAngle;
  51438. /**
  51439. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51440. * This specifies what angle the shadow will use to be created.
  51441. *
  51442. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51443. */
  51444. /**
  51445. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51446. * This specifies what angle the shadow will use to be created.
  51447. *
  51448. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51449. */
  51450. shadowAngle: number;
  51451. /**
  51452. * Gets the direction if it has been set.
  51453. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51454. */
  51455. /**
  51456. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51457. */
  51458. direction: Vector3;
  51459. /**
  51460. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51461. * A PointLight emits the light in every direction.
  51462. * It can cast shadows.
  51463. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51464. * ```javascript
  51465. * var pointLight = new PointLight("pl", camera.position, scene);
  51466. * ```
  51467. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51468. * @param name The light friendly name
  51469. * @param position The position of the point light in the scene
  51470. * @param scene The scene the lights belongs to
  51471. */
  51472. constructor(name: string, position: Vector3, scene: Scene);
  51473. /**
  51474. * Returns the string "PointLight"
  51475. * @returns the class name
  51476. */
  51477. getClassName(): string;
  51478. /**
  51479. * Returns the integer 0.
  51480. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51481. */
  51482. getTypeID(): number;
  51483. /**
  51484. * Specifies wether or not the shadowmap should be a cube texture.
  51485. * @returns true if the shadowmap needs to be a cube texture.
  51486. */
  51487. needCube(): boolean;
  51488. /**
  51489. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51490. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51491. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51492. */
  51493. getShadowDirection(faceIndex?: number): Vector3;
  51494. /**
  51495. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51496. * - fov = PI / 2
  51497. * - aspect ratio : 1.0
  51498. * - z-near and far equal to the active camera minZ and maxZ.
  51499. * Returns the PointLight.
  51500. */
  51501. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51502. protected _buildUniformLayout(): void;
  51503. /**
  51504. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51505. * @param effect The effect to update
  51506. * @param lightIndex The index of the light in the effect to update
  51507. * @returns The point light
  51508. */
  51509. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51510. /**
  51511. * Prepares the list of defines specific to the light type.
  51512. * @param defines the list of defines
  51513. * @param lightIndex defines the index of the light for the effect
  51514. */
  51515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51516. }
  51517. }
  51518. declare module "babylonjs/Lights/index" {
  51519. export * from "babylonjs/Lights/light";
  51520. export * from "babylonjs/Lights/shadowLight";
  51521. export * from "babylonjs/Lights/Shadows/index";
  51522. export * from "babylonjs/Lights/directionalLight";
  51523. export * from "babylonjs/Lights/hemisphericLight";
  51524. export * from "babylonjs/Lights/pointLight";
  51525. export * from "babylonjs/Lights/spotLight";
  51526. }
  51527. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51528. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51529. /**
  51530. * Header information of HDR texture files.
  51531. */
  51532. export interface HDRInfo {
  51533. /**
  51534. * The height of the texture in pixels.
  51535. */
  51536. height: number;
  51537. /**
  51538. * The width of the texture in pixels.
  51539. */
  51540. width: number;
  51541. /**
  51542. * The index of the beginning of the data in the binary file.
  51543. */
  51544. dataPosition: number;
  51545. }
  51546. /**
  51547. * This groups tools to convert HDR texture to native colors array.
  51548. */
  51549. export class HDRTools {
  51550. private static Ldexp;
  51551. private static Rgbe2float;
  51552. private static readStringLine;
  51553. /**
  51554. * Reads header information from an RGBE texture stored in a native array.
  51555. * More information on this format are available here:
  51556. * https://en.wikipedia.org/wiki/RGBE_image_format
  51557. *
  51558. * @param uint8array The binary file stored in native array.
  51559. * @return The header information.
  51560. */
  51561. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51562. /**
  51563. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51564. * This RGBE texture needs to store the information as a panorama.
  51565. *
  51566. * More information on this format are available here:
  51567. * https://en.wikipedia.org/wiki/RGBE_image_format
  51568. *
  51569. * @param buffer The binary file stored in an array buffer.
  51570. * @param size The expected size of the extracted cubemap.
  51571. * @return The Cube Map information.
  51572. */
  51573. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51574. /**
  51575. * Returns the pixels data extracted from an RGBE texture.
  51576. * This pixels will be stored left to right up to down in the R G B order in one array.
  51577. *
  51578. * More information on this format are available here:
  51579. * https://en.wikipedia.org/wiki/RGBE_image_format
  51580. *
  51581. * @param uint8array The binary file stored in an array buffer.
  51582. * @param hdrInfo The header information of the file.
  51583. * @return The pixels data in RGB right to left up to down order.
  51584. */
  51585. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51586. private static RGBE_ReadPixels_RLE;
  51587. }
  51588. }
  51589. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51590. import { Nullable } from "babylonjs/types";
  51591. import { Scene } from "babylonjs/scene";
  51592. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51594. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51595. /**
  51596. * This represents a texture coming from an HDR input.
  51597. *
  51598. * The only supported format is currently panorama picture stored in RGBE format.
  51599. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51600. */
  51601. export class HDRCubeTexture extends BaseTexture {
  51602. private static _facesMapping;
  51603. private _generateHarmonics;
  51604. private _noMipmap;
  51605. private _textureMatrix;
  51606. private _size;
  51607. private _onLoad;
  51608. private _onError;
  51609. /**
  51610. * The texture URL.
  51611. */
  51612. url: string;
  51613. /**
  51614. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51615. */
  51616. coordinatesMode: number;
  51617. protected _isBlocking: boolean;
  51618. /**
  51619. * Sets wether or not the texture is blocking during loading.
  51620. */
  51621. /**
  51622. * Gets wether or not the texture is blocking during loading.
  51623. */
  51624. isBlocking: boolean;
  51625. protected _rotationY: number;
  51626. /**
  51627. * Sets texture matrix rotation angle around Y axis in radians.
  51628. */
  51629. /**
  51630. * Gets texture matrix rotation angle around Y axis radians.
  51631. */
  51632. rotationY: number;
  51633. /**
  51634. * Gets or sets the center of the bounding box associated with the cube texture
  51635. * It must define where the camera used to render the texture was set
  51636. */
  51637. boundingBoxPosition: Vector3;
  51638. private _boundingBoxSize;
  51639. /**
  51640. * Gets or sets the size of the bounding box associated with the cube texture
  51641. * When defined, the cubemap will switch to local mode
  51642. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51643. * @example https://www.babylonjs-playground.com/#RNASML
  51644. */
  51645. boundingBoxSize: Vector3;
  51646. /**
  51647. * Instantiates an HDRTexture from the following parameters.
  51648. *
  51649. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51650. * @param scene The scene the texture will be used in
  51651. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51652. * @param noMipmap Forces to not generate the mipmap if true
  51653. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51654. * @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)
  51655. * @param reserved Reserved flag for internal use.
  51656. */
  51657. 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>);
  51658. /**
  51659. * Get the current class name of the texture useful for serialization or dynamic coding.
  51660. * @returns "HDRCubeTexture"
  51661. */
  51662. getClassName(): string;
  51663. /**
  51664. * Occurs when the file is raw .hdr file.
  51665. */
  51666. private loadTexture;
  51667. clone(): HDRCubeTexture;
  51668. delayLoad(): void;
  51669. /**
  51670. * Get the texture reflection matrix used to rotate/transform the reflection.
  51671. * @returns the reflection matrix
  51672. */
  51673. getReflectionTextureMatrix(): Matrix;
  51674. /**
  51675. * Set the texture reflection matrix used to rotate/transform the reflection.
  51676. * @param value Define the reflection matrix to set
  51677. */
  51678. setReflectionTextureMatrix(value: Matrix): void;
  51679. /**
  51680. * Parses a JSON representation of an HDR Texture in order to create the texture
  51681. * @param parsedTexture Define the JSON representation
  51682. * @param scene Define the scene the texture should be created in
  51683. * @param rootUrl Define the root url in case we need to load relative dependencies
  51684. * @returns the newly created texture after parsing
  51685. */
  51686. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51687. serialize(): any;
  51688. }
  51689. }
  51690. declare module "babylonjs/Physics/physicsEngine" {
  51691. import { Nullable } from "babylonjs/types";
  51692. import { Vector3 } from "babylonjs/Maths/math.vector";
  51693. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51694. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51695. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51696. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51697. /**
  51698. * Class used to control physics engine
  51699. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51700. */
  51701. export class PhysicsEngine implements IPhysicsEngine {
  51702. private _physicsPlugin;
  51703. /**
  51704. * Global value used to control the smallest number supported by the simulation
  51705. */
  51706. static Epsilon: number;
  51707. private _impostors;
  51708. private _joints;
  51709. /**
  51710. * Gets the gravity vector used by the simulation
  51711. */
  51712. gravity: Vector3;
  51713. /**
  51714. * Factory used to create the default physics plugin.
  51715. * @returns The default physics plugin
  51716. */
  51717. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51718. /**
  51719. * Creates a new Physics Engine
  51720. * @param gravity defines the gravity vector used by the simulation
  51721. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51722. */
  51723. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51724. /**
  51725. * Sets the gravity vector used by the simulation
  51726. * @param gravity defines the gravity vector to use
  51727. */
  51728. setGravity(gravity: Vector3): void;
  51729. /**
  51730. * Set the time step of the physics engine.
  51731. * Default is 1/60.
  51732. * To slow it down, enter 1/600 for example.
  51733. * To speed it up, 1/30
  51734. * @param newTimeStep defines the new timestep to apply to this world.
  51735. */
  51736. setTimeStep(newTimeStep?: number): void;
  51737. /**
  51738. * Get the time step of the physics engine.
  51739. * @returns the current time step
  51740. */
  51741. getTimeStep(): number;
  51742. /**
  51743. * Release all resources
  51744. */
  51745. dispose(): void;
  51746. /**
  51747. * Gets the name of the current physics plugin
  51748. * @returns the name of the plugin
  51749. */
  51750. getPhysicsPluginName(): string;
  51751. /**
  51752. * Adding a new impostor for the impostor tracking.
  51753. * This will be done by the impostor itself.
  51754. * @param impostor the impostor to add
  51755. */
  51756. addImpostor(impostor: PhysicsImpostor): void;
  51757. /**
  51758. * Remove an impostor from the engine.
  51759. * This impostor and its mesh will not longer be updated by the physics engine.
  51760. * @param impostor the impostor to remove
  51761. */
  51762. removeImpostor(impostor: PhysicsImpostor): void;
  51763. /**
  51764. * Add a joint to the physics engine
  51765. * @param mainImpostor defines the main impostor to which the joint is added.
  51766. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51767. * @param joint defines the joint that will connect both impostors.
  51768. */
  51769. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51770. /**
  51771. * Removes a joint from the simulation
  51772. * @param mainImpostor defines the impostor used with the joint
  51773. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51774. * @param joint defines the joint to remove
  51775. */
  51776. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51777. /**
  51778. * Called by the scene. No need to call it.
  51779. * @param delta defines the timespam between frames
  51780. */
  51781. _step(delta: number): void;
  51782. /**
  51783. * Gets the current plugin used to run the simulation
  51784. * @returns current plugin
  51785. */
  51786. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51787. /**
  51788. * Gets the list of physic impostors
  51789. * @returns an array of PhysicsImpostor
  51790. */
  51791. getImpostors(): Array<PhysicsImpostor>;
  51792. /**
  51793. * Gets the impostor for a physics enabled object
  51794. * @param object defines the object impersonated by the impostor
  51795. * @returns the PhysicsImpostor or null if not found
  51796. */
  51797. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51798. /**
  51799. * Gets the impostor for a physics body object
  51800. * @param body defines physics body used by the impostor
  51801. * @returns the PhysicsImpostor or null if not found
  51802. */
  51803. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51804. /**
  51805. * Does a raycast in the physics world
  51806. * @param from when should the ray start?
  51807. * @param to when should the ray end?
  51808. * @returns PhysicsRaycastResult
  51809. */
  51810. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51811. }
  51812. }
  51813. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51814. import { Nullable } from "babylonjs/types";
  51815. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51817. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51818. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51819. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51820. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51821. /** @hidden */
  51822. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51823. private _useDeltaForWorldStep;
  51824. world: any;
  51825. name: string;
  51826. private _physicsMaterials;
  51827. private _fixedTimeStep;
  51828. private _cannonRaycastResult;
  51829. private _raycastResult;
  51830. private _physicsBodysToRemoveAfterStep;
  51831. BJSCANNON: any;
  51832. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51833. setGravity(gravity: Vector3): void;
  51834. setTimeStep(timeStep: number): void;
  51835. getTimeStep(): number;
  51836. executeStep(delta: number): void;
  51837. private _removeMarkedPhysicsBodiesFromWorld;
  51838. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51839. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51841. private _processChildMeshes;
  51842. removePhysicsBody(impostor: PhysicsImpostor): void;
  51843. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51844. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51845. private _addMaterial;
  51846. private _checkWithEpsilon;
  51847. private _createShape;
  51848. private _createHeightmap;
  51849. private _minus90X;
  51850. private _plus90X;
  51851. private _tmpPosition;
  51852. private _tmpDeltaPosition;
  51853. private _tmpUnityRotation;
  51854. private _updatePhysicsBodyTransformation;
  51855. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51856. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51857. isSupported(): boolean;
  51858. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51859. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51860. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51862. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51863. getBodyMass(impostor: PhysicsImpostor): number;
  51864. getBodyFriction(impostor: PhysicsImpostor): number;
  51865. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51866. getBodyRestitution(impostor: PhysicsImpostor): number;
  51867. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51868. sleepBody(impostor: PhysicsImpostor): void;
  51869. wakeUpBody(impostor: PhysicsImpostor): void;
  51870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51871. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51873. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51874. getRadius(impostor: PhysicsImpostor): number;
  51875. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51876. dispose(): void;
  51877. private _extendNamespace;
  51878. /**
  51879. * Does a raycast in the physics world
  51880. * @param from when should the ray start?
  51881. * @param to when should the ray end?
  51882. * @returns PhysicsRaycastResult
  51883. */
  51884. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51885. }
  51886. }
  51887. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51888. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51889. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51890. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51892. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51893. import { Nullable } from "babylonjs/types";
  51894. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51895. /** @hidden */
  51896. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51897. world: any;
  51898. name: string;
  51899. BJSOIMO: any;
  51900. private _raycastResult;
  51901. constructor(iterations?: number, oimoInjection?: any);
  51902. setGravity(gravity: Vector3): void;
  51903. setTimeStep(timeStep: number): void;
  51904. getTimeStep(): number;
  51905. private _tmpImpostorsArray;
  51906. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51908. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51909. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51910. private _tmpPositionVector;
  51911. removePhysicsBody(impostor: PhysicsImpostor): void;
  51912. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51913. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51914. isSupported(): boolean;
  51915. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51916. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51917. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51918. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51919. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51920. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51921. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51922. getBodyMass(impostor: PhysicsImpostor): number;
  51923. getBodyFriction(impostor: PhysicsImpostor): number;
  51924. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51925. getBodyRestitution(impostor: PhysicsImpostor): number;
  51926. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51927. sleepBody(impostor: PhysicsImpostor): void;
  51928. wakeUpBody(impostor: PhysicsImpostor): void;
  51929. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51930. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51931. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51932. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51933. getRadius(impostor: PhysicsImpostor): number;
  51934. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51935. dispose(): void;
  51936. /**
  51937. * Does a raycast in the physics world
  51938. * @param from when should the ray start?
  51939. * @param to when should the ray end?
  51940. * @returns PhysicsRaycastResult
  51941. */
  51942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51943. }
  51944. }
  51945. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51946. import { Nullable } from "babylonjs/types";
  51947. import { Scene } from "babylonjs/scene";
  51948. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51949. import { Color4 } from "babylonjs/Maths/math.color";
  51950. import { Mesh } from "babylonjs/Meshes/mesh";
  51951. /**
  51952. * Class containing static functions to help procedurally build meshes
  51953. */
  51954. export class RibbonBuilder {
  51955. /**
  51956. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51957. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51958. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51959. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51960. * * 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
  51961. * * 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
  51962. * * 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
  51963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51965. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51966. * * 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
  51967. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51968. * * 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
  51969. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51971. * @param name defines the name of the mesh
  51972. * @param options defines the options used to create the mesh
  51973. * @param scene defines the hosting scene
  51974. * @returns the ribbon mesh
  51975. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51976. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51977. */
  51978. static CreateRibbon(name: string, options: {
  51979. pathArray: Vector3[][];
  51980. closeArray?: boolean;
  51981. closePath?: boolean;
  51982. offset?: number;
  51983. updatable?: boolean;
  51984. sideOrientation?: number;
  51985. frontUVs?: Vector4;
  51986. backUVs?: Vector4;
  51987. instance?: Mesh;
  51988. invertUV?: boolean;
  51989. uvs?: Vector2[];
  51990. colors?: Color4[];
  51991. }, scene?: Nullable<Scene>): Mesh;
  51992. }
  51993. }
  51994. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51995. import { Nullable } from "babylonjs/types";
  51996. import { Scene } from "babylonjs/scene";
  51997. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  51998. import { Mesh } from "babylonjs/Meshes/mesh";
  51999. /**
  52000. * Class containing static functions to help procedurally build meshes
  52001. */
  52002. export class ShapeBuilder {
  52003. /**
  52004. * 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.
  52005. * * 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.
  52006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52007. * * 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.
  52008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52009. * * 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
  52010. * * 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
  52011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52016. * @param name defines the name of the mesh
  52017. * @param options defines the options used to create the mesh
  52018. * @param scene defines the hosting scene
  52019. * @returns the extruded shape mesh
  52020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52022. */
  52023. static ExtrudeShape(name: string, options: {
  52024. shape: Vector3[];
  52025. path: Vector3[];
  52026. scale?: number;
  52027. rotation?: number;
  52028. cap?: number;
  52029. updatable?: boolean;
  52030. sideOrientation?: number;
  52031. frontUVs?: Vector4;
  52032. backUVs?: Vector4;
  52033. instance?: Mesh;
  52034. invertUV?: boolean;
  52035. }, scene?: Nullable<Scene>): Mesh;
  52036. /**
  52037. * Creates an custom extruded shape mesh.
  52038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52039. * * 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.
  52040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52041. * * 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
  52042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52043. * * 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
  52044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52047. * * 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
  52048. * * 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
  52049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52054. * @param name defines the name of the mesh
  52055. * @param options defines the options used to create the mesh
  52056. * @param scene defines the hosting scene
  52057. * @returns the custom extruded shape mesh
  52058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52061. */
  52062. static ExtrudeShapeCustom(name: string, options: {
  52063. shape: Vector3[];
  52064. path: Vector3[];
  52065. scaleFunction?: any;
  52066. rotationFunction?: any;
  52067. ribbonCloseArray?: boolean;
  52068. ribbonClosePath?: boolean;
  52069. cap?: number;
  52070. updatable?: boolean;
  52071. sideOrientation?: number;
  52072. frontUVs?: Vector4;
  52073. backUVs?: Vector4;
  52074. instance?: Mesh;
  52075. invertUV?: boolean;
  52076. }, scene?: Nullable<Scene>): Mesh;
  52077. private static _ExtrudeShapeGeneric;
  52078. }
  52079. }
  52080. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52081. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52082. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52083. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52084. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52085. import { Nullable } from "babylonjs/types";
  52086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52087. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52088. /**
  52089. * AmmoJS Physics plugin
  52090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52091. * @see https://github.com/kripken/ammo.js/
  52092. */
  52093. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52094. private _useDeltaForWorldStep;
  52095. /**
  52096. * Reference to the Ammo library
  52097. */
  52098. bjsAMMO: any;
  52099. /**
  52100. * Created ammoJS world which physics bodies are added to
  52101. */
  52102. world: any;
  52103. /**
  52104. * Name of the plugin
  52105. */
  52106. name: string;
  52107. private _timeStep;
  52108. private _fixedTimeStep;
  52109. private _maxSteps;
  52110. private _tmpQuaternion;
  52111. private _tmpAmmoTransform;
  52112. private _tmpAmmoQuaternion;
  52113. private _tmpAmmoConcreteContactResultCallback;
  52114. private _collisionConfiguration;
  52115. private _dispatcher;
  52116. private _overlappingPairCache;
  52117. private _solver;
  52118. private _softBodySolver;
  52119. private _tmpAmmoVectorA;
  52120. private _tmpAmmoVectorB;
  52121. private _tmpAmmoVectorC;
  52122. private _tmpAmmoVectorD;
  52123. private _tmpContactCallbackResult;
  52124. private _tmpAmmoVectorRCA;
  52125. private _tmpAmmoVectorRCB;
  52126. private _raycastResult;
  52127. private static readonly DISABLE_COLLISION_FLAG;
  52128. private static readonly KINEMATIC_FLAG;
  52129. private static readonly DISABLE_DEACTIVATION_FLAG;
  52130. /**
  52131. * Initializes the ammoJS plugin
  52132. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52133. * @param ammoInjection can be used to inject your own ammo reference
  52134. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52135. */
  52136. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52137. /**
  52138. * Sets the gravity of the physics world (m/(s^2))
  52139. * @param gravity Gravity to set
  52140. */
  52141. setGravity(gravity: Vector3): void;
  52142. /**
  52143. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52144. * @param timeStep timestep to use in seconds
  52145. */
  52146. setTimeStep(timeStep: number): void;
  52147. /**
  52148. * 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)
  52149. * @param fixedTimeStep fixedTimeStep to use in seconds
  52150. */
  52151. setFixedTimeStep(fixedTimeStep: number): void;
  52152. /**
  52153. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52154. * @param maxSteps the maximum number of steps by the physics engine per frame
  52155. */
  52156. setMaxSteps(maxSteps: number): void;
  52157. /**
  52158. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52159. * @returns the current timestep in seconds
  52160. */
  52161. getTimeStep(): number;
  52162. private _isImpostorInContact;
  52163. private _isImpostorPairInContact;
  52164. private _stepSimulation;
  52165. /**
  52166. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52167. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52168. * After the step the babylon meshes are set to the position of the physics imposters
  52169. * @param delta amount of time to step forward
  52170. * @param impostors array of imposters to update before/after the step
  52171. */
  52172. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52173. /**
  52174. * Update babylon mesh to match physics world object
  52175. * @param impostor imposter to match
  52176. */
  52177. private _afterSoftStep;
  52178. /**
  52179. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52180. * @param impostor imposter to match
  52181. */
  52182. private _ropeStep;
  52183. /**
  52184. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52185. * @param impostor imposter to match
  52186. */
  52187. private _softbodyOrClothStep;
  52188. private _tmpVector;
  52189. private _tmpMatrix;
  52190. /**
  52191. * Applies an impulse on the imposter
  52192. * @param impostor imposter to apply impulse to
  52193. * @param force amount of force to be applied to the imposter
  52194. * @param contactPoint the location to apply the impulse on the imposter
  52195. */
  52196. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52197. /**
  52198. * Applies a force on the imposter
  52199. * @param impostor imposter to apply force
  52200. * @param force amount of force to be applied to the imposter
  52201. * @param contactPoint the location to apply the force on the imposter
  52202. */
  52203. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52204. /**
  52205. * Creates a physics body using the plugin
  52206. * @param impostor the imposter to create the physics body on
  52207. */
  52208. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52209. /**
  52210. * Removes the physics body from the imposter and disposes of the body's memory
  52211. * @param impostor imposter to remove the physics body from
  52212. */
  52213. removePhysicsBody(impostor: PhysicsImpostor): void;
  52214. /**
  52215. * Generates a joint
  52216. * @param impostorJoint the imposter joint to create the joint with
  52217. */
  52218. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52219. /**
  52220. * Removes a joint
  52221. * @param impostorJoint the imposter joint to remove the joint from
  52222. */
  52223. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52224. private _addMeshVerts;
  52225. /**
  52226. * Initialise the soft body vertices to match its object's (mesh) vertices
  52227. * Softbody vertices (nodes) are in world space and to match this
  52228. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52229. * @param impostor to create the softbody for
  52230. */
  52231. private _softVertexData;
  52232. /**
  52233. * Create an impostor's soft body
  52234. * @param impostor to create the softbody for
  52235. */
  52236. private _createSoftbody;
  52237. /**
  52238. * Create cloth for an impostor
  52239. * @param impostor to create the softbody for
  52240. */
  52241. private _createCloth;
  52242. /**
  52243. * Create rope for an impostor
  52244. * @param impostor to create the softbody for
  52245. */
  52246. private _createRope;
  52247. private _addHullVerts;
  52248. private _createShape;
  52249. /**
  52250. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52251. * @param impostor imposter containing the physics body and babylon object
  52252. */
  52253. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52254. /**
  52255. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52256. * @param impostor imposter containing the physics body and babylon object
  52257. * @param newPosition new position
  52258. * @param newRotation new rotation
  52259. */
  52260. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52261. /**
  52262. * If this plugin is supported
  52263. * @returns true if its supported
  52264. */
  52265. isSupported(): boolean;
  52266. /**
  52267. * Sets the linear velocity of the physics body
  52268. * @param impostor imposter to set the velocity on
  52269. * @param velocity velocity to set
  52270. */
  52271. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52272. /**
  52273. * Sets the angular velocity of the physics body
  52274. * @param impostor imposter to set the velocity on
  52275. * @param velocity velocity to set
  52276. */
  52277. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52278. /**
  52279. * gets the linear velocity
  52280. * @param impostor imposter to get linear velocity from
  52281. * @returns linear velocity
  52282. */
  52283. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52284. /**
  52285. * gets the angular velocity
  52286. * @param impostor imposter to get angular velocity from
  52287. * @returns angular velocity
  52288. */
  52289. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52290. /**
  52291. * Sets the mass of physics body
  52292. * @param impostor imposter to set the mass on
  52293. * @param mass mass to set
  52294. */
  52295. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52296. /**
  52297. * Gets the mass of the physics body
  52298. * @param impostor imposter to get the mass from
  52299. * @returns mass
  52300. */
  52301. getBodyMass(impostor: PhysicsImpostor): number;
  52302. /**
  52303. * Gets friction of the impostor
  52304. * @param impostor impostor to get friction from
  52305. * @returns friction value
  52306. */
  52307. getBodyFriction(impostor: PhysicsImpostor): number;
  52308. /**
  52309. * Sets friction of the impostor
  52310. * @param impostor impostor to set friction on
  52311. * @param friction friction value
  52312. */
  52313. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52314. /**
  52315. * Gets restitution of the impostor
  52316. * @param impostor impostor to get restitution from
  52317. * @returns restitution value
  52318. */
  52319. getBodyRestitution(impostor: PhysicsImpostor): number;
  52320. /**
  52321. * Sets resitution of the impostor
  52322. * @param impostor impostor to set resitution on
  52323. * @param restitution resitution value
  52324. */
  52325. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52326. /**
  52327. * Gets pressure inside the impostor
  52328. * @param impostor impostor to get pressure from
  52329. * @returns pressure value
  52330. */
  52331. getBodyPressure(impostor: PhysicsImpostor): number;
  52332. /**
  52333. * Sets pressure inside a soft body impostor
  52334. * Cloth and rope must remain 0 pressure
  52335. * @param impostor impostor to set pressure on
  52336. * @param pressure pressure value
  52337. */
  52338. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52339. /**
  52340. * Gets stiffness of the impostor
  52341. * @param impostor impostor to get stiffness from
  52342. * @returns pressure value
  52343. */
  52344. getBodyStiffness(impostor: PhysicsImpostor): number;
  52345. /**
  52346. * Sets stiffness of the impostor
  52347. * @param impostor impostor to set stiffness on
  52348. * @param stiffness stiffness value from 0 to 1
  52349. */
  52350. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52351. /**
  52352. * Gets velocityIterations of the impostor
  52353. * @param impostor impostor to get velocity iterations from
  52354. * @returns velocityIterations value
  52355. */
  52356. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52357. /**
  52358. * Sets velocityIterations of the impostor
  52359. * @param impostor impostor to set velocity iterations on
  52360. * @param velocityIterations velocityIterations value
  52361. */
  52362. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52363. /**
  52364. * Gets positionIterations of the impostor
  52365. * @param impostor impostor to get position iterations from
  52366. * @returns positionIterations value
  52367. */
  52368. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52369. /**
  52370. * Sets positionIterations of the impostor
  52371. * @param impostor impostor to set position on
  52372. * @param positionIterations positionIterations value
  52373. */
  52374. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52375. /**
  52376. * Append an anchor to a cloth object
  52377. * @param impostor is the cloth impostor to add anchor to
  52378. * @param otherImpostor is the rigid impostor to anchor to
  52379. * @param width ratio across width from 0 to 1
  52380. * @param height ratio up height from 0 to 1
  52381. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52382. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52383. */
  52384. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52385. /**
  52386. * Append an hook to a rope object
  52387. * @param impostor is the rope impostor to add hook to
  52388. * @param otherImpostor is the rigid impostor to hook to
  52389. * @param length ratio along the rope from 0 to 1
  52390. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52391. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52392. */
  52393. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52394. /**
  52395. * Sleeps the physics body and stops it from being active
  52396. * @param impostor impostor to sleep
  52397. */
  52398. sleepBody(impostor: PhysicsImpostor): void;
  52399. /**
  52400. * Activates the physics body
  52401. * @param impostor impostor to activate
  52402. */
  52403. wakeUpBody(impostor: PhysicsImpostor): void;
  52404. /**
  52405. * Updates the distance parameters of the joint
  52406. * @param joint joint to update
  52407. * @param maxDistance maximum distance of the joint
  52408. * @param minDistance minimum distance of the joint
  52409. */
  52410. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52411. /**
  52412. * Sets a motor on the joint
  52413. * @param joint joint to set motor on
  52414. * @param speed speed of the motor
  52415. * @param maxForce maximum force of the motor
  52416. * @param motorIndex index of the motor
  52417. */
  52418. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52419. /**
  52420. * Sets the motors limit
  52421. * @param joint joint to set limit on
  52422. * @param upperLimit upper limit
  52423. * @param lowerLimit lower limit
  52424. */
  52425. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52426. /**
  52427. * Syncs the position and rotation of a mesh with the impostor
  52428. * @param mesh mesh to sync
  52429. * @param impostor impostor to update the mesh with
  52430. */
  52431. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52432. /**
  52433. * Gets the radius of the impostor
  52434. * @param impostor impostor to get radius from
  52435. * @returns the radius
  52436. */
  52437. getRadius(impostor: PhysicsImpostor): number;
  52438. /**
  52439. * Gets the box size of the impostor
  52440. * @param impostor impostor to get box size from
  52441. * @param result the resulting box size
  52442. */
  52443. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52444. /**
  52445. * Disposes of the impostor
  52446. */
  52447. dispose(): void;
  52448. /**
  52449. * Does a raycast in the physics world
  52450. * @param from when should the ray start?
  52451. * @param to when should the ray end?
  52452. * @returns PhysicsRaycastResult
  52453. */
  52454. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52455. }
  52456. }
  52457. declare module "babylonjs/Probes/reflectionProbe" {
  52458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52459. import { Vector3 } from "babylonjs/Maths/math.vector";
  52460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52461. import { Nullable } from "babylonjs/types";
  52462. import { Scene } from "babylonjs/scene";
  52463. module "babylonjs/abstractScene" {
  52464. interface AbstractScene {
  52465. /**
  52466. * The list of reflection probes added to the scene
  52467. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52468. */
  52469. reflectionProbes: Array<ReflectionProbe>;
  52470. /**
  52471. * Removes the given reflection probe from this scene.
  52472. * @param toRemove The reflection probe to remove
  52473. * @returns The index of the removed reflection probe
  52474. */
  52475. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52476. /**
  52477. * Adds the given reflection probe to this scene.
  52478. * @param newReflectionProbe The reflection probe to add
  52479. */
  52480. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52481. }
  52482. }
  52483. /**
  52484. * Class used to generate realtime reflection / refraction cube textures
  52485. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52486. */
  52487. export class ReflectionProbe {
  52488. /** defines the name of the probe */
  52489. name: string;
  52490. private _scene;
  52491. private _renderTargetTexture;
  52492. private _projectionMatrix;
  52493. private _viewMatrix;
  52494. private _target;
  52495. private _add;
  52496. private _attachedMesh;
  52497. private _invertYAxis;
  52498. /** Gets or sets probe position (center of the cube map) */
  52499. position: Vector3;
  52500. /**
  52501. * Creates a new reflection probe
  52502. * @param name defines the name of the probe
  52503. * @param size defines the texture resolution (for each face)
  52504. * @param scene defines the hosting scene
  52505. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52506. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52507. */
  52508. constructor(
  52509. /** defines the name of the probe */
  52510. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52511. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52512. samples: number;
  52513. /** Gets or sets the refresh rate to use (on every frame by default) */
  52514. refreshRate: number;
  52515. /**
  52516. * Gets the hosting scene
  52517. * @returns a Scene
  52518. */
  52519. getScene(): Scene;
  52520. /** Gets the internal CubeTexture used to render to */
  52521. readonly cubeTexture: RenderTargetTexture;
  52522. /** Gets the list of meshes to render */
  52523. readonly renderList: Nullable<AbstractMesh[]>;
  52524. /**
  52525. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52526. * @param mesh defines the mesh to attach to
  52527. */
  52528. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52529. /**
  52530. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52531. * @param renderingGroupId The rendering group id corresponding to its index
  52532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52533. */
  52534. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52535. /**
  52536. * Clean all associated resources
  52537. */
  52538. dispose(): void;
  52539. /**
  52540. * Converts the reflection probe information to a readable string for debug purpose.
  52541. * @param fullDetails Supports for multiple levels of logging within scene loading
  52542. * @returns the human readable reflection probe info
  52543. */
  52544. toString(fullDetails?: boolean): string;
  52545. /**
  52546. * Get the class name of the relfection probe.
  52547. * @returns "ReflectionProbe"
  52548. */
  52549. getClassName(): string;
  52550. /**
  52551. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52552. * @returns The JSON representation of the texture
  52553. */
  52554. serialize(): any;
  52555. /**
  52556. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52557. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52558. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52559. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52560. * @returns The parsed reflection probe if successful
  52561. */
  52562. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52563. }
  52564. }
  52565. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52566. /** @hidden */
  52567. export var _BabylonLoaderRegistered: boolean;
  52568. }
  52569. declare module "babylonjs/Loading/Plugins/index" {
  52570. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52571. }
  52572. declare module "babylonjs/Loading/index" {
  52573. export * from "babylonjs/Loading/loadingScreen";
  52574. export * from "babylonjs/Loading/Plugins/index";
  52575. export * from "babylonjs/Loading/sceneLoader";
  52576. export * from "babylonjs/Loading/sceneLoaderFlags";
  52577. }
  52578. declare module "babylonjs/Materials/Background/index" {
  52579. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52580. }
  52581. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52582. import { Scene } from "babylonjs/scene";
  52583. import { Color3 } from "babylonjs/Maths/math.color";
  52584. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52585. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52586. /**
  52587. * The Physically based simple base material of BJS.
  52588. *
  52589. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52590. * It is used as the base class for both the specGloss and metalRough conventions.
  52591. */
  52592. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52593. /**
  52594. * Number of Simultaneous lights allowed on the material.
  52595. */
  52596. maxSimultaneousLights: number;
  52597. /**
  52598. * If sets to true, disables all the lights affecting the material.
  52599. */
  52600. disableLighting: boolean;
  52601. /**
  52602. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52603. */
  52604. environmentTexture: BaseTexture;
  52605. /**
  52606. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52607. */
  52608. invertNormalMapX: boolean;
  52609. /**
  52610. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52611. */
  52612. invertNormalMapY: boolean;
  52613. /**
  52614. * Normal map used in the model.
  52615. */
  52616. normalTexture: BaseTexture;
  52617. /**
  52618. * Emissivie color used to self-illuminate the model.
  52619. */
  52620. emissiveColor: Color3;
  52621. /**
  52622. * Emissivie texture used to self-illuminate the model.
  52623. */
  52624. emissiveTexture: BaseTexture;
  52625. /**
  52626. * Occlusion Channel Strenght.
  52627. */
  52628. occlusionStrength: number;
  52629. /**
  52630. * Occlusion Texture of the material (adding extra occlusion effects).
  52631. */
  52632. occlusionTexture: BaseTexture;
  52633. /**
  52634. * Defines the alpha limits in alpha test mode.
  52635. */
  52636. alphaCutOff: number;
  52637. /**
  52638. * Gets the current double sided mode.
  52639. */
  52640. /**
  52641. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52642. */
  52643. doubleSided: boolean;
  52644. /**
  52645. * Stores the pre-calculated light information of a mesh in a texture.
  52646. */
  52647. lightmapTexture: BaseTexture;
  52648. /**
  52649. * If true, the light map contains occlusion information instead of lighting info.
  52650. */
  52651. useLightmapAsShadowmap: boolean;
  52652. /**
  52653. * Instantiates a new PBRMaterial instance.
  52654. *
  52655. * @param name The material name
  52656. * @param scene The scene the material will be use in.
  52657. */
  52658. constructor(name: string, scene: Scene);
  52659. getClassName(): string;
  52660. }
  52661. }
  52662. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52663. import { Scene } from "babylonjs/scene";
  52664. import { Color3 } from "babylonjs/Maths/math.color";
  52665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52666. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52667. /**
  52668. * The PBR material of BJS following the metal roughness convention.
  52669. *
  52670. * This fits to the PBR convention in the GLTF definition:
  52671. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52672. */
  52673. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52674. /**
  52675. * The base color has two different interpretations depending on the value of metalness.
  52676. * When the material is a metal, the base color is the specific measured reflectance value
  52677. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52678. * of the material.
  52679. */
  52680. baseColor: Color3;
  52681. /**
  52682. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52683. * well as opacity information in the alpha channel.
  52684. */
  52685. baseTexture: BaseTexture;
  52686. /**
  52687. * Specifies the metallic scalar value of the material.
  52688. * Can also be used to scale the metalness values of the metallic texture.
  52689. */
  52690. metallic: number;
  52691. /**
  52692. * Specifies the roughness scalar value of the material.
  52693. * Can also be used to scale the roughness values of the metallic texture.
  52694. */
  52695. roughness: number;
  52696. /**
  52697. * Texture containing both the metallic value in the B channel and the
  52698. * roughness value in the G channel to keep better precision.
  52699. */
  52700. metallicRoughnessTexture: BaseTexture;
  52701. /**
  52702. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52703. *
  52704. * @param name The material name
  52705. * @param scene The scene the material will be use in.
  52706. */
  52707. constructor(name: string, scene: Scene);
  52708. /**
  52709. * Return the currrent class name of the material.
  52710. */
  52711. getClassName(): string;
  52712. /**
  52713. * Makes a duplicate of the current material.
  52714. * @param name - name to use for the new material.
  52715. */
  52716. clone(name: string): PBRMetallicRoughnessMaterial;
  52717. /**
  52718. * Serialize the material to a parsable JSON object.
  52719. */
  52720. serialize(): any;
  52721. /**
  52722. * Parses a JSON object correponding to the serialize function.
  52723. */
  52724. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52725. }
  52726. }
  52727. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52728. import { Scene } from "babylonjs/scene";
  52729. import { Color3 } from "babylonjs/Maths/math.color";
  52730. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52731. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52732. /**
  52733. * The PBR material of BJS following the specular glossiness convention.
  52734. *
  52735. * This fits to the PBR convention in the GLTF definition:
  52736. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52737. */
  52738. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52739. /**
  52740. * Specifies the diffuse color of the material.
  52741. */
  52742. diffuseColor: Color3;
  52743. /**
  52744. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52745. * channel.
  52746. */
  52747. diffuseTexture: BaseTexture;
  52748. /**
  52749. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52750. */
  52751. specularColor: Color3;
  52752. /**
  52753. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52754. */
  52755. glossiness: number;
  52756. /**
  52757. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52758. */
  52759. specularGlossinessTexture: BaseTexture;
  52760. /**
  52761. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52762. *
  52763. * @param name The material name
  52764. * @param scene The scene the material will be use in.
  52765. */
  52766. constructor(name: string, scene: Scene);
  52767. /**
  52768. * Return the currrent class name of the material.
  52769. */
  52770. getClassName(): string;
  52771. /**
  52772. * Makes a duplicate of the current material.
  52773. * @param name - name to use for the new material.
  52774. */
  52775. clone(name: string): PBRSpecularGlossinessMaterial;
  52776. /**
  52777. * Serialize the material to a parsable JSON object.
  52778. */
  52779. serialize(): any;
  52780. /**
  52781. * Parses a JSON object correponding to the serialize function.
  52782. */
  52783. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52784. }
  52785. }
  52786. declare module "babylonjs/Materials/PBR/index" {
  52787. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52788. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52789. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52790. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52791. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52792. }
  52793. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52794. import { Nullable } from "babylonjs/types";
  52795. import { Scene } from "babylonjs/scene";
  52796. import { Matrix } from "babylonjs/Maths/math.vector";
  52797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52798. /**
  52799. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52800. * It can help converting any input color in a desired output one. This can then be used to create effects
  52801. * from sepia, black and white to sixties or futuristic rendering...
  52802. *
  52803. * The only supported format is currently 3dl.
  52804. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52805. */
  52806. export class ColorGradingTexture extends BaseTexture {
  52807. /**
  52808. * The current texture matrix. (will always be identity in color grading texture)
  52809. */
  52810. private _textureMatrix;
  52811. /**
  52812. * The texture URL.
  52813. */
  52814. url: string;
  52815. /**
  52816. * Empty line regex stored for GC.
  52817. */
  52818. private static _noneEmptyLineRegex;
  52819. private _engine;
  52820. /**
  52821. * Instantiates a ColorGradingTexture from the following parameters.
  52822. *
  52823. * @param url The location of the color gradind data (currently only supporting 3dl)
  52824. * @param scene The scene the texture will be used in
  52825. */
  52826. constructor(url: string, scene: Scene);
  52827. /**
  52828. * Returns the texture matrix used in most of the material.
  52829. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52830. */
  52831. getTextureMatrix(): Matrix;
  52832. /**
  52833. * Occurs when the file being loaded is a .3dl LUT file.
  52834. */
  52835. private load3dlTexture;
  52836. /**
  52837. * Starts the loading process of the texture.
  52838. */
  52839. private loadTexture;
  52840. /**
  52841. * Clones the color gradind texture.
  52842. */
  52843. clone(): ColorGradingTexture;
  52844. /**
  52845. * Called during delayed load for textures.
  52846. */
  52847. delayLoad(): void;
  52848. /**
  52849. * Parses a color grading texture serialized by Babylon.
  52850. * @param parsedTexture The texture information being parsedTexture
  52851. * @param scene The scene to load the texture in
  52852. * @param rootUrl The root url of the data assets to load
  52853. * @return A color gradind texture
  52854. */
  52855. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52856. /**
  52857. * Serializes the LUT texture to json format.
  52858. */
  52859. serialize(): any;
  52860. }
  52861. }
  52862. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52863. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52864. import { Scene } from "babylonjs/scene";
  52865. import { Nullable } from "babylonjs/types";
  52866. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52867. /**
  52868. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52869. */
  52870. export class EquiRectangularCubeTexture extends BaseTexture {
  52871. /** The six faces of the cube. */
  52872. private static _FacesMapping;
  52873. private _noMipmap;
  52874. private _onLoad;
  52875. private _onError;
  52876. /** The size of the cubemap. */
  52877. private _size;
  52878. /** The buffer of the image. */
  52879. private _buffer;
  52880. /** The width of the input image. */
  52881. private _width;
  52882. /** The height of the input image. */
  52883. private _height;
  52884. /** The URL to the image. */
  52885. url: string;
  52886. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52887. coordinatesMode: number;
  52888. /**
  52889. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52890. * @param url The location of the image
  52891. * @param scene The scene the texture will be used in
  52892. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52893. * @param noMipmap Forces to not generate the mipmap if true
  52894. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52895. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52896. * @param onLoad — defines a callback called when texture is loaded
  52897. * @param onError — defines a callback called if there is an error
  52898. */
  52899. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52900. /**
  52901. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52902. */
  52903. private loadImage;
  52904. /**
  52905. * Convert the image buffer into a cubemap and create a CubeTexture.
  52906. */
  52907. private loadTexture;
  52908. /**
  52909. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52910. * @param buffer The ArrayBuffer that should be converted.
  52911. * @returns The buffer as Float32Array.
  52912. */
  52913. private getFloat32ArrayFromArrayBuffer;
  52914. /**
  52915. * Get the current class name of the texture useful for serialization or dynamic coding.
  52916. * @returns "EquiRectangularCubeTexture"
  52917. */
  52918. getClassName(): string;
  52919. /**
  52920. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52921. * @returns A clone of the current EquiRectangularCubeTexture.
  52922. */
  52923. clone(): EquiRectangularCubeTexture;
  52924. }
  52925. }
  52926. declare module "babylonjs/Misc/tga" {
  52927. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52928. /**
  52929. * Based on jsTGALoader - Javascript loader for TGA file
  52930. * By Vincent Thibault
  52931. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52932. */
  52933. export class TGATools {
  52934. private static _TYPE_INDEXED;
  52935. private static _TYPE_RGB;
  52936. private static _TYPE_GREY;
  52937. private static _TYPE_RLE_INDEXED;
  52938. private static _TYPE_RLE_RGB;
  52939. private static _TYPE_RLE_GREY;
  52940. private static _ORIGIN_MASK;
  52941. private static _ORIGIN_SHIFT;
  52942. private static _ORIGIN_BL;
  52943. private static _ORIGIN_BR;
  52944. private static _ORIGIN_UL;
  52945. private static _ORIGIN_UR;
  52946. /**
  52947. * Gets the header of a TGA file
  52948. * @param data defines the TGA data
  52949. * @returns the header
  52950. */
  52951. static GetTGAHeader(data: Uint8Array): any;
  52952. /**
  52953. * Uploads TGA content to a Babylon Texture
  52954. * @hidden
  52955. */
  52956. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52957. /** @hidden */
  52958. 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;
  52959. /** @hidden */
  52960. 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;
  52961. /** @hidden */
  52962. 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;
  52963. /** @hidden */
  52964. 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;
  52965. /** @hidden */
  52966. 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;
  52967. /** @hidden */
  52968. 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;
  52969. }
  52970. }
  52971. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52972. import { Nullable } from "babylonjs/types";
  52973. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52974. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52975. /**
  52976. * Implementation of the TGA Texture Loader.
  52977. * @hidden
  52978. */
  52979. export class _TGATextureLoader implements IInternalTextureLoader {
  52980. /**
  52981. * Defines wether the loader supports cascade loading the different faces.
  52982. */
  52983. readonly supportCascades: boolean;
  52984. /**
  52985. * This returns if the loader support the current file information.
  52986. * @param extension defines the file extension of the file being loaded
  52987. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52988. * @param fallback defines the fallback internal texture if any
  52989. * @param isBase64 defines whether the texture is encoded as a base64
  52990. * @param isBuffer defines whether the texture data are stored as a buffer
  52991. * @returns true if the loader can load the specified file
  52992. */
  52993. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52994. /**
  52995. * Transform the url before loading if required.
  52996. * @param rootUrl the url of the texture
  52997. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52998. * @returns the transformed texture
  52999. */
  53000. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53001. /**
  53002. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53003. * @param rootUrl the url of the texture
  53004. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53005. * @returns the fallback texture
  53006. */
  53007. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53008. /**
  53009. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53010. * @param data contains the texture data
  53011. * @param texture defines the BabylonJS internal texture
  53012. * @param createPolynomials will be true if polynomials have been requested
  53013. * @param onLoad defines the callback to trigger once the texture is ready
  53014. * @param onError defines the callback to trigger in case of error
  53015. */
  53016. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53017. /**
  53018. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53019. * @param data contains the texture data
  53020. * @param texture defines the BabylonJS internal texture
  53021. * @param callback defines the method to call once ready to upload
  53022. */
  53023. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53024. }
  53025. }
  53026. declare module "babylonjs/Misc/basis" {
  53027. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53028. /**
  53029. * Info about the .basis files
  53030. */
  53031. class BasisFileInfo {
  53032. /**
  53033. * If the file has alpha
  53034. */
  53035. hasAlpha: boolean;
  53036. /**
  53037. * Info about each image of the basis file
  53038. */
  53039. images: Array<{
  53040. levels: Array<{
  53041. width: number;
  53042. height: number;
  53043. transcodedPixels: ArrayBufferView;
  53044. }>;
  53045. }>;
  53046. }
  53047. /**
  53048. * Result of transcoding a basis file
  53049. */
  53050. class TranscodeResult {
  53051. /**
  53052. * Info about the .basis file
  53053. */
  53054. fileInfo: BasisFileInfo;
  53055. /**
  53056. * Format to use when loading the file
  53057. */
  53058. format: number;
  53059. }
  53060. /**
  53061. * Configuration options for the Basis transcoder
  53062. */
  53063. export class BasisTranscodeConfiguration {
  53064. /**
  53065. * Supported compression formats used to determine the supported output format of the transcoder
  53066. */
  53067. supportedCompressionFormats?: {
  53068. /**
  53069. * etc1 compression format
  53070. */
  53071. etc1?: boolean;
  53072. /**
  53073. * s3tc compression format
  53074. */
  53075. s3tc?: boolean;
  53076. /**
  53077. * pvrtc compression format
  53078. */
  53079. pvrtc?: boolean;
  53080. /**
  53081. * etc2 compression format
  53082. */
  53083. etc2?: boolean;
  53084. };
  53085. /**
  53086. * If mipmap levels should be loaded for transcoded images (Default: true)
  53087. */
  53088. loadMipmapLevels?: boolean;
  53089. /**
  53090. * Index of a single image to load (Default: all images)
  53091. */
  53092. loadSingleImage?: number;
  53093. }
  53094. /**
  53095. * Used to load .Basis files
  53096. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53097. */
  53098. export class BasisTools {
  53099. private static _IgnoreSupportedFormats;
  53100. /**
  53101. * URL to use when loading the basis transcoder
  53102. */
  53103. static JSModuleURL: string;
  53104. /**
  53105. * URL to use when loading the wasm module for the transcoder
  53106. */
  53107. static WasmModuleURL: string;
  53108. /**
  53109. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53110. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53111. * @returns internal format corresponding to the Basis format
  53112. */
  53113. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53114. private static _WorkerPromise;
  53115. private static _Worker;
  53116. private static _actionId;
  53117. private static _CreateWorkerAsync;
  53118. /**
  53119. * Transcodes a loaded image file to compressed pixel data
  53120. * @param imageData image data to transcode
  53121. * @param config configuration options for the transcoding
  53122. * @returns a promise resulting in the transcoded image
  53123. */
  53124. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53125. /**
  53126. * Loads a texture from the transcode result
  53127. * @param texture texture load to
  53128. * @param transcodeResult the result of transcoding the basis file to load from
  53129. */
  53130. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53131. }
  53132. }
  53133. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53134. import { Nullable } from "babylonjs/types";
  53135. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53136. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53137. /**
  53138. * Loader for .basis file format
  53139. */
  53140. export class _BasisTextureLoader implements IInternalTextureLoader {
  53141. /**
  53142. * Defines whether the loader supports cascade loading the different faces.
  53143. */
  53144. readonly supportCascades: boolean;
  53145. /**
  53146. * This returns if the loader support the current file information.
  53147. * @param extension defines the file extension of the file being loaded
  53148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53149. * @param fallback defines the fallback internal texture if any
  53150. * @param isBase64 defines whether the texture is encoded as a base64
  53151. * @param isBuffer defines whether the texture data are stored as a buffer
  53152. * @returns true if the loader can load the specified file
  53153. */
  53154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53155. /**
  53156. * Transform the url before loading if required.
  53157. * @param rootUrl the url of the texture
  53158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53159. * @returns the transformed texture
  53160. */
  53161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53162. /**
  53163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53164. * @param rootUrl the url of the texture
  53165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53166. * @returns the fallback texture
  53167. */
  53168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53169. /**
  53170. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53171. * @param data contains the texture data
  53172. * @param texture defines the BabylonJS internal texture
  53173. * @param createPolynomials will be true if polynomials have been requested
  53174. * @param onLoad defines the callback to trigger once the texture is ready
  53175. * @param onError defines the callback to trigger in case of error
  53176. */
  53177. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53178. /**
  53179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53180. * @param data contains the texture data
  53181. * @param texture defines the BabylonJS internal texture
  53182. * @param callback defines the method to call once ready to upload
  53183. */
  53184. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53185. }
  53186. }
  53187. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53188. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53189. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53190. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53191. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53192. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53193. }
  53194. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53195. import { Scene } from "babylonjs/scene";
  53196. import { Texture } from "babylonjs/Materials/Textures/texture";
  53197. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53198. /**
  53199. * 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.
  53200. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53201. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53202. */
  53203. export class CustomProceduralTexture extends ProceduralTexture {
  53204. private _animate;
  53205. private _time;
  53206. private _config;
  53207. private _texturePath;
  53208. /**
  53209. * Instantiates a new Custom Procedural Texture.
  53210. * 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.
  53211. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53212. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53213. * @param name Define the name of the texture
  53214. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53215. * @param size Define the size of the texture to create
  53216. * @param scene Define the scene the texture belongs to
  53217. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53218. * @param generateMipMaps Define if the texture should creates mip maps or not
  53219. */
  53220. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53221. private _loadJson;
  53222. /**
  53223. * Is the texture ready to be used ? (rendered at least once)
  53224. * @returns true if ready, otherwise, false.
  53225. */
  53226. isReady(): boolean;
  53227. /**
  53228. * Render the texture to its associated render target.
  53229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53230. */
  53231. render(useCameraPostProcess?: boolean): void;
  53232. /**
  53233. * Update the list of dependant textures samplers in the shader.
  53234. */
  53235. updateTextures(): void;
  53236. /**
  53237. * Update the uniform values of the procedural texture in the shader.
  53238. */
  53239. updateShaderUniforms(): void;
  53240. /**
  53241. * Define if the texture animates or not.
  53242. */
  53243. animate: boolean;
  53244. }
  53245. }
  53246. declare module "babylonjs/Shaders/noise.fragment" {
  53247. /** @hidden */
  53248. export var noisePixelShader: {
  53249. name: string;
  53250. shader: string;
  53251. };
  53252. }
  53253. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53254. import { Nullable } from "babylonjs/types";
  53255. import { Scene } from "babylonjs/scene";
  53256. import { Texture } from "babylonjs/Materials/Textures/texture";
  53257. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53258. import "babylonjs/Shaders/noise.fragment";
  53259. /**
  53260. * Class used to generate noise procedural textures
  53261. */
  53262. export class NoiseProceduralTexture extends ProceduralTexture {
  53263. private _time;
  53264. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53265. brightness: number;
  53266. /** Defines the number of octaves to process */
  53267. octaves: number;
  53268. /** Defines the level of persistence (0.8 by default) */
  53269. persistence: number;
  53270. /** Gets or sets animation speed factor (default is 1) */
  53271. animationSpeedFactor: number;
  53272. /**
  53273. * Creates a new NoiseProceduralTexture
  53274. * @param name defines the name fo the texture
  53275. * @param size defines the size of the texture (default is 256)
  53276. * @param scene defines the hosting scene
  53277. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53278. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53279. */
  53280. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53281. private _updateShaderUniforms;
  53282. protected _getDefines(): string;
  53283. /** Generate the current state of the procedural texture */
  53284. render(useCameraPostProcess?: boolean): void;
  53285. /**
  53286. * Serializes this noise procedural texture
  53287. * @returns a serialized noise procedural texture object
  53288. */
  53289. serialize(): any;
  53290. /**
  53291. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53292. * @param parsedTexture defines parsed texture data
  53293. * @param scene defines the current scene
  53294. * @param rootUrl defines the root URL containing noise procedural texture information
  53295. * @returns a parsed NoiseProceduralTexture
  53296. */
  53297. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53298. }
  53299. }
  53300. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53301. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53302. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53303. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53304. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53305. }
  53306. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53307. import { Nullable } from "babylonjs/types";
  53308. import { Scene } from "babylonjs/scene";
  53309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53311. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53312. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53313. /**
  53314. * Raw cube texture where the raw buffers are passed in
  53315. */
  53316. export class RawCubeTexture extends CubeTexture {
  53317. /**
  53318. * Creates a cube texture where the raw buffers are passed in.
  53319. * @param scene defines the scene the texture is attached to
  53320. * @param data defines the array of data to use to create each face
  53321. * @param size defines the size of the textures
  53322. * @param format defines the format of the data
  53323. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53324. * @param generateMipMaps defines if the engine should generate the mip levels
  53325. * @param invertY defines if data must be stored with Y axis inverted
  53326. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53327. * @param compression defines the compression used (null by default)
  53328. */
  53329. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53330. /**
  53331. * Updates the raw cube texture.
  53332. * @param data defines the data to store
  53333. * @param format defines the data format
  53334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53335. * @param invertY defines if data must be stored with Y axis inverted
  53336. * @param compression defines the compression used (null by default)
  53337. * @param level defines which level of the texture to update
  53338. */
  53339. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53340. /**
  53341. * Updates a raw cube texture with RGBD encoded data.
  53342. * @param data defines the array of data [mipmap][face] to use to create each face
  53343. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53344. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53345. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53346. * @returns a promsie that resolves when the operation is complete
  53347. */
  53348. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53349. /**
  53350. * Clones the raw cube texture.
  53351. * @return a new cube texture
  53352. */
  53353. clone(): CubeTexture;
  53354. /** @hidden */
  53355. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53356. }
  53357. }
  53358. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53359. import { Scene } from "babylonjs/scene";
  53360. import { Texture } from "babylonjs/Materials/Textures/texture";
  53361. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53362. /**
  53363. * Class used to store 3D textures containing user data
  53364. */
  53365. export class RawTexture3D extends Texture {
  53366. /** Gets or sets the texture format to use */
  53367. format: number;
  53368. private _engine;
  53369. /**
  53370. * Create a new RawTexture3D
  53371. * @param data defines the data of the texture
  53372. * @param width defines the width of the texture
  53373. * @param height defines the height of the texture
  53374. * @param depth defines the depth of the texture
  53375. * @param format defines the texture format to use
  53376. * @param scene defines the hosting scene
  53377. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53378. * @param invertY defines if texture must be stored with Y axis inverted
  53379. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53380. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53381. */
  53382. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53383. /** Gets or sets the texture format to use */
  53384. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53385. /**
  53386. * Update the texture with new data
  53387. * @param data defines the data to store in the texture
  53388. */
  53389. update(data: ArrayBufferView): void;
  53390. }
  53391. }
  53392. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53393. import { Scene } from "babylonjs/scene";
  53394. import { Plane } from "babylonjs/Maths/math.plane";
  53395. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53396. /**
  53397. * Creates a refraction texture used by refraction channel of the standard material.
  53398. * It is like a mirror but to see through a material.
  53399. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53400. */
  53401. export class RefractionTexture extends RenderTargetTexture {
  53402. /**
  53403. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53404. * 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.
  53405. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53406. */
  53407. refractionPlane: Plane;
  53408. /**
  53409. * Define how deep under the surface we should see.
  53410. */
  53411. depth: number;
  53412. /**
  53413. * Creates a refraction texture used by refraction channel of the standard material.
  53414. * It is like a mirror but to see through a material.
  53415. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53416. * @param name Define the texture name
  53417. * @param size Define the size of the underlying texture
  53418. * @param scene Define the scene the refraction belongs to
  53419. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53420. */
  53421. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53422. /**
  53423. * Clone the refraction texture.
  53424. * @returns the cloned texture
  53425. */
  53426. clone(): RefractionTexture;
  53427. /**
  53428. * Serialize the texture to a JSON representation you could use in Parse later on
  53429. * @returns the serialized JSON representation
  53430. */
  53431. serialize(): any;
  53432. }
  53433. }
  53434. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53435. import { Nullable } from "babylonjs/types";
  53436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53437. import { Matrix } from "babylonjs/Maths/math.vector";
  53438. import { Engine } from "babylonjs/Engines/engine";
  53439. import { Scene } from "babylonjs/scene";
  53440. /**
  53441. * Defines the options related to the creation of an HtmlElementTexture
  53442. */
  53443. export interface IHtmlElementTextureOptions {
  53444. /**
  53445. * Defines wether mip maps should be created or not.
  53446. */
  53447. generateMipMaps?: boolean;
  53448. /**
  53449. * Defines the sampling mode of the texture.
  53450. */
  53451. samplingMode?: number;
  53452. /**
  53453. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53454. */
  53455. engine: Nullable<Engine>;
  53456. /**
  53457. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53458. */
  53459. scene: Nullable<Scene>;
  53460. }
  53461. /**
  53462. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53463. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53464. * is automatically managed.
  53465. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53466. * in your application.
  53467. *
  53468. * As the update is not automatic, you need to call them manually.
  53469. */
  53470. export class HtmlElementTexture extends BaseTexture {
  53471. /**
  53472. * The texture URL.
  53473. */
  53474. element: HTMLVideoElement | HTMLCanvasElement;
  53475. private static readonly DefaultOptions;
  53476. private _textureMatrix;
  53477. private _engine;
  53478. private _isVideo;
  53479. private _generateMipMaps;
  53480. private _samplingMode;
  53481. /**
  53482. * Instantiates a HtmlElementTexture from the following parameters.
  53483. *
  53484. * @param name Defines the name of the texture
  53485. * @param element Defines the video or canvas the texture is filled with
  53486. * @param options Defines the other none mandatory texture creation options
  53487. */
  53488. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53489. private _createInternalTexture;
  53490. /**
  53491. * Returns the texture matrix used in most of the material.
  53492. */
  53493. getTextureMatrix(): Matrix;
  53494. /**
  53495. * Updates the content of the texture.
  53496. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53497. */
  53498. update(invertY?: Nullable<boolean>): void;
  53499. }
  53500. }
  53501. declare module "babylonjs/Materials/Textures/index" {
  53502. export * from "babylonjs/Materials/Textures/baseTexture";
  53503. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53504. export * from "babylonjs/Materials/Textures/cubeTexture";
  53505. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53506. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53507. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53508. export * from "babylonjs/Materials/Textures/internalTexture";
  53509. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53510. export * from "babylonjs/Materials/Textures/Loaders/index";
  53511. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53512. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53513. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53514. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53515. export * from "babylonjs/Materials/Textures/rawTexture";
  53516. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53517. export * from "babylonjs/Materials/Textures/refractionTexture";
  53518. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53519. export * from "babylonjs/Materials/Textures/texture";
  53520. export * from "babylonjs/Materials/Textures/videoTexture";
  53521. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53522. }
  53523. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53524. /**
  53525. * Enum used to define the target of a block
  53526. */
  53527. export enum NodeMaterialBlockTargets {
  53528. /** Vertex shader */
  53529. Vertex = 1,
  53530. /** Fragment shader */
  53531. Fragment = 2,
  53532. /** Neutral */
  53533. Neutral = 4,
  53534. /** Vertex and Fragment */
  53535. VertexAndFragment = 3
  53536. }
  53537. }
  53538. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53539. /**
  53540. * Defines the kind of connection point for node based material
  53541. */
  53542. export enum NodeMaterialBlockConnectionPointTypes {
  53543. /** Float */
  53544. Float = 1,
  53545. /** Int */
  53546. Int = 2,
  53547. /** Vector2 */
  53548. Vector2 = 4,
  53549. /** Vector3 */
  53550. Vector3 = 8,
  53551. /** Vector4 */
  53552. Vector4 = 16,
  53553. /** Color3 */
  53554. Color3 = 32,
  53555. /** Color4 */
  53556. Color4 = 64,
  53557. /** Matrix */
  53558. Matrix = 128,
  53559. /** Vector3 or Color3 */
  53560. Vector3OrColor3 = 40,
  53561. /** Vector3 or Vector4 */
  53562. Vector3OrVector4 = 24,
  53563. /** Vector4 or Color4 */
  53564. Vector4OrColor4 = 80,
  53565. /** Color3 or Color4 */
  53566. Color3OrColor4 = 96,
  53567. /** Vector2 or Color3 or Color4 */
  53568. Vector2OrColor3OrColor4 = 100,
  53569. /** Vector3 or Color3 or Color4 or Vector4 */
  53570. Vector3OrColor3OrVector4OrColor4 = 120,
  53571. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53572. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53573. /** Detect type based on connection */
  53574. AutoDetect = 1024,
  53575. /** Output type that will be defined by input type */
  53576. BasedOnInput = 2048
  53577. }
  53578. }
  53579. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53581. /**
  53582. * Root class for all node material optimizers
  53583. */
  53584. export class NodeMaterialOptimizer {
  53585. /**
  53586. * Function used to optimize a NodeMaterial graph
  53587. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53588. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53589. */
  53590. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53591. }
  53592. }
  53593. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53597. /**
  53598. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53599. */
  53600. export class TransformBlock extends NodeMaterialBlock {
  53601. /**
  53602. * Defines the value to use to complement W value to transform it to a Vector4
  53603. */
  53604. complementW: number;
  53605. /**
  53606. * Defines the value to use to complement z value to transform it to a Vector4
  53607. */
  53608. complementZ: number;
  53609. /**
  53610. * Creates a new TransformBlock
  53611. * @param name defines the block name
  53612. */
  53613. constructor(name: string);
  53614. /**
  53615. * Gets the current class name
  53616. * @returns the class name
  53617. */
  53618. getClassName(): string;
  53619. /**
  53620. * Gets the vector input
  53621. */
  53622. readonly vector: NodeMaterialConnectionPoint;
  53623. /**
  53624. * Gets the output component
  53625. */
  53626. readonly output: NodeMaterialConnectionPoint;
  53627. /**
  53628. * Gets the matrix transform input
  53629. */
  53630. readonly transform: NodeMaterialConnectionPoint;
  53631. protected _buildBlock(state: NodeMaterialBuildState): this;
  53632. }
  53633. }
  53634. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53638. /**
  53639. * Block used to output the vertex position
  53640. */
  53641. export class VertexOutputBlock extends NodeMaterialBlock {
  53642. /**
  53643. * Creates a new VertexOutputBlock
  53644. * @param name defines the block name
  53645. */
  53646. constructor(name: string);
  53647. /**
  53648. * Gets the current class name
  53649. * @returns the class name
  53650. */
  53651. getClassName(): string;
  53652. /**
  53653. * Gets the vector input component
  53654. */
  53655. readonly vector: NodeMaterialConnectionPoint;
  53656. protected _buildBlock(state: NodeMaterialBuildState): this;
  53657. }
  53658. }
  53659. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53663. /**
  53664. * Block used to output the final color
  53665. */
  53666. export class FragmentOutputBlock extends NodeMaterialBlock {
  53667. /**
  53668. * Create a new FragmentOutputBlock
  53669. * @param name defines the block name
  53670. */
  53671. constructor(name: string);
  53672. /**
  53673. * Gets the current class name
  53674. * @returns the class name
  53675. */
  53676. getClassName(): string;
  53677. /**
  53678. * Gets the rgba input component
  53679. */
  53680. readonly rgba: NodeMaterialConnectionPoint;
  53681. /**
  53682. * Gets the rgb input component
  53683. */
  53684. readonly rgb: NodeMaterialConnectionPoint;
  53685. /**
  53686. * Gets the a input component
  53687. */
  53688. readonly a: NodeMaterialConnectionPoint;
  53689. protected _buildBlock(state: NodeMaterialBuildState): this;
  53690. }
  53691. }
  53692. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53694. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53695. import { Scene } from "babylonjs/scene";
  53696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53697. import { Matrix } from "babylonjs/Maths/math.vector";
  53698. import { Mesh } from "babylonjs/Meshes/mesh";
  53699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53700. import { Observable } from "babylonjs/Misc/observable";
  53701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53702. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53703. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53704. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53705. import { Nullable } from "babylonjs/types";
  53706. /**
  53707. * Interface used to configure the node material editor
  53708. */
  53709. export interface INodeMaterialEditorOptions {
  53710. /** Define the URl to load node editor script */
  53711. editorURL?: string;
  53712. }
  53713. /** @hidden */
  53714. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53715. /** BONES */
  53716. NUM_BONE_INFLUENCERS: number;
  53717. BonesPerMesh: number;
  53718. BONETEXTURE: boolean;
  53719. /** MORPH TARGETS */
  53720. MORPHTARGETS: boolean;
  53721. MORPHTARGETS_NORMAL: boolean;
  53722. MORPHTARGETS_TANGENT: boolean;
  53723. MORPHTARGETS_UV: boolean;
  53724. NUM_MORPH_INFLUENCERS: number;
  53725. /** IMAGE PROCESSING */
  53726. IMAGEPROCESSING: boolean;
  53727. VIGNETTE: boolean;
  53728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53729. VIGNETTEBLENDMODEOPAQUE: boolean;
  53730. TONEMAPPING: boolean;
  53731. TONEMAPPING_ACES: boolean;
  53732. CONTRAST: boolean;
  53733. EXPOSURE: boolean;
  53734. COLORCURVES: boolean;
  53735. COLORGRADING: boolean;
  53736. COLORGRADING3D: boolean;
  53737. SAMPLER3DGREENDEPTH: boolean;
  53738. SAMPLER3DBGRMAP: boolean;
  53739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53740. constructor();
  53741. setValue(name: string, value: boolean): void;
  53742. }
  53743. /**
  53744. * Class used to configure NodeMaterial
  53745. */
  53746. export interface INodeMaterialOptions {
  53747. /**
  53748. * Defines if blocks should emit comments
  53749. */
  53750. emitComments: boolean;
  53751. }
  53752. /**
  53753. * Class used to create a node based material built by assembling shader blocks
  53754. */
  53755. export class NodeMaterial extends PushMaterial {
  53756. private _options;
  53757. private _vertexCompilationState;
  53758. private _fragmentCompilationState;
  53759. private _sharedData;
  53760. private _buildId;
  53761. private _buildWasSuccessful;
  53762. private _cachedWorldViewMatrix;
  53763. private _cachedWorldViewProjectionMatrix;
  53764. private _optimizers;
  53765. /** Define the URl to load node editor script */
  53766. static EditorURL: string;
  53767. private BJSNODEMATERIALEDITOR;
  53768. /** Get the inspector from bundle or global */
  53769. private _getGlobalNodeMaterialEditor;
  53770. /**
  53771. * 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)
  53772. */
  53773. ignoreAlpha: boolean;
  53774. /**
  53775. * Defines the maximum number of lights that can be used in the material
  53776. */
  53777. maxSimultaneousLights: number;
  53778. /**
  53779. * Observable raised when the material is built
  53780. */
  53781. onBuildObservable: Observable<NodeMaterial>;
  53782. /**
  53783. * Gets or sets the root nodes of the material vertex shader
  53784. */
  53785. _vertexOutputNodes: NodeMaterialBlock[];
  53786. /**
  53787. * Gets or sets the root nodes of the material fragment (pixel) shader
  53788. */
  53789. _fragmentOutputNodes: NodeMaterialBlock[];
  53790. /** Gets or sets options to control the node material overall behavior */
  53791. options: INodeMaterialOptions;
  53792. /**
  53793. * Default configuration related to image processing available in the standard Material.
  53794. */
  53795. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53796. /**
  53797. * Gets the image processing configuration used either in this material.
  53798. */
  53799. /**
  53800. * Sets the Default image processing configuration used either in the this material.
  53801. *
  53802. * If sets to null, the scene one is in use.
  53803. */
  53804. imageProcessingConfiguration: ImageProcessingConfiguration;
  53805. /**
  53806. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  53807. */
  53808. attachedBlocks: NodeMaterialBlock[];
  53809. /**
  53810. * Create a new node based material
  53811. * @param name defines the material name
  53812. * @param scene defines the hosting scene
  53813. * @param options defines creation option
  53814. */
  53815. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53816. /**
  53817. * Gets the current class name of the material e.g. "NodeMaterial"
  53818. * @returns the class name
  53819. */
  53820. getClassName(): string;
  53821. /**
  53822. * Keep track of the image processing observer to allow dispose and replace.
  53823. */
  53824. private _imageProcessingObserver;
  53825. /**
  53826. * Attaches a new image processing configuration to the Standard Material.
  53827. * @param configuration
  53828. */
  53829. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53830. /**
  53831. * Adds a new optimizer to the list of optimizers
  53832. * @param optimizer defines the optimizers to add
  53833. * @returns the current material
  53834. */
  53835. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53836. /**
  53837. * Remove an optimizer from the list of optimizers
  53838. * @param optimizer defines the optimizers to remove
  53839. * @returns the current material
  53840. */
  53841. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53842. /**
  53843. * Add a new block to the list of output nodes
  53844. * @param node defines the node to add
  53845. * @returns the current material
  53846. */
  53847. addOutputNode(node: NodeMaterialBlock): this;
  53848. /**
  53849. * Remove a block from the list of root nodes
  53850. * @param node defines the node to remove
  53851. * @returns the current material
  53852. */
  53853. removeOutputNode(node: NodeMaterialBlock): this;
  53854. private _addVertexOutputNode;
  53855. private _removeVertexOutputNode;
  53856. private _addFragmentOutputNode;
  53857. private _removeFragmentOutputNode;
  53858. /**
  53859. * Specifies if the material will require alpha blending
  53860. * @returns a boolean specifying if alpha blending is needed
  53861. */
  53862. needAlphaBlending(): boolean;
  53863. /**
  53864. * Specifies if this material should be rendered in alpha test mode
  53865. * @returns a boolean specifying if an alpha test is needed.
  53866. */
  53867. needAlphaTesting(): boolean;
  53868. private _initializeBlock;
  53869. private _resetDualBlocks;
  53870. /**
  53871. * Build the material and generates the inner effect
  53872. * @param verbose defines if the build should log activity
  53873. */
  53874. build(verbose?: boolean): void;
  53875. /**
  53876. * Runs an otpimization phase to try to improve the shader code
  53877. */
  53878. optimize(): void;
  53879. private _prepareDefinesForAttributes;
  53880. /**
  53881. * Get if the submesh is ready to be used and all its information available.
  53882. * Child classes can use it to update shaders
  53883. * @param mesh defines the mesh to check
  53884. * @param subMesh defines which submesh to check
  53885. * @param useInstances specifies that instances should be used
  53886. * @returns a boolean indicating that the submesh is ready or not
  53887. */
  53888. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53889. /**
  53890. * Get a string representing the shaders built by the current node graph
  53891. */
  53892. readonly compiledShaders: string;
  53893. /**
  53894. * Binds the world matrix to the material
  53895. * @param world defines the world transformation matrix
  53896. */
  53897. bindOnlyWorldMatrix(world: Matrix): void;
  53898. /**
  53899. * Binds the submesh to this material by preparing the effect and shader to draw
  53900. * @param world defines the world transformation matrix
  53901. * @param mesh defines the mesh containing the submesh
  53902. * @param subMesh defines the submesh to bind the material to
  53903. */
  53904. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53905. /**
  53906. * Gets the active textures from the material
  53907. * @returns an array of textures
  53908. */
  53909. getActiveTextures(): BaseTexture[];
  53910. /**
  53911. * Specifies if the material uses a texture
  53912. * @param texture defines the texture to check against the material
  53913. * @returns a boolean specifying if the material uses the texture
  53914. */
  53915. hasTexture(texture: BaseTexture): boolean;
  53916. /**
  53917. * Disposes the material
  53918. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53919. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53920. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53921. */
  53922. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53923. /** Creates the node editor window. */
  53924. private _createNodeEditor;
  53925. /**
  53926. * Launch the node material editor
  53927. * @param config Define the configuration of the editor
  53928. * @return a promise fulfilled when the node editor is visible
  53929. */
  53930. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53931. /**
  53932. * Clear the current material
  53933. */
  53934. clear(): void;
  53935. /**
  53936. * Clear the current material and set it to a default state
  53937. */
  53938. setToDefault(): void;
  53939. private _gatherBlocks;
  53940. /**
  53941. * Serializes this material in a JSON representation
  53942. * @returns the serialized material object
  53943. */
  53944. serialize(): any;
  53945. /**
  53946. * Clear the current graph and load a new one from a serialization object
  53947. * @param source defines the JSON representation of the material
  53948. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53949. */
  53950. loadFromSerialization(source: any, rootUrl?: string): void;
  53951. /**
  53952. * Creates a node material from parsed material data
  53953. * @param source defines the JSON representation of the material
  53954. * @param scene defines the hosting scene
  53955. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53956. * @returns a new node material
  53957. */
  53958. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53959. }
  53960. }
  53961. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53967. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53968. import { Effect } from "babylonjs/Materials/effect";
  53969. import { Mesh } from "babylonjs/Meshes/mesh";
  53970. import { Nullable } from "babylonjs/types";
  53971. import { Scene } from "babylonjs/scene";
  53972. /**
  53973. * Block used to read a texture from a sampler
  53974. */
  53975. export class TextureBlock extends NodeMaterialBlock {
  53976. private _defineName;
  53977. private _samplerName;
  53978. private _transformedUVName;
  53979. private _textureTransformName;
  53980. private _textureInfoName;
  53981. private _mainUVName;
  53982. private _mainUVDefineName;
  53983. /**
  53984. * Gets or sets the texture associated with the node
  53985. */
  53986. texture: Nullable<BaseTexture>;
  53987. /**
  53988. * Create a new TextureBlock
  53989. * @param name defines the block name
  53990. */
  53991. constructor(name: string);
  53992. /**
  53993. * Gets the current class name
  53994. * @returns the class name
  53995. */
  53996. getClassName(): string;
  53997. /**
  53998. * Gets the uv input component
  53999. */
  54000. readonly uv: NodeMaterialConnectionPoint;
  54001. /**
  54002. * Gets the output component
  54003. */
  54004. readonly output: NodeMaterialConnectionPoint;
  54005. autoConfigure(): void;
  54006. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54008. isReady(): boolean;
  54009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54010. private _injectVertexCode;
  54011. private _writeOutput;
  54012. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54013. serialize(): any;
  54014. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54015. }
  54016. }
  54017. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54020. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54021. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54022. /**
  54023. * Class used to store shared data between 2 NodeMaterialBuildState
  54024. */
  54025. export class NodeMaterialBuildStateSharedData {
  54026. /**
  54027. * Gets the list of emitted varyings
  54028. */
  54029. varyings: string[];
  54030. /**
  54031. * Gets the varying declaration string
  54032. */
  54033. varyingDeclaration: string;
  54034. /**
  54035. * Input blocks
  54036. */
  54037. inputBlocks: InputBlock[];
  54038. /**
  54039. * Input blocks
  54040. */
  54041. textureBlocks: TextureBlock[];
  54042. /**
  54043. * Bindable blocks (Blocks that need to set data to the effect)
  54044. */
  54045. bindableBlocks: NodeMaterialBlock[];
  54046. /**
  54047. * List of blocks that can provide a compilation fallback
  54048. */
  54049. blocksWithFallbacks: NodeMaterialBlock[];
  54050. /**
  54051. * List of blocks that can provide a define update
  54052. */
  54053. blocksWithDefines: NodeMaterialBlock[];
  54054. /**
  54055. * List of blocks that can provide a repeatable content
  54056. */
  54057. repeatableContentBlocks: NodeMaterialBlock[];
  54058. /**
  54059. * List of blocks that can provide a dynamic list of uniforms
  54060. */
  54061. dynamicUniformBlocks: NodeMaterialBlock[];
  54062. /**
  54063. * List of blocks that can block the isReady function for the material
  54064. */
  54065. blockingBlocks: NodeMaterialBlock[];
  54066. /**
  54067. * Build Id used to avoid multiple recompilations
  54068. */
  54069. buildId: number;
  54070. /** List of emitted variables */
  54071. variableNames: {
  54072. [key: string]: number;
  54073. };
  54074. /** List of emitted defines */
  54075. defineNames: {
  54076. [key: string]: number;
  54077. };
  54078. /** Should emit comments? */
  54079. emitComments: boolean;
  54080. /** Emit build activity */
  54081. verbose: boolean;
  54082. /**
  54083. * Gets the compilation hints emitted at compilation time
  54084. */
  54085. hints: {
  54086. needWorldViewMatrix: boolean;
  54087. needWorldViewProjectionMatrix: boolean;
  54088. needAlphaBlending: boolean;
  54089. needAlphaTesting: boolean;
  54090. };
  54091. /**
  54092. * List of compilation checks
  54093. */
  54094. checks: {
  54095. emitVertex: boolean;
  54096. emitFragment: boolean;
  54097. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54098. };
  54099. /** Creates a new shared data */
  54100. constructor();
  54101. /**
  54102. * Emits console errors and exceptions if there is a failing check
  54103. */
  54104. emitErrors(): void;
  54105. }
  54106. }
  54107. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54108. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54109. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54110. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54111. /**
  54112. * Class used to store node based material build state
  54113. */
  54114. export class NodeMaterialBuildState {
  54115. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54116. supportUniformBuffers: boolean;
  54117. /**
  54118. * Gets the list of emitted attributes
  54119. */
  54120. attributes: string[];
  54121. /**
  54122. * Gets the list of emitted uniforms
  54123. */
  54124. uniforms: string[];
  54125. /**
  54126. * Gets the list of emitted uniform buffers
  54127. */
  54128. uniformBuffers: string[];
  54129. /**
  54130. * Gets the list of emitted samplers
  54131. */
  54132. samplers: string[];
  54133. /**
  54134. * Gets the list of emitted functions
  54135. */
  54136. functions: {
  54137. [key: string]: string;
  54138. };
  54139. /**
  54140. * Gets the target of the compilation state
  54141. */
  54142. target: NodeMaterialBlockTargets;
  54143. /**
  54144. * Gets the list of emitted counters
  54145. */
  54146. counters: {
  54147. [key: string]: number;
  54148. };
  54149. /**
  54150. * Shared data between multiple NodeMaterialBuildState instances
  54151. */
  54152. sharedData: NodeMaterialBuildStateSharedData;
  54153. /** @hidden */
  54154. _vertexState: NodeMaterialBuildState;
  54155. /** @hidden */
  54156. _attributeDeclaration: string;
  54157. /** @hidden */
  54158. _uniformDeclaration: string;
  54159. /** @hidden */
  54160. _samplerDeclaration: string;
  54161. /** @hidden */
  54162. _varyingTransfer: string;
  54163. private _repeatableContentAnchorIndex;
  54164. /** @hidden */
  54165. _builtCompilationString: string;
  54166. /**
  54167. * Gets the emitted compilation strings
  54168. */
  54169. compilationString: string;
  54170. /**
  54171. * Finalize the compilation strings
  54172. * @param state defines the current compilation state
  54173. */
  54174. finalize(state: NodeMaterialBuildState): void;
  54175. /** @hidden */
  54176. readonly _repeatableContentAnchor: string;
  54177. /** @hidden */
  54178. _getFreeVariableName(prefix: string): string;
  54179. /** @hidden */
  54180. _getFreeDefineName(prefix: string): string;
  54181. /** @hidden */
  54182. _excludeVariableName(name: string): void;
  54183. /** @hidden */
  54184. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54185. /** @hidden */
  54186. _emitFunction(name: string, code: string, comments: string): void;
  54187. /** @hidden */
  54188. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54189. replaceStrings?: {
  54190. search: RegExp;
  54191. replace: string;
  54192. }[];
  54193. repeatKey?: string;
  54194. }): string;
  54195. /** @hidden */
  54196. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54197. repeatKey?: string;
  54198. removeAttributes?: boolean;
  54199. removeUniforms?: boolean;
  54200. removeVaryings?: boolean;
  54201. removeIfDef?: boolean;
  54202. replaceStrings?: {
  54203. search: RegExp;
  54204. replace: string;
  54205. }[];
  54206. }, storeKey?: string): void;
  54207. /** @hidden */
  54208. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54209. /** @hidden */
  54210. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54211. }
  54212. }
  54213. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54214. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54216. import { Nullable } from "babylonjs/types";
  54217. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54218. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54219. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54221. import { Mesh } from "babylonjs/Meshes/mesh";
  54222. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54223. import { Scene } from "babylonjs/scene";
  54224. /**
  54225. * Defines a block that can be used inside a node based material
  54226. */
  54227. export class NodeMaterialBlock {
  54228. private _buildId;
  54229. private _buildTarget;
  54230. private _target;
  54231. private _isFinalMerger;
  54232. private _isInput;
  54233. /** @hidden */
  54234. _inputs: NodeMaterialConnectionPoint[];
  54235. /** @hidden */
  54236. _outputs: NodeMaterialConnectionPoint[];
  54237. /**
  54238. * Gets or sets the name of the block
  54239. */
  54240. name: string;
  54241. /**
  54242. * Gets or sets the unique id of the node
  54243. */
  54244. uniqueId: number;
  54245. /**
  54246. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54247. */
  54248. readonly isFinalMerger: boolean;
  54249. /**
  54250. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54251. */
  54252. readonly isInput: boolean;
  54253. /**
  54254. * Gets or sets the build Id
  54255. */
  54256. buildId: number;
  54257. /**
  54258. * Gets or sets the target of the block
  54259. */
  54260. target: NodeMaterialBlockTargets;
  54261. /**
  54262. * Gets the list of input points
  54263. */
  54264. readonly inputs: NodeMaterialConnectionPoint[];
  54265. /** Gets the list of output points */
  54266. readonly outputs: NodeMaterialConnectionPoint[];
  54267. /**
  54268. * Find an input by its name
  54269. * @param name defines the name of the input to look for
  54270. * @returns the input or null if not found
  54271. */
  54272. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54273. /**
  54274. * Find an output by its name
  54275. * @param name defines the name of the outputto look for
  54276. * @returns the output or null if not found
  54277. */
  54278. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54279. /**
  54280. * Creates a new NodeMaterialBlock
  54281. * @param name defines the block name
  54282. * @param target defines the target of that block (Vertex by default)
  54283. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54284. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54285. */
  54286. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54287. /**
  54288. * Initialize the block and prepare the context for build
  54289. * @param state defines the state that will be used for the build
  54290. */
  54291. initialize(state: NodeMaterialBuildState): void;
  54292. /**
  54293. * Bind data to effect. Will only be called for blocks with isBindable === true
  54294. * @param effect defines the effect to bind data to
  54295. * @param nodeMaterial defines the hosting NodeMaterial
  54296. * @param mesh defines the mesh that will be rendered
  54297. */
  54298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54299. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54300. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54301. protected _writeFloat(value: number): string;
  54302. /**
  54303. * Gets the current class name e.g. "NodeMaterialBlock"
  54304. * @returns the class name
  54305. */
  54306. getClassName(): string;
  54307. /**
  54308. * Register a new input. Must be called inside a block constructor
  54309. * @param name defines the connection point name
  54310. * @param type defines the connection point type
  54311. * @param isOptional defines a boolean indicating that this input can be omitted
  54312. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54313. * @returns the current block
  54314. */
  54315. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54316. /**
  54317. * Register a new output. Must be called inside a block constructor
  54318. * @param name defines the connection point name
  54319. * @param type defines the connection point type
  54320. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54321. * @returns the current block
  54322. */
  54323. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54324. /**
  54325. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54326. * @param forOutput defines an optional connection point to check compatibility with
  54327. * @returns the first available input or null
  54328. */
  54329. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54330. /**
  54331. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54332. * @param forBlock defines an optional block to check compatibility with
  54333. * @returns the first available input or null
  54334. */
  54335. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54336. /**
  54337. * Connect current block with another block
  54338. * @param other defines the block to connect with
  54339. * @param options define the various options to help pick the right connections
  54340. * @returns the current block
  54341. */
  54342. connectTo(other: NodeMaterialBlock, options?: {
  54343. input?: string;
  54344. output?: string;
  54345. outputSwizzle?: string;
  54346. }): this | undefined;
  54347. protected _buildBlock(state: NodeMaterialBuildState): void;
  54348. /**
  54349. * Add uniforms, samplers and uniform buffers at compilation time
  54350. * @param state defines the state to update
  54351. * @param nodeMaterial defines the node material requesting the update
  54352. * @param defines defines the material defines to update
  54353. */
  54354. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54355. /**
  54356. * Add potential fallbacks if shader compilation fails
  54357. * @param mesh defines the mesh to be rendered
  54358. * @param fallbacks defines the current prioritized list of fallbacks
  54359. */
  54360. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54361. /**
  54362. * Update defines for shader compilation
  54363. * @param mesh defines the mesh to be rendered
  54364. * @param nodeMaterial defines the node material requesting the update
  54365. * @param defines defines the material defines to update
  54366. * @param useInstances specifies that instances should be used
  54367. */
  54368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54369. /**
  54370. * Initialize defines for shader compilation
  54371. * @param mesh defines the mesh to be rendered
  54372. * @param nodeMaterial defines the node material requesting the update
  54373. * @param defines defines the material defines to be prepared
  54374. * @param useInstances specifies that instances should be used
  54375. */
  54376. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54377. /**
  54378. * Lets the block try to connect some inputs automatically
  54379. */
  54380. autoConfigure(): void;
  54381. /**
  54382. * Function called when a block is declared as repeatable content generator
  54383. * @param vertexShaderState defines the current compilation state for the vertex shader
  54384. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54385. * @param mesh defines the mesh to be rendered
  54386. * @param defines defines the material defines to update
  54387. */
  54388. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54389. /**
  54390. * Checks if the block is ready
  54391. * @param mesh defines the mesh to be rendered
  54392. * @param nodeMaterial defines the node material requesting the update
  54393. * @param defines defines the material defines to update
  54394. * @param useInstances specifies that instances should be used
  54395. * @returns true if the block is ready
  54396. */
  54397. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54398. private _processBuild;
  54399. /**
  54400. * Compile the current node and generate the shader code
  54401. * @param state defines the current compilation state (uniforms, samplers, current string)
  54402. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54403. * @returns true if already built
  54404. */
  54405. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54406. /**
  54407. * Serializes this block in a JSON representation
  54408. * @returns the serialized block object
  54409. */
  54410. serialize(): any;
  54411. /** @hidden */
  54412. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54413. }
  54414. }
  54415. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54416. /**
  54417. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54418. */
  54419. export enum NodeMaterialBlockConnectionPointMode {
  54420. /** Value is an uniform */
  54421. Uniform = 0,
  54422. /** Value is a mesh attribute */
  54423. Attribute = 1,
  54424. /** Value is a varying between vertex and fragment shaders */
  54425. Varying = 2,
  54426. /** Mode is undefined */
  54427. Undefined = 3
  54428. }
  54429. }
  54430. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54431. /**
  54432. * Enum used to define well known values e.g. values automatically provided by the system
  54433. */
  54434. export enum NodeMaterialWellKnownValues {
  54435. /** World */
  54436. World = 1,
  54437. /** View */
  54438. View = 2,
  54439. /** Projection */
  54440. Projection = 3,
  54441. /** ViewProjection */
  54442. ViewProjection = 4,
  54443. /** WorldView */
  54444. WorldView = 5,
  54445. /** WorldViewProjection */
  54446. WorldViewProjection = 6,
  54447. /** CameraPosition */
  54448. CameraPosition = 7,
  54449. /** Fog Color */
  54450. FogColor = 8
  54451. }
  54452. }
  54453. declare module "babylonjs/Maths/math.vertexFormat" {
  54454. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54455. /**
  54456. * Contains position and normal vectors for a vertex
  54457. */
  54458. export class PositionNormalVertex {
  54459. /** the position of the vertex (defaut: 0,0,0) */
  54460. position: Vector3;
  54461. /** the normal of the vertex (defaut: 0,1,0) */
  54462. normal: Vector3;
  54463. /**
  54464. * Creates a PositionNormalVertex
  54465. * @param position the position of the vertex (defaut: 0,0,0)
  54466. * @param normal the normal of the vertex (defaut: 0,1,0)
  54467. */
  54468. constructor(
  54469. /** the position of the vertex (defaut: 0,0,0) */
  54470. position?: Vector3,
  54471. /** the normal of the vertex (defaut: 0,1,0) */
  54472. normal?: Vector3);
  54473. /**
  54474. * Clones the PositionNormalVertex
  54475. * @returns the cloned PositionNormalVertex
  54476. */
  54477. clone(): PositionNormalVertex;
  54478. }
  54479. /**
  54480. * Contains position, normal and uv vectors for a vertex
  54481. */
  54482. export class PositionNormalTextureVertex {
  54483. /** the position of the vertex (defaut: 0,0,0) */
  54484. position: Vector3;
  54485. /** the normal of the vertex (defaut: 0,1,0) */
  54486. normal: Vector3;
  54487. /** the uv of the vertex (default: 0,0) */
  54488. uv: Vector2;
  54489. /**
  54490. * Creates a PositionNormalTextureVertex
  54491. * @param position the position of the vertex (defaut: 0,0,0)
  54492. * @param normal the normal of the vertex (defaut: 0,1,0)
  54493. * @param uv the uv of the vertex (default: 0,0)
  54494. */
  54495. constructor(
  54496. /** the position of the vertex (defaut: 0,0,0) */
  54497. position?: Vector3,
  54498. /** the normal of the vertex (defaut: 0,1,0) */
  54499. normal?: Vector3,
  54500. /** the uv of the vertex (default: 0,0) */
  54501. uv?: Vector2);
  54502. /**
  54503. * Clones the PositionNormalTextureVertex
  54504. * @returns the cloned PositionNormalTextureVertex
  54505. */
  54506. clone(): PositionNormalTextureVertex;
  54507. }
  54508. }
  54509. declare module "babylonjs/Maths/math" {
  54510. export * from "babylonjs/Maths/math.axis";
  54511. export * from "babylonjs/Maths/math.color";
  54512. export * from "babylonjs/Maths/math.constants";
  54513. export * from "babylonjs/Maths/math.frustum";
  54514. export * from "babylonjs/Maths/math.path";
  54515. export * from "babylonjs/Maths/math.plane";
  54516. export * from "babylonjs/Maths/math.size";
  54517. export * from "babylonjs/Maths/math.vector";
  54518. export * from "babylonjs/Maths/math.vertexFormat";
  54519. export * from "babylonjs/Maths/math.viewport";
  54520. }
  54521. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54522. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54523. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54524. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54525. import { Nullable } from "babylonjs/types";
  54526. import { Effect } from "babylonjs/Materials/effect";
  54527. import { Matrix } from "babylonjs/Maths/math.vector";
  54528. import { Scene } from "babylonjs/scene";
  54529. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54531. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54532. /**
  54533. * Block used to expose an input value
  54534. */
  54535. export class InputBlock extends NodeMaterialBlock {
  54536. private _mode;
  54537. private _associatedVariableName;
  54538. private _storedValue;
  54539. private _valueCallback;
  54540. private _type;
  54541. /** @hidden */
  54542. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54543. /**
  54544. * Gets or sets the connection point type (default is float)
  54545. */
  54546. readonly type: NodeMaterialBlockConnectionPointTypes;
  54547. /**
  54548. * Creates a new InputBlock
  54549. * @param name defines the block name
  54550. * @param target defines the target of that block (Vertex by default)
  54551. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54552. */
  54553. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54554. /**
  54555. * Gets the output component
  54556. */
  54557. readonly output: NodeMaterialConnectionPoint;
  54558. /**
  54559. * Set the source of this connection point to a vertex attribute
  54560. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54561. * @returns the current connection point
  54562. */
  54563. setAsAttribute(attributeName?: string): InputBlock;
  54564. /**
  54565. * Set the source of this connection point to a well known value
  54566. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54567. * @returns the current connection point
  54568. */
  54569. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54570. /**
  54571. * Gets or sets the value of that point.
  54572. * Please note that this value will be ignored if valueCallback is defined
  54573. */
  54574. value: any;
  54575. /**
  54576. * Gets or sets a callback used to get the value of that point.
  54577. * Please note that setting this value will force the connection point to ignore the value property
  54578. */
  54579. valueCallback: () => any;
  54580. /**
  54581. * Gets or sets the associated variable name in the shader
  54582. */
  54583. associatedVariableName: string;
  54584. /**
  54585. * Gets a boolean indicating that this connection point not defined yet
  54586. */
  54587. readonly isUndefined: boolean;
  54588. /**
  54589. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54590. * In this case the connection point name must be the name of the uniform to use.
  54591. * Can only be set on inputs
  54592. */
  54593. isUniform: boolean;
  54594. /**
  54595. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54596. * In this case the connection point name must be the name of the attribute to use
  54597. * Can only be set on inputs
  54598. */
  54599. isAttribute: boolean;
  54600. /**
  54601. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54602. * Can only be set on exit points
  54603. */
  54604. isVarying: boolean;
  54605. /**
  54606. * Gets a boolean indicating that the current connection point is a well known value
  54607. */
  54608. readonly isWellKnownValue: boolean;
  54609. /**
  54610. * Gets or sets the current well known value or null if not defined as well know value
  54611. */
  54612. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54613. /**
  54614. * Gets the current class name
  54615. * @returns the class name
  54616. */
  54617. getClassName(): string;
  54618. private _emitDefine;
  54619. /**
  54620. * Set the input block to its default value (based on its type)
  54621. */
  54622. setDefaultValue(): void;
  54623. private _emit;
  54624. /** @hidden */
  54625. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54626. /** @hidden */
  54627. _transmit(effect: Effect, scene: Scene): void;
  54628. protected _buildBlock(state: NodeMaterialBuildState): void;
  54629. serialize(): any;
  54630. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54631. }
  54632. }
  54633. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54634. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54635. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54636. import { Nullable } from "babylonjs/types";
  54637. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54638. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54639. /**
  54640. * Defines a connection point for a block
  54641. */
  54642. export class NodeMaterialConnectionPoint {
  54643. /** @hidden */
  54644. _ownerBlock: NodeMaterialBlock;
  54645. /** @hidden */
  54646. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54647. private _endpoints;
  54648. private _associatedVariableName;
  54649. /** @hidden */
  54650. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54651. private _type;
  54652. /** @hidden */
  54653. _enforceAssociatedVariableName: boolean;
  54654. /**
  54655. * Gets or sets the associated variable name in the shader
  54656. */
  54657. associatedVariableName: string;
  54658. /**
  54659. * Gets or sets the connection point type (default is float)
  54660. */
  54661. type: NodeMaterialBlockConnectionPointTypes;
  54662. /**
  54663. * Gets or sets the connection point name
  54664. */
  54665. name: string;
  54666. /**
  54667. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54668. */
  54669. swizzle: string;
  54670. /**
  54671. * Gets or sets a boolean indicating that this connection point can be omitted
  54672. */
  54673. isOptional: boolean;
  54674. /**
  54675. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54676. */
  54677. define: string;
  54678. /** Gets or sets the target of that connection point */
  54679. target: NodeMaterialBlockTargets;
  54680. /**
  54681. * Gets a boolean indicating that the current point is connected
  54682. */
  54683. readonly isConnected: boolean;
  54684. /**
  54685. * Gets a boolean indicating that the current point is connected to an input block
  54686. */
  54687. readonly isConnectedToInput: boolean;
  54688. /**
  54689. * Gets a the connected input block (if any)
  54690. */
  54691. readonly connectInputBlock: Nullable<InputBlock>;
  54692. /** Get the other side of the connection (if any) */
  54693. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54694. /** Get the block that owns this connection point */
  54695. readonly ownerBlock: NodeMaterialBlock;
  54696. /** Get the block connected on the other side of this connection (if any) */
  54697. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54698. /** Get the block connected on the endpoints of this connection (if any) */
  54699. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54700. /** Gets the list of connected endpoints */
  54701. readonly endpoints: NodeMaterialConnectionPoint[];
  54702. /**
  54703. * Creates a new connection point
  54704. * @param name defines the connection point name
  54705. * @param ownerBlock defines the block hosting this connection point
  54706. */
  54707. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54708. /**
  54709. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54710. * @returns the class name
  54711. */
  54712. getClassName(): string;
  54713. /**
  54714. * Gets an boolean indicating if the current point can be connected to another point
  54715. * @param connectionPoint defines the other connection point
  54716. * @returns true if the connection is possible
  54717. */
  54718. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54719. /**
  54720. * Connect this point to another connection point
  54721. * @param connectionPoint defines the other connection point
  54722. * @returns the current connection point
  54723. */
  54724. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54725. /**
  54726. * Disconnect this point from one of his endpoint
  54727. * @param endpoint defines the other connection point
  54728. * @returns the current connection point
  54729. */
  54730. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54731. /**
  54732. * Serializes this point in a JSON representation
  54733. * @returns the serialized point object
  54734. */
  54735. serialize(): any;
  54736. private static _GetTypeLength;
  54737. }
  54738. }
  54739. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54740. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54741. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54743. import { Mesh } from "babylonjs/Meshes/mesh";
  54744. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54745. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54746. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54747. /**
  54748. * Block used to add support for vertex skinning (bones)
  54749. */
  54750. export class BonesBlock extends NodeMaterialBlock {
  54751. /**
  54752. * Creates a new BonesBlock
  54753. * @param name defines the block name
  54754. */
  54755. constructor(name: string);
  54756. /**
  54757. * Initialize the block and prepare the context for build
  54758. * @param state defines the state that will be used for the build
  54759. */
  54760. initialize(state: NodeMaterialBuildState): void;
  54761. /**
  54762. * Gets the current class name
  54763. * @returns the class name
  54764. */
  54765. getClassName(): string;
  54766. /**
  54767. * Gets the matrix indices input component
  54768. */
  54769. readonly matricesIndices: NodeMaterialConnectionPoint;
  54770. /**
  54771. * Gets the matrix weights input component
  54772. */
  54773. readonly matricesWeights: NodeMaterialConnectionPoint;
  54774. /**
  54775. * Gets the extra matrix indices input component
  54776. */
  54777. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54778. /**
  54779. * Gets the extra matrix weights input component
  54780. */
  54781. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54782. /**
  54783. * Gets the world input component
  54784. */
  54785. readonly world: NodeMaterialConnectionPoint;
  54786. /**
  54787. * Gets the output component
  54788. */
  54789. readonly output: NodeMaterialConnectionPoint;
  54790. autoConfigure(): void;
  54791. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54792. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54794. protected _buildBlock(state: NodeMaterialBuildState): this;
  54795. }
  54796. }
  54797. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54798. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54799. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54800. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54802. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54803. /**
  54804. * Block used to add support for instances
  54805. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54806. */
  54807. export class InstancesBlock extends NodeMaterialBlock {
  54808. /**
  54809. * Creates a new InstancesBlock
  54810. * @param name defines the block name
  54811. */
  54812. constructor(name: string);
  54813. /**
  54814. * Gets the current class name
  54815. * @returns the class name
  54816. */
  54817. getClassName(): string;
  54818. /**
  54819. * Gets the first world row input component
  54820. */
  54821. readonly world0: NodeMaterialConnectionPoint;
  54822. /**
  54823. * Gets the second world row input component
  54824. */
  54825. readonly world1: NodeMaterialConnectionPoint;
  54826. /**
  54827. * Gets the third world row input component
  54828. */
  54829. readonly world2: NodeMaterialConnectionPoint;
  54830. /**
  54831. * Gets the forth world row input component
  54832. */
  54833. readonly world3: NodeMaterialConnectionPoint;
  54834. /**
  54835. * Gets the world input component
  54836. */
  54837. readonly world: NodeMaterialConnectionPoint;
  54838. /**
  54839. * Gets the output component
  54840. */
  54841. readonly output: NodeMaterialConnectionPoint;
  54842. autoConfigure(): void;
  54843. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54844. protected _buildBlock(state: NodeMaterialBuildState): this;
  54845. }
  54846. }
  54847. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54848. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54849. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54850. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54851. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54852. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54853. import { Effect } from "babylonjs/Materials/effect";
  54854. import { Mesh } from "babylonjs/Meshes/mesh";
  54855. /**
  54856. * Block used to add morph targets support to vertex shader
  54857. */
  54858. export class MorphTargetsBlock extends NodeMaterialBlock {
  54859. private _repeatableContentAnchor;
  54860. private _repeatebleContentGenerated;
  54861. /**
  54862. * Create a new MorphTargetsBlock
  54863. * @param name defines the block name
  54864. */
  54865. constructor(name: string);
  54866. /**
  54867. * Gets the current class name
  54868. * @returns the class name
  54869. */
  54870. getClassName(): string;
  54871. /**
  54872. * Gets the position input component
  54873. */
  54874. readonly position: NodeMaterialConnectionPoint;
  54875. /**
  54876. * Gets the normal input component
  54877. */
  54878. readonly normal: NodeMaterialConnectionPoint;
  54879. /**
  54880. * Gets the tangent input component
  54881. */
  54882. readonly tangent: NodeMaterialConnectionPoint;
  54883. /**
  54884. * Gets the tangent input component
  54885. */
  54886. readonly uv: NodeMaterialConnectionPoint;
  54887. /**
  54888. * Gets the position output component
  54889. */
  54890. readonly positionOutput: NodeMaterialConnectionPoint;
  54891. /**
  54892. * Gets the normal output component
  54893. */
  54894. readonly normalOutput: NodeMaterialConnectionPoint;
  54895. /**
  54896. * Gets the tangent output component
  54897. */
  54898. readonly tangentOutput: NodeMaterialConnectionPoint;
  54899. /**
  54900. * Gets the tangent output component
  54901. */
  54902. readonly uvOutput: NodeMaterialConnectionPoint;
  54903. initialize(state: NodeMaterialBuildState): void;
  54904. autoConfigure(): void;
  54905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54906. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54907. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54908. protected _buildBlock(state: NodeMaterialBuildState): this;
  54909. }
  54910. }
  54911. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54912. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54913. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54914. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54915. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54916. }
  54917. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54918. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54919. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54920. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54921. /**
  54922. * Block used to add an alpha test in the fragment shader
  54923. */
  54924. export class AlphaTestBlock extends NodeMaterialBlock {
  54925. /**
  54926. * Gets or sets the alpha value where alpha testing happens
  54927. */
  54928. alphaCutOff: number;
  54929. /**
  54930. * Create a new AlphaTestBlock
  54931. * @param name defines the block name
  54932. */
  54933. constructor(name: string);
  54934. /**
  54935. * Gets the current class name
  54936. * @returns the class name
  54937. */
  54938. getClassName(): string;
  54939. /**
  54940. * Gets the color input component
  54941. */
  54942. readonly color: NodeMaterialConnectionPoint;
  54943. protected _buildBlock(state: NodeMaterialBuildState): this;
  54944. }
  54945. }
  54946. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  54947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54950. /**
  54951. * Block used to create a Color3/4 out of individual inputs (one for each component)
  54952. */
  54953. export class ColorMergerBlock extends NodeMaterialBlock {
  54954. /**
  54955. * Create a new ColorMergerBlock
  54956. * @param name defines the block name
  54957. */
  54958. constructor(name: string);
  54959. /**
  54960. * Gets the current class name
  54961. * @returns the class name
  54962. */
  54963. getClassName(): string;
  54964. /**
  54965. * Gets the r component input
  54966. */
  54967. readonly r: NodeMaterialConnectionPoint;
  54968. /**
  54969. * Gets the g component input
  54970. */
  54971. readonly g: NodeMaterialConnectionPoint;
  54972. /**
  54973. * Gets the b component input
  54974. */
  54975. readonly b: NodeMaterialConnectionPoint;
  54976. /**
  54977. * Gets the a component input
  54978. */
  54979. readonly a: NodeMaterialConnectionPoint;
  54980. protected _buildBlock(state: NodeMaterialBuildState): this;
  54981. }
  54982. }
  54983. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  54984. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54985. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54986. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54987. /**
  54988. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  54989. */
  54990. export class VectorMergerBlock extends NodeMaterialBlock {
  54991. /**
  54992. * Create a new VectorMergerBlock
  54993. * @param name defines the block name
  54994. */
  54995. constructor(name: string);
  54996. /**
  54997. * Gets the current class name
  54998. * @returns the class name
  54999. */
  55000. getClassName(): string;
  55001. /**
  55002. * Gets the x component input
  55003. */
  55004. readonly x: NodeMaterialConnectionPoint;
  55005. /**
  55006. * Gets the y component input
  55007. */
  55008. readonly y: NodeMaterialConnectionPoint;
  55009. /**
  55010. * Gets the z component input
  55011. */
  55012. readonly z: NodeMaterialConnectionPoint;
  55013. /**
  55014. * Gets the w component input
  55015. */
  55016. readonly w: NodeMaterialConnectionPoint;
  55017. protected _buildBlock(state: NodeMaterialBuildState): this;
  55018. }
  55019. }
  55020. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  55021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55024. /**
  55025. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  55026. */
  55027. export class ColorSplitterBlock extends NodeMaterialBlock {
  55028. /**
  55029. * Create a new ColorSplitterBlock
  55030. * @param name defines the block name
  55031. */
  55032. constructor(name: string);
  55033. /**
  55034. * Gets the current class name
  55035. * @returns the class name
  55036. */
  55037. getClassName(): string;
  55038. /**
  55039. * Gets the rgba input component
  55040. */
  55041. readonly rgba: NodeMaterialConnectionPoint;
  55042. /**
  55043. * Gets the rgb input component
  55044. */
  55045. readonly rgb: NodeMaterialConnectionPoint;
  55046. protected _buildBlock(state: NodeMaterialBuildState): this;
  55047. }
  55048. }
  55049. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  55050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55053. /**
  55054. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  55055. */
  55056. export class VectorSplitterBlock extends NodeMaterialBlock {
  55057. /**
  55058. * Create a new VectorSplitterBlock
  55059. * @param name defines the block name
  55060. */
  55061. constructor(name: string);
  55062. /**
  55063. * Gets the current class name
  55064. * @returns the class name
  55065. */
  55066. getClassName(): string;
  55067. /**
  55068. * Gets the rgba input component
  55069. */
  55070. readonly xyzw: NodeMaterialConnectionPoint;
  55071. /**
  55072. * Gets the rgb input component
  55073. */
  55074. readonly xyz: NodeMaterialConnectionPoint;
  55075. protected _buildBlock(state: NodeMaterialBuildState): this;
  55076. }
  55077. }
  55078. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55079. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55080. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55081. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55083. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55084. import { Effect } from "babylonjs/Materials/effect";
  55085. import { Mesh } from "babylonjs/Meshes/mesh";
  55086. /**
  55087. * Block used to add image processing support to fragment shader
  55088. */
  55089. export class ImageProcessingBlock extends NodeMaterialBlock {
  55090. /**
  55091. * Create a new ImageProcessingBlock
  55092. * @param name defines the block name
  55093. */
  55094. constructor(name: string);
  55095. /**
  55096. * Gets the current class name
  55097. * @returns the class name
  55098. */
  55099. getClassName(): string;
  55100. /**
  55101. * Gets the color input component
  55102. */
  55103. readonly color: NodeMaterialConnectionPoint;
  55104. /**
  55105. * Gets the output component
  55106. */
  55107. readonly output: NodeMaterialConnectionPoint;
  55108. /**
  55109. * Initialize the block and prepare the context for build
  55110. * @param state defines the state that will be used for the build
  55111. */
  55112. initialize(state: NodeMaterialBuildState): void;
  55113. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55116. protected _buildBlock(state: NodeMaterialBuildState): this;
  55117. }
  55118. }
  55119. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55120. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55121. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55122. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  55123. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  55124. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  55125. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  55126. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55127. }
  55128. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55131. import { Mesh } from "babylonjs/Meshes/mesh";
  55132. import { Effect } from "babylonjs/Materials/effect";
  55133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55135. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55136. /**
  55137. * Block used to add support for scene fog
  55138. */
  55139. export class FogBlock extends NodeMaterialBlock {
  55140. private _fogDistanceName;
  55141. private _fogParameters;
  55142. /**
  55143. * Create a new FogBlock
  55144. * @param name defines the block name
  55145. */
  55146. constructor(name: string);
  55147. /**
  55148. * Gets the current class name
  55149. * @returns the class name
  55150. */
  55151. getClassName(): string;
  55152. /**
  55153. * Gets the world position input component
  55154. */
  55155. readonly worldPosition: NodeMaterialConnectionPoint;
  55156. /**
  55157. * Gets the view input component
  55158. */
  55159. readonly view: NodeMaterialConnectionPoint;
  55160. /**
  55161. * Gets the color input component
  55162. */
  55163. readonly color: NodeMaterialConnectionPoint;
  55164. /**
  55165. * Gets the fog color input component
  55166. */
  55167. readonly fogColor: NodeMaterialConnectionPoint;
  55168. /**
  55169. * Gets the output component
  55170. */
  55171. readonly output: NodeMaterialConnectionPoint;
  55172. autoConfigure(): void;
  55173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55174. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55175. protected _buildBlock(state: NodeMaterialBuildState): this;
  55176. }
  55177. }
  55178. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55183. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55184. import { Effect } from "babylonjs/Materials/effect";
  55185. import { Mesh } from "babylonjs/Meshes/mesh";
  55186. import { Light } from "babylonjs/Lights/light";
  55187. import { Nullable } from "babylonjs/types";
  55188. import { Scene } from "babylonjs/scene";
  55189. /**
  55190. * Block used to add light in the fragment shader
  55191. */
  55192. export class LightBlock extends NodeMaterialBlock {
  55193. private _lightId;
  55194. /**
  55195. * Gets or sets the light associated with this block
  55196. */
  55197. light: Nullable<Light>;
  55198. /**
  55199. * Create a new LightBlock
  55200. * @param name defines the block name
  55201. */
  55202. constructor(name: string);
  55203. /**
  55204. * Gets the current class name
  55205. * @returns the class name
  55206. */
  55207. getClassName(): string;
  55208. /**
  55209. * Gets the world position input component
  55210. */
  55211. readonly worldPosition: NodeMaterialConnectionPoint;
  55212. /**
  55213. * Gets the world normal input component
  55214. */
  55215. readonly worldNormal: NodeMaterialConnectionPoint;
  55216. /**
  55217. * Gets the camera (or eye) position component
  55218. */
  55219. readonly cameraPosition: NodeMaterialConnectionPoint;
  55220. /**
  55221. * Gets the diffuse output component
  55222. */
  55223. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55224. /**
  55225. * Gets the specular output component
  55226. */
  55227. readonly specularOutput: NodeMaterialConnectionPoint;
  55228. autoConfigure(): void;
  55229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55230. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55231. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55232. private _injectVertexCode;
  55233. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55234. serialize(): any;
  55235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55236. }
  55237. }
  55238. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55239. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55240. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55241. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55242. }
  55243. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55244. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55245. }
  55246. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55250. /**
  55251. * Block used to multiply 2 values
  55252. */
  55253. export class MultiplyBlock extends NodeMaterialBlock {
  55254. /**
  55255. * Creates a new MultiplyBlock
  55256. * @param name defines the block name
  55257. */
  55258. constructor(name: string);
  55259. /**
  55260. * Gets the current class name
  55261. * @returns the class name
  55262. */
  55263. getClassName(): string;
  55264. /**
  55265. * Gets the left operand input component
  55266. */
  55267. readonly left: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the right operand input component
  55270. */
  55271. readonly right: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the output component
  55274. */
  55275. readonly output: NodeMaterialConnectionPoint;
  55276. protected _buildBlock(state: NodeMaterialBuildState): this;
  55277. }
  55278. }
  55279. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55283. /**
  55284. * Block used to add 2 vectors
  55285. */
  55286. export class AddBlock extends NodeMaterialBlock {
  55287. /**
  55288. * Creates a new AddBlock
  55289. * @param name defines the block name
  55290. */
  55291. constructor(name: string);
  55292. /**
  55293. * Gets the current class name
  55294. * @returns the class name
  55295. */
  55296. getClassName(): string;
  55297. /**
  55298. * Gets the left operand input component
  55299. */
  55300. readonly left: NodeMaterialConnectionPoint;
  55301. /**
  55302. * Gets the right operand input component
  55303. */
  55304. readonly right: NodeMaterialConnectionPoint;
  55305. /**
  55306. * Gets the output component
  55307. */
  55308. readonly output: NodeMaterialConnectionPoint;
  55309. protected _buildBlock(state: NodeMaterialBuildState): this;
  55310. }
  55311. }
  55312. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55316. /**
  55317. * Block used to clamp a float
  55318. */
  55319. export class ClampBlock extends NodeMaterialBlock {
  55320. /** Gets or sets the minimum range */
  55321. minimum: number;
  55322. /** Gets or sets the maximum range */
  55323. maximum: number;
  55324. /**
  55325. * Creates a new ClampBlock
  55326. * @param name defines the block name
  55327. */
  55328. constructor(name: string);
  55329. /**
  55330. * Gets the current class name
  55331. * @returns the class name
  55332. */
  55333. getClassName(): string;
  55334. /**
  55335. * Gets the value input component
  55336. */
  55337. readonly value: NodeMaterialConnectionPoint;
  55338. /**
  55339. * Gets the output component
  55340. */
  55341. readonly output: NodeMaterialConnectionPoint;
  55342. protected _buildBlock(state: NodeMaterialBuildState): this;
  55343. }
  55344. }
  55345. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55346. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55347. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55348. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55349. /**
  55350. * Block used to apply a cross product between 2 vectors
  55351. */
  55352. export class CrossBlock extends NodeMaterialBlock {
  55353. /**
  55354. * Creates a new CrossBlock
  55355. * @param name defines the block name
  55356. */
  55357. constructor(name: string);
  55358. /**
  55359. * Gets the current class name
  55360. * @returns the class name
  55361. */
  55362. getClassName(): string;
  55363. /**
  55364. * Gets the left operand input component
  55365. */
  55366. readonly left: NodeMaterialConnectionPoint;
  55367. /**
  55368. * Gets the right operand input component
  55369. */
  55370. readonly right: NodeMaterialConnectionPoint;
  55371. /**
  55372. * Gets the output component
  55373. */
  55374. readonly output: NodeMaterialConnectionPoint;
  55375. protected _buildBlock(state: NodeMaterialBuildState): this;
  55376. }
  55377. }
  55378. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55380. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55382. /**
  55383. * Block used to apply a dot product between 2 vectors
  55384. */
  55385. export class DotBlock extends NodeMaterialBlock {
  55386. /**
  55387. * Creates a new DotBlock
  55388. * @param name defines the block name
  55389. */
  55390. constructor(name: string);
  55391. /**
  55392. * Gets the current class name
  55393. * @returns the class name
  55394. */
  55395. getClassName(): string;
  55396. /**
  55397. * Gets the left operand input component
  55398. */
  55399. readonly left: NodeMaterialConnectionPoint;
  55400. /**
  55401. * Gets the right operand input component
  55402. */
  55403. readonly right: NodeMaterialConnectionPoint;
  55404. /**
  55405. * Gets the output component
  55406. */
  55407. readonly output: NodeMaterialConnectionPoint;
  55408. protected _buildBlock(state: NodeMaterialBuildState): this;
  55409. }
  55410. }
  55411. declare module "babylonjs/Materials/Node/Blocks/index" {
  55412. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55413. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55414. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55415. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55416. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55417. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55418. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55419. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55420. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55421. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55422. }
  55423. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55424. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55425. }
  55426. declare module "babylonjs/Materials/Node/index" {
  55427. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55428. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55429. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55430. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55431. export * from "babylonjs/Materials/Node/nodeMaterial";
  55432. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55433. export * from "babylonjs/Materials/Node/Blocks/index";
  55434. export * from "babylonjs/Materials/Node/Optimizers/index";
  55435. }
  55436. declare module "babylonjs/Materials/effectRenderer" {
  55437. import { Nullable } from "babylonjs/types";
  55438. import { Texture } from "babylonjs/Materials/Textures/texture";
  55439. import { Engine } from "babylonjs/Engines/engine";
  55440. import { Viewport } from "babylonjs/Maths/math.viewport";
  55441. import { Observable } from "babylonjs/Misc/observable";
  55442. import { Effect } from "babylonjs/Materials/effect";
  55443. import "babylonjs/Shaders/postprocess.vertex";
  55444. /**
  55445. * Effect Render Options
  55446. */
  55447. export interface IEffectRendererOptions {
  55448. /**
  55449. * Defines the vertices positions.
  55450. */
  55451. positions?: number[];
  55452. /**
  55453. * Defines the indices.
  55454. */
  55455. indices?: number[];
  55456. }
  55457. /**
  55458. * Helper class to render one or more effects
  55459. */
  55460. export class EffectRenderer {
  55461. private engine;
  55462. private static _DefaultOptions;
  55463. private _vertexBuffers;
  55464. private _indexBuffer;
  55465. private _ringBufferIndex;
  55466. private _ringScreenBuffer;
  55467. private _fullscreenViewport;
  55468. private _getNextFrameBuffer;
  55469. /**
  55470. * Creates an effect renderer
  55471. * @param engine the engine to use for rendering
  55472. * @param options defines the options of the effect renderer
  55473. */
  55474. constructor(engine: Engine, options?: IEffectRendererOptions);
  55475. /**
  55476. * Sets the current viewport in normalized coordinates 0-1
  55477. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55478. */
  55479. setViewport(viewport?: Viewport): void;
  55480. /**
  55481. * Sets the current effect wrapper to use during draw.
  55482. * The effect needs to be ready before calling this api.
  55483. * This also sets the default full screen position attribute.
  55484. * @param effectWrapper Defines the effect to draw with
  55485. */
  55486. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55487. /**
  55488. * Draws a full screen quad.
  55489. */
  55490. draw(): void;
  55491. /**
  55492. * renders one or more effects to a specified texture
  55493. * @param effectWrappers list of effects to renderer
  55494. * @param outputTexture texture to draw to, if null it will render to the screen
  55495. */
  55496. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55497. /**
  55498. * Disposes of the effect renderer
  55499. */
  55500. dispose(): void;
  55501. }
  55502. /**
  55503. * Options to create an EffectWrapper
  55504. */
  55505. interface EffectWrapperCreationOptions {
  55506. /**
  55507. * Engine to use to create the effect
  55508. */
  55509. engine: Engine;
  55510. /**
  55511. * Fragment shader for the effect
  55512. */
  55513. fragmentShader: string;
  55514. /**
  55515. * Vertex shader for the effect
  55516. */
  55517. vertexShader: string;
  55518. /**
  55519. * Attributes to use in the shader
  55520. */
  55521. attributeNames?: Array<string>;
  55522. /**
  55523. * Uniforms to use in the shader
  55524. */
  55525. uniformNames?: Array<string>;
  55526. /**
  55527. * Texture sampler names to use in the shader
  55528. */
  55529. samplerNames?: Array<string>;
  55530. /**
  55531. * The friendly name of the effect displayed in Spector.
  55532. */
  55533. name?: string;
  55534. }
  55535. /**
  55536. * Wraps an effect to be used for rendering
  55537. */
  55538. export class EffectWrapper {
  55539. /**
  55540. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55541. */
  55542. onApplyObservable: Observable<{}>;
  55543. /**
  55544. * The underlying effect
  55545. */
  55546. effect: Effect;
  55547. /**
  55548. * Creates an effect to be renderer
  55549. * @param creationOptions options to create the effect
  55550. */
  55551. constructor(creationOptions: EffectWrapperCreationOptions);
  55552. /**
  55553. * Disposes of the effect wrapper
  55554. */
  55555. dispose(): void;
  55556. }
  55557. }
  55558. declare module "babylonjs/Materials/index" {
  55559. export * from "babylonjs/Materials/Background/index";
  55560. export * from "babylonjs/Materials/colorCurves";
  55561. export * from "babylonjs/Materials/effect";
  55562. export * from "babylonjs/Materials/fresnelParameters";
  55563. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55564. export * from "babylonjs/Materials/material";
  55565. export * from "babylonjs/Materials/materialDefines";
  55566. export * from "babylonjs/Materials/materialHelper";
  55567. export * from "babylonjs/Materials/multiMaterial";
  55568. export * from "babylonjs/Materials/PBR/index";
  55569. export * from "babylonjs/Materials/pushMaterial";
  55570. export * from "babylonjs/Materials/shaderMaterial";
  55571. export * from "babylonjs/Materials/standardMaterial";
  55572. export * from "babylonjs/Materials/Textures/index";
  55573. export * from "babylonjs/Materials/uniformBuffer";
  55574. export * from "babylonjs/Materials/materialFlags";
  55575. export * from "babylonjs/Materials/Node/index";
  55576. export * from "babylonjs/Materials/effectRenderer";
  55577. }
  55578. declare module "babylonjs/Maths/index" {
  55579. export * from "babylonjs/Maths/math.scalar";
  55580. export * from "babylonjs/Maths/math";
  55581. export * from "babylonjs/Maths/sphericalPolynomial";
  55582. }
  55583. declare module "babylonjs/Misc/workerPool" {
  55584. import { IDisposable } from "babylonjs/scene";
  55585. /**
  55586. * Helper class to push actions to a pool of workers.
  55587. */
  55588. export class WorkerPool implements IDisposable {
  55589. private _workerInfos;
  55590. private _pendingActions;
  55591. /**
  55592. * Constructor
  55593. * @param workers Array of workers to use for actions
  55594. */
  55595. constructor(workers: Array<Worker>);
  55596. /**
  55597. * Terminates all workers and clears any pending actions.
  55598. */
  55599. dispose(): void;
  55600. /**
  55601. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55602. * pended until a worker has completed its action.
  55603. * @param action The action to perform. Call onComplete when the action is complete.
  55604. */
  55605. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55606. private _execute;
  55607. }
  55608. }
  55609. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55610. import { IDisposable } from "babylonjs/scene";
  55611. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55612. /**
  55613. * Configuration for Draco compression
  55614. */
  55615. export interface IDracoCompressionConfiguration {
  55616. /**
  55617. * Configuration for the decoder.
  55618. */
  55619. decoder: {
  55620. /**
  55621. * The url to the WebAssembly module.
  55622. */
  55623. wasmUrl?: string;
  55624. /**
  55625. * The url to the WebAssembly binary.
  55626. */
  55627. wasmBinaryUrl?: string;
  55628. /**
  55629. * The url to the fallback JavaScript module.
  55630. */
  55631. fallbackUrl?: string;
  55632. };
  55633. }
  55634. /**
  55635. * Draco compression (https://google.github.io/draco/)
  55636. *
  55637. * This class wraps the Draco module.
  55638. *
  55639. * **Encoder**
  55640. *
  55641. * The encoder is not currently implemented.
  55642. *
  55643. * **Decoder**
  55644. *
  55645. * 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.
  55646. *
  55647. * To update the configuration, use the following code:
  55648. * ```javascript
  55649. * DracoCompression.Configuration = {
  55650. * decoder: {
  55651. * wasmUrl: "<url to the WebAssembly library>",
  55652. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55653. * fallbackUrl: "<url to the fallback JavaScript library>",
  55654. * }
  55655. * };
  55656. * ```
  55657. *
  55658. * 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.
  55659. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55660. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55661. *
  55662. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55663. * ```javascript
  55664. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55665. * ```
  55666. *
  55667. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55668. */
  55669. export class DracoCompression implements IDisposable {
  55670. private _workerPoolPromise?;
  55671. private _decoderModulePromise?;
  55672. /**
  55673. * The configuration. Defaults to the following urls:
  55674. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55675. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55676. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55677. */
  55678. static Configuration: IDracoCompressionConfiguration;
  55679. /**
  55680. * Returns true if the decoder configuration is available.
  55681. */
  55682. static readonly DecoderAvailable: boolean;
  55683. /**
  55684. * Default number of workers to create when creating the draco compression object.
  55685. */
  55686. static DefaultNumWorkers: number;
  55687. private static GetDefaultNumWorkers;
  55688. private static _Default;
  55689. /**
  55690. * Default instance for the draco compression object.
  55691. */
  55692. static readonly Default: DracoCompression;
  55693. /**
  55694. * Constructor
  55695. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55696. */
  55697. constructor(numWorkers?: number);
  55698. /**
  55699. * Stop all async operations and release resources.
  55700. */
  55701. dispose(): void;
  55702. /**
  55703. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55704. * @returns a promise that resolves when ready
  55705. */
  55706. whenReadyAsync(): Promise<void>;
  55707. /**
  55708. * Decode Draco compressed mesh data to vertex data.
  55709. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55710. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55711. * @returns A promise that resolves with the decoded vertex data
  55712. */
  55713. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55714. [kind: string]: number;
  55715. }): Promise<VertexData>;
  55716. }
  55717. }
  55718. declare module "babylonjs/Meshes/Compression/index" {
  55719. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55720. }
  55721. declare module "babylonjs/Meshes/csg" {
  55722. import { Nullable } from "babylonjs/types";
  55723. import { Scene } from "babylonjs/scene";
  55724. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55725. import { Mesh } from "babylonjs/Meshes/mesh";
  55726. import { Material } from "babylonjs/Materials/material";
  55727. /**
  55728. * Class for building Constructive Solid Geometry
  55729. */
  55730. export class CSG {
  55731. private polygons;
  55732. /**
  55733. * The world matrix
  55734. */
  55735. matrix: Matrix;
  55736. /**
  55737. * Stores the position
  55738. */
  55739. position: Vector3;
  55740. /**
  55741. * Stores the rotation
  55742. */
  55743. rotation: Vector3;
  55744. /**
  55745. * Stores the rotation quaternion
  55746. */
  55747. rotationQuaternion: Nullable<Quaternion>;
  55748. /**
  55749. * Stores the scaling vector
  55750. */
  55751. scaling: Vector3;
  55752. /**
  55753. * Convert the Mesh to CSG
  55754. * @param mesh The Mesh to convert to CSG
  55755. * @returns A new CSG from the Mesh
  55756. */
  55757. static FromMesh(mesh: Mesh): CSG;
  55758. /**
  55759. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55760. * @param polygons Polygons used to construct a CSG solid
  55761. */
  55762. private static FromPolygons;
  55763. /**
  55764. * Clones, or makes a deep copy, of the CSG
  55765. * @returns A new CSG
  55766. */
  55767. clone(): CSG;
  55768. /**
  55769. * Unions this CSG with another CSG
  55770. * @param csg The CSG to union against this CSG
  55771. * @returns The unioned CSG
  55772. */
  55773. union(csg: CSG): CSG;
  55774. /**
  55775. * Unions this CSG with another CSG in place
  55776. * @param csg The CSG to union against this CSG
  55777. */
  55778. unionInPlace(csg: CSG): void;
  55779. /**
  55780. * Subtracts this CSG with another CSG
  55781. * @param csg The CSG to subtract against this CSG
  55782. * @returns A new CSG
  55783. */
  55784. subtract(csg: CSG): CSG;
  55785. /**
  55786. * Subtracts this CSG with another CSG in place
  55787. * @param csg The CSG to subtact against this CSG
  55788. */
  55789. subtractInPlace(csg: CSG): void;
  55790. /**
  55791. * Intersect this CSG with another CSG
  55792. * @param csg The CSG to intersect against this CSG
  55793. * @returns A new CSG
  55794. */
  55795. intersect(csg: CSG): CSG;
  55796. /**
  55797. * Intersects this CSG with another CSG in place
  55798. * @param csg The CSG to intersect against this CSG
  55799. */
  55800. intersectInPlace(csg: CSG): void;
  55801. /**
  55802. * Return a new CSG solid with solid and empty space switched. This solid is
  55803. * not modified.
  55804. * @returns A new CSG solid with solid and empty space switched
  55805. */
  55806. inverse(): CSG;
  55807. /**
  55808. * Inverses the CSG in place
  55809. */
  55810. inverseInPlace(): void;
  55811. /**
  55812. * This is used to keep meshes transformations so they can be restored
  55813. * when we build back a Babylon Mesh
  55814. * NB : All CSG operations are performed in world coordinates
  55815. * @param csg The CSG to copy the transform attributes from
  55816. * @returns This CSG
  55817. */
  55818. copyTransformAttributes(csg: CSG): CSG;
  55819. /**
  55820. * Build Raw mesh from CSG
  55821. * Coordinates here are in world space
  55822. * @param name The name of the mesh geometry
  55823. * @param scene The Scene
  55824. * @param keepSubMeshes Specifies if the submeshes should be kept
  55825. * @returns A new Mesh
  55826. */
  55827. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55828. /**
  55829. * Build Mesh from CSG taking material and transforms into account
  55830. * @param name The name of the Mesh
  55831. * @param material The material of the Mesh
  55832. * @param scene The Scene
  55833. * @param keepSubMeshes Specifies if submeshes should be kept
  55834. * @returns The new Mesh
  55835. */
  55836. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55837. }
  55838. }
  55839. declare module "babylonjs/Meshes/trailMesh" {
  55840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55841. import { Mesh } from "babylonjs/Meshes/mesh";
  55842. import { Scene } from "babylonjs/scene";
  55843. /**
  55844. * Class used to create a trail following a mesh
  55845. */
  55846. export class TrailMesh extends Mesh {
  55847. private _generator;
  55848. private _autoStart;
  55849. private _running;
  55850. private _diameter;
  55851. private _length;
  55852. private _sectionPolygonPointsCount;
  55853. private _sectionVectors;
  55854. private _sectionNormalVectors;
  55855. private _beforeRenderObserver;
  55856. /**
  55857. * @constructor
  55858. * @param name The value used by scene.getMeshByName() to do a lookup.
  55859. * @param generator The mesh to generate a trail.
  55860. * @param scene The scene to add this mesh to.
  55861. * @param diameter Diameter of trailing mesh. Default is 1.
  55862. * @param length Length of trailing mesh. Default is 60.
  55863. * @param autoStart Automatically start trailing mesh. Default true.
  55864. */
  55865. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55866. /**
  55867. * "TrailMesh"
  55868. * @returns "TrailMesh"
  55869. */
  55870. getClassName(): string;
  55871. private _createMesh;
  55872. /**
  55873. * Start trailing mesh.
  55874. */
  55875. start(): void;
  55876. /**
  55877. * Stop trailing mesh.
  55878. */
  55879. stop(): void;
  55880. /**
  55881. * Update trailing mesh geometry.
  55882. */
  55883. update(): void;
  55884. /**
  55885. * Returns a new TrailMesh object.
  55886. * @param name is a string, the name given to the new mesh
  55887. * @param newGenerator use new generator object for cloned trail mesh
  55888. * @returns a new mesh
  55889. */
  55890. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55891. /**
  55892. * Serializes this trail mesh
  55893. * @param serializationObject object to write serialization to
  55894. */
  55895. serialize(serializationObject: any): void;
  55896. /**
  55897. * Parses a serialized trail mesh
  55898. * @param parsedMesh the serialized mesh
  55899. * @param scene the scene to create the trail mesh in
  55900. * @returns the created trail mesh
  55901. */
  55902. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55903. }
  55904. }
  55905. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55906. import { Nullable } from "babylonjs/types";
  55907. import { Scene } from "babylonjs/scene";
  55908. import { Vector4 } from "babylonjs/Maths/math.vector";
  55909. import { Color4 } from "babylonjs/Maths/math.color";
  55910. import { Mesh } from "babylonjs/Meshes/mesh";
  55911. /**
  55912. * Class containing static functions to help procedurally build meshes
  55913. */
  55914. export class TiledBoxBuilder {
  55915. /**
  55916. * Creates a box mesh
  55917. * 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)
  55918. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55922. * @param name defines the name of the mesh
  55923. * @param options defines the options used to create the mesh
  55924. * @param scene defines the hosting scene
  55925. * @returns the box mesh
  55926. */
  55927. static CreateTiledBox(name: string, options: {
  55928. pattern?: number;
  55929. width?: number;
  55930. height?: number;
  55931. depth?: number;
  55932. tileSize?: number;
  55933. tileWidth?: number;
  55934. tileHeight?: number;
  55935. alignHorizontal?: number;
  55936. alignVertical?: number;
  55937. faceUV?: Vector4[];
  55938. faceColors?: Color4[];
  55939. sideOrientation?: number;
  55940. updatable?: boolean;
  55941. }, scene?: Nullable<Scene>): Mesh;
  55942. }
  55943. }
  55944. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55945. import { Vector4 } from "babylonjs/Maths/math.vector";
  55946. import { Mesh } from "babylonjs/Meshes/mesh";
  55947. /**
  55948. * Class containing static functions to help procedurally build meshes
  55949. */
  55950. export class TorusKnotBuilder {
  55951. /**
  55952. * Creates a torus knot mesh
  55953. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55954. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55955. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55956. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55957. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55958. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55959. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55960. * @param name defines the name of the mesh
  55961. * @param options defines the options used to create the mesh
  55962. * @param scene defines the hosting scene
  55963. * @returns the torus knot mesh
  55964. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55965. */
  55966. static CreateTorusKnot(name: string, options: {
  55967. radius?: number;
  55968. tube?: number;
  55969. radialSegments?: number;
  55970. tubularSegments?: number;
  55971. p?: number;
  55972. q?: number;
  55973. updatable?: boolean;
  55974. sideOrientation?: number;
  55975. frontUVs?: Vector4;
  55976. backUVs?: Vector4;
  55977. }, scene: any): Mesh;
  55978. }
  55979. }
  55980. declare module "babylonjs/Meshes/polygonMesh" {
  55981. import { Scene } from "babylonjs/scene";
  55982. import { Vector2 } from "babylonjs/Maths/math.vector";
  55983. import { Mesh } from "babylonjs/Meshes/mesh";
  55984. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55985. import { Path2 } from "babylonjs/Maths/math.path";
  55986. /**
  55987. * Polygon
  55988. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55989. */
  55990. export class Polygon {
  55991. /**
  55992. * Creates a rectangle
  55993. * @param xmin bottom X coord
  55994. * @param ymin bottom Y coord
  55995. * @param xmax top X coord
  55996. * @param ymax top Y coord
  55997. * @returns points that make the resulting rectation
  55998. */
  55999. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  56000. /**
  56001. * Creates a circle
  56002. * @param radius radius of circle
  56003. * @param cx scale in x
  56004. * @param cy scale in y
  56005. * @param numberOfSides number of sides that make up the circle
  56006. * @returns points that make the resulting circle
  56007. */
  56008. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  56009. /**
  56010. * Creates a polygon from input string
  56011. * @param input Input polygon data
  56012. * @returns the parsed points
  56013. */
  56014. static Parse(input: string): Vector2[];
  56015. /**
  56016. * Starts building a polygon from x and y coordinates
  56017. * @param x x coordinate
  56018. * @param y y coordinate
  56019. * @returns the started path2
  56020. */
  56021. static StartingAt(x: number, y: number): Path2;
  56022. }
  56023. /**
  56024. * Builds a polygon
  56025. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56026. */
  56027. export class PolygonMeshBuilder {
  56028. private _points;
  56029. private _outlinepoints;
  56030. private _holes;
  56031. private _name;
  56032. private _scene;
  56033. private _epoints;
  56034. private _eholes;
  56035. private _addToepoint;
  56036. /**
  56037. * Babylon reference to the earcut plugin.
  56038. */
  56039. bjsEarcut: any;
  56040. /**
  56041. * Creates a PolygonMeshBuilder
  56042. * @param name name of the builder
  56043. * @param contours Path of the polygon
  56044. * @param scene scene to add to when creating the mesh
  56045. * @param earcutInjection can be used to inject your own earcut reference
  56046. */
  56047. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56048. /**
  56049. * Adds a whole within the polygon
  56050. * @param hole Array of points defining the hole
  56051. * @returns this
  56052. */
  56053. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56054. /**
  56055. * Creates the polygon
  56056. * @param updatable If the mesh should be updatable
  56057. * @param depth The depth of the mesh created
  56058. * @returns the created mesh
  56059. */
  56060. build(updatable?: boolean, depth?: number): Mesh;
  56061. /**
  56062. * Creates the polygon
  56063. * @param depth The depth of the mesh created
  56064. * @returns the created VertexData
  56065. */
  56066. buildVertexData(depth?: number): VertexData;
  56067. /**
  56068. * Adds a side to the polygon
  56069. * @param positions points that make the polygon
  56070. * @param normals normals of the polygon
  56071. * @param uvs uvs of the polygon
  56072. * @param indices indices of the polygon
  56073. * @param bounds bounds of the polygon
  56074. * @param points points of the polygon
  56075. * @param depth depth of the polygon
  56076. * @param flip flip of the polygon
  56077. */
  56078. private addSide;
  56079. }
  56080. }
  56081. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56082. import { Scene } from "babylonjs/scene";
  56083. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56084. import { Color4 } from "babylonjs/Maths/math.color";
  56085. import { Mesh } from "babylonjs/Meshes/mesh";
  56086. import { Nullable } from "babylonjs/types";
  56087. /**
  56088. * Class containing static functions to help procedurally build meshes
  56089. */
  56090. export class PolygonBuilder {
  56091. /**
  56092. * Creates a polygon mesh
  56093. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56094. * * 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
  56095. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56098. * * Remember you can only change the shape positions, not their number when updating a polygon
  56099. * @param name defines the name of the mesh
  56100. * @param options defines the options used to create the mesh
  56101. * @param scene defines the hosting scene
  56102. * @param earcutInjection can be used to inject your own earcut reference
  56103. * @returns the polygon mesh
  56104. */
  56105. static CreatePolygon(name: string, options: {
  56106. shape: Vector3[];
  56107. holes?: Vector3[][];
  56108. depth?: number;
  56109. faceUV?: Vector4[];
  56110. faceColors?: Color4[];
  56111. updatable?: boolean;
  56112. sideOrientation?: number;
  56113. frontUVs?: Vector4;
  56114. backUVs?: Vector4;
  56115. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56116. /**
  56117. * Creates an extruded polygon mesh, with depth in the Y direction.
  56118. * * 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)
  56119. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56120. * @param name defines the name of the mesh
  56121. * @param options defines the options used to create the mesh
  56122. * @param scene defines the hosting scene
  56123. * @param earcutInjection can be used to inject your own earcut reference
  56124. * @returns the polygon mesh
  56125. */
  56126. static ExtrudePolygon(name: string, options: {
  56127. shape: Vector3[];
  56128. holes?: Vector3[][];
  56129. depth?: number;
  56130. faceUV?: Vector4[];
  56131. faceColors?: Color4[];
  56132. updatable?: boolean;
  56133. sideOrientation?: number;
  56134. frontUVs?: Vector4;
  56135. backUVs?: Vector4;
  56136. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56137. }
  56138. }
  56139. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56140. import { Scene } from "babylonjs/scene";
  56141. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56142. import { Mesh } from "babylonjs/Meshes/mesh";
  56143. import { Nullable } from "babylonjs/types";
  56144. /**
  56145. * Class containing static functions to help procedurally build meshes
  56146. */
  56147. export class LatheBuilder {
  56148. /**
  56149. * Creates lathe mesh.
  56150. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56151. * * 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
  56152. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56153. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56154. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56155. * * 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
  56156. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56157. * * 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
  56158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56162. * @param name defines the name of the mesh
  56163. * @param options defines the options used to create the mesh
  56164. * @param scene defines the hosting scene
  56165. * @returns the lathe mesh
  56166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56167. */
  56168. static CreateLathe(name: string, options: {
  56169. shape: Vector3[];
  56170. radius?: number;
  56171. tessellation?: number;
  56172. clip?: number;
  56173. arc?: number;
  56174. closed?: boolean;
  56175. updatable?: boolean;
  56176. sideOrientation?: number;
  56177. frontUVs?: Vector4;
  56178. backUVs?: Vector4;
  56179. cap?: number;
  56180. invertUV?: boolean;
  56181. }, scene?: Nullable<Scene>): Mesh;
  56182. }
  56183. }
  56184. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56185. import { Nullable } from "babylonjs/types";
  56186. import { Scene } from "babylonjs/scene";
  56187. import { Vector4 } from "babylonjs/Maths/math.vector";
  56188. import { Mesh } from "babylonjs/Meshes/mesh";
  56189. /**
  56190. * Class containing static functions to help procedurally build meshes
  56191. */
  56192. export class TiledPlaneBuilder {
  56193. /**
  56194. * Creates a tiled plane mesh
  56195. * * The parameter `pattern` will, depending on value, do nothing or
  56196. * * * flip (reflect about central vertical) alternate tiles across and up
  56197. * * * flip every tile on alternate rows
  56198. * * * rotate (180 degs) alternate tiles across and up
  56199. * * * rotate every tile on alternate rows
  56200. * * * flip and rotate alternate tiles across and up
  56201. * * * flip and rotate every tile on alternate rows
  56202. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56203. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56206. * * 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)
  56207. * * 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)
  56208. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56209. * @param name defines the name of the mesh
  56210. * @param options defines the options used to create the mesh
  56211. * @param scene defines the hosting scene
  56212. * @returns the box mesh
  56213. */
  56214. static CreateTiledPlane(name: string, options: {
  56215. pattern?: number;
  56216. tileSize?: number;
  56217. tileWidth?: number;
  56218. tileHeight?: number;
  56219. size?: number;
  56220. width?: number;
  56221. height?: number;
  56222. alignHorizontal?: number;
  56223. alignVertical?: number;
  56224. sideOrientation?: number;
  56225. frontUVs?: Vector4;
  56226. backUVs?: Vector4;
  56227. updatable?: boolean;
  56228. }, scene?: Nullable<Scene>): Mesh;
  56229. }
  56230. }
  56231. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56232. import { Nullable } from "babylonjs/types";
  56233. import { Scene } from "babylonjs/scene";
  56234. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56235. import { Mesh } from "babylonjs/Meshes/mesh";
  56236. /**
  56237. * Class containing static functions to help procedurally build meshes
  56238. */
  56239. export class TubeBuilder {
  56240. /**
  56241. * Creates a tube mesh.
  56242. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56243. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56244. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56245. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56246. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56247. * * 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)
  56248. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56249. * * 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
  56250. * * 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
  56251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56253. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56255. * @param name defines the name of the mesh
  56256. * @param options defines the options used to create the mesh
  56257. * @param scene defines the hosting scene
  56258. * @returns the tube mesh
  56259. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56260. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56261. */
  56262. static CreateTube(name: string, options: {
  56263. path: Vector3[];
  56264. radius?: number;
  56265. tessellation?: number;
  56266. radiusFunction?: {
  56267. (i: number, distance: number): number;
  56268. };
  56269. cap?: number;
  56270. arc?: number;
  56271. updatable?: boolean;
  56272. sideOrientation?: number;
  56273. frontUVs?: Vector4;
  56274. backUVs?: Vector4;
  56275. instance?: Mesh;
  56276. invertUV?: boolean;
  56277. }, scene?: Nullable<Scene>): Mesh;
  56278. }
  56279. }
  56280. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56281. import { Scene } from "babylonjs/scene";
  56282. import { Vector4 } from "babylonjs/Maths/math.vector";
  56283. import { Mesh } from "babylonjs/Meshes/mesh";
  56284. import { Nullable } from "babylonjs/types";
  56285. /**
  56286. * Class containing static functions to help procedurally build meshes
  56287. */
  56288. export class IcoSphereBuilder {
  56289. /**
  56290. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56291. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56292. * * 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`)
  56293. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56294. * * 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
  56295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56298. * @param name defines the name of the mesh
  56299. * @param options defines the options used to create the mesh
  56300. * @param scene defines the hosting scene
  56301. * @returns the icosahedron mesh
  56302. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56303. */
  56304. static CreateIcoSphere(name: string, options: {
  56305. radius?: number;
  56306. radiusX?: number;
  56307. radiusY?: number;
  56308. radiusZ?: number;
  56309. flat?: boolean;
  56310. subdivisions?: number;
  56311. sideOrientation?: number;
  56312. frontUVs?: Vector4;
  56313. backUVs?: Vector4;
  56314. updatable?: boolean;
  56315. }, scene?: Nullable<Scene>): Mesh;
  56316. }
  56317. }
  56318. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56319. import { Vector3 } from "babylonjs/Maths/math.vector";
  56320. import { Mesh } from "babylonjs/Meshes/mesh";
  56321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56322. /**
  56323. * Class containing static functions to help procedurally build meshes
  56324. */
  56325. export class DecalBuilder {
  56326. /**
  56327. * Creates a decal mesh.
  56328. * 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
  56329. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56330. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56331. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56332. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56333. * @param name defines the name of the mesh
  56334. * @param sourceMesh defines the mesh where the decal must be applied
  56335. * @param options defines the options used to create the mesh
  56336. * @param scene defines the hosting scene
  56337. * @returns the decal mesh
  56338. * @see https://doc.babylonjs.com/how_to/decals
  56339. */
  56340. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56341. position?: Vector3;
  56342. normal?: Vector3;
  56343. size?: Vector3;
  56344. angle?: number;
  56345. }): Mesh;
  56346. }
  56347. }
  56348. declare module "babylonjs/Meshes/meshBuilder" {
  56349. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56350. import { Nullable } from "babylonjs/types";
  56351. import { Scene } from "babylonjs/scene";
  56352. import { Mesh } from "babylonjs/Meshes/mesh";
  56353. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56354. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56356. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56357. import { Plane } from "babylonjs/Maths/math.plane";
  56358. /**
  56359. * Class containing static functions to help procedurally build meshes
  56360. */
  56361. export class MeshBuilder {
  56362. /**
  56363. * Creates a box mesh
  56364. * * The parameter `size` sets the size (float) of each box side (default 1)
  56365. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56366. * * 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)
  56367. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56371. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56372. * @param name defines the name of the mesh
  56373. * @param options defines the options used to create the mesh
  56374. * @param scene defines the hosting scene
  56375. * @returns the box mesh
  56376. */
  56377. static CreateBox(name: string, options: {
  56378. size?: number;
  56379. width?: number;
  56380. height?: number;
  56381. depth?: number;
  56382. faceUV?: Vector4[];
  56383. faceColors?: Color4[];
  56384. sideOrientation?: number;
  56385. frontUVs?: Vector4;
  56386. backUVs?: Vector4;
  56387. updatable?: boolean;
  56388. }, scene?: Nullable<Scene>): Mesh;
  56389. /**
  56390. * Creates a tiled box mesh
  56391. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56393. * @param name defines the name of the mesh
  56394. * @param options defines the options used to create the mesh
  56395. * @param scene defines the hosting scene
  56396. * @returns the tiled box mesh
  56397. */
  56398. static CreateTiledBox(name: string, options: {
  56399. pattern?: number;
  56400. size?: number;
  56401. width?: number;
  56402. height?: number;
  56403. depth: number;
  56404. tileSize?: number;
  56405. tileWidth?: number;
  56406. tileHeight?: number;
  56407. faceUV?: Vector4[];
  56408. faceColors?: Color4[];
  56409. alignHorizontal?: number;
  56410. alignVertical?: number;
  56411. sideOrientation?: number;
  56412. updatable?: boolean;
  56413. }, scene?: Nullable<Scene>): Mesh;
  56414. /**
  56415. * Creates a sphere mesh
  56416. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56417. * * 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`)
  56418. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56419. * * 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
  56420. * * 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)
  56421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56424. * @param name defines the name of the mesh
  56425. * @param options defines the options used to create the mesh
  56426. * @param scene defines the hosting scene
  56427. * @returns the sphere mesh
  56428. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56429. */
  56430. static CreateSphere(name: string, options: {
  56431. segments?: number;
  56432. diameter?: number;
  56433. diameterX?: number;
  56434. diameterY?: number;
  56435. diameterZ?: number;
  56436. arc?: number;
  56437. slice?: number;
  56438. sideOrientation?: number;
  56439. frontUVs?: Vector4;
  56440. backUVs?: Vector4;
  56441. updatable?: boolean;
  56442. }, scene?: Nullable<Scene>): Mesh;
  56443. /**
  56444. * Creates a plane polygonal mesh. By default, this is a disc
  56445. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56446. * * 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
  56447. * * 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
  56448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56451. * @param name defines the name of the mesh
  56452. * @param options defines the options used to create the mesh
  56453. * @param scene defines the hosting scene
  56454. * @returns the plane polygonal mesh
  56455. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56456. */
  56457. static CreateDisc(name: string, options: {
  56458. radius?: number;
  56459. tessellation?: number;
  56460. arc?: number;
  56461. updatable?: boolean;
  56462. sideOrientation?: number;
  56463. frontUVs?: Vector4;
  56464. backUVs?: Vector4;
  56465. }, scene?: Nullable<Scene>): Mesh;
  56466. /**
  56467. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56468. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56469. * * 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`)
  56470. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56471. * * 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
  56472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56474. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56475. * @param name defines the name of the mesh
  56476. * @param options defines the options used to create the mesh
  56477. * @param scene defines the hosting scene
  56478. * @returns the icosahedron mesh
  56479. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56480. */
  56481. static CreateIcoSphere(name: string, options: {
  56482. radius?: number;
  56483. radiusX?: number;
  56484. radiusY?: number;
  56485. radiusZ?: number;
  56486. flat?: boolean;
  56487. subdivisions?: number;
  56488. sideOrientation?: number;
  56489. frontUVs?: Vector4;
  56490. backUVs?: Vector4;
  56491. updatable?: boolean;
  56492. }, scene?: Nullable<Scene>): Mesh;
  56493. /**
  56494. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56495. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56496. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56497. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56498. * * 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
  56499. * * 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
  56500. * * 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
  56501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56503. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56504. * * 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
  56505. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56506. * * 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
  56507. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56509. * @param name defines the name of the mesh
  56510. * @param options defines the options used to create the mesh
  56511. * @param scene defines the hosting scene
  56512. * @returns the ribbon mesh
  56513. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56514. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56515. */
  56516. static CreateRibbon(name: string, options: {
  56517. pathArray: Vector3[][];
  56518. closeArray?: boolean;
  56519. closePath?: boolean;
  56520. offset?: number;
  56521. updatable?: boolean;
  56522. sideOrientation?: number;
  56523. frontUVs?: Vector4;
  56524. backUVs?: Vector4;
  56525. instance?: Mesh;
  56526. invertUV?: boolean;
  56527. uvs?: Vector2[];
  56528. colors?: Color4[];
  56529. }, scene?: Nullable<Scene>): Mesh;
  56530. /**
  56531. * Creates a cylinder or a cone mesh
  56532. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56533. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56534. * * 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.
  56535. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56536. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56537. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56538. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56539. * * 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).
  56540. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56541. * * 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).
  56542. * * 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
  56543. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56544. * * 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
  56545. * * 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.
  56546. * * If `enclose` is false, a ring surface is one element.
  56547. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56548. * * 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
  56549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56552. * @param name defines the name of the mesh
  56553. * @param options defines the options used to create the mesh
  56554. * @param scene defines the hosting scene
  56555. * @returns the cylinder mesh
  56556. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56557. */
  56558. static CreateCylinder(name: string, options: {
  56559. height?: number;
  56560. diameterTop?: number;
  56561. diameterBottom?: number;
  56562. diameter?: number;
  56563. tessellation?: number;
  56564. subdivisions?: number;
  56565. arc?: number;
  56566. faceColors?: Color4[];
  56567. faceUV?: Vector4[];
  56568. updatable?: boolean;
  56569. hasRings?: boolean;
  56570. enclose?: boolean;
  56571. cap?: number;
  56572. sideOrientation?: number;
  56573. frontUVs?: Vector4;
  56574. backUVs?: Vector4;
  56575. }, scene?: Nullable<Scene>): Mesh;
  56576. /**
  56577. * Creates a torus mesh
  56578. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56579. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56580. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56584. * @param name defines the name of the mesh
  56585. * @param options defines the options used to create the mesh
  56586. * @param scene defines the hosting scene
  56587. * @returns the torus mesh
  56588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56589. */
  56590. static CreateTorus(name: string, options: {
  56591. diameter?: number;
  56592. thickness?: number;
  56593. tessellation?: number;
  56594. updatable?: boolean;
  56595. sideOrientation?: number;
  56596. frontUVs?: Vector4;
  56597. backUVs?: Vector4;
  56598. }, scene?: Nullable<Scene>): Mesh;
  56599. /**
  56600. * Creates a torus knot mesh
  56601. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56602. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56603. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56604. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56608. * @param name defines the name of the mesh
  56609. * @param options defines the options used to create the mesh
  56610. * @param scene defines the hosting scene
  56611. * @returns the torus knot mesh
  56612. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56613. */
  56614. static CreateTorusKnot(name: string, options: {
  56615. radius?: number;
  56616. tube?: number;
  56617. radialSegments?: number;
  56618. tubularSegments?: number;
  56619. p?: number;
  56620. q?: number;
  56621. updatable?: boolean;
  56622. sideOrientation?: number;
  56623. frontUVs?: Vector4;
  56624. backUVs?: Vector4;
  56625. }, scene?: Nullable<Scene>): Mesh;
  56626. /**
  56627. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56628. * * 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
  56629. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56630. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56631. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56632. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56633. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56634. * * 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
  56635. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56636. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56638. * @param name defines the name of the new line system
  56639. * @param options defines the options used to create the line system
  56640. * @param scene defines the hosting scene
  56641. * @returns a new line system mesh
  56642. */
  56643. static CreateLineSystem(name: string, options: {
  56644. lines: Vector3[][];
  56645. updatable?: boolean;
  56646. instance?: Nullable<LinesMesh>;
  56647. colors?: Nullable<Color4[][]>;
  56648. useVertexAlpha?: boolean;
  56649. }, scene: Nullable<Scene>): LinesMesh;
  56650. /**
  56651. * Creates a line mesh
  56652. * 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
  56653. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56654. * * The parameter `points` is an array successive Vector3
  56655. * * 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
  56656. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56657. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56658. * * When updating an instance, remember that only point positions can change, not the number of points
  56659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56660. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56661. * @param name defines the name of the new line system
  56662. * @param options defines the options used to create the line system
  56663. * @param scene defines the hosting scene
  56664. * @returns a new line mesh
  56665. */
  56666. static CreateLines(name: string, options: {
  56667. points: Vector3[];
  56668. updatable?: boolean;
  56669. instance?: Nullable<LinesMesh>;
  56670. colors?: Color4[];
  56671. useVertexAlpha?: boolean;
  56672. }, scene?: Nullable<Scene>): LinesMesh;
  56673. /**
  56674. * Creates a dashed line mesh
  56675. * * 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
  56676. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56677. * * The parameter `points` is an array successive Vector3
  56678. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56679. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56680. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56681. * * 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
  56682. * * When updating an instance, remember that only point positions can change, not the number of points
  56683. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56684. * @param name defines the name of the mesh
  56685. * @param options defines the options used to create the mesh
  56686. * @param scene defines the hosting scene
  56687. * @returns the dashed line mesh
  56688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56689. */
  56690. static CreateDashedLines(name: string, options: {
  56691. points: Vector3[];
  56692. dashSize?: number;
  56693. gapSize?: number;
  56694. dashNb?: number;
  56695. updatable?: boolean;
  56696. instance?: LinesMesh;
  56697. }, scene?: Nullable<Scene>): LinesMesh;
  56698. /**
  56699. * 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.
  56700. * * 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.
  56701. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56702. * * 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.
  56703. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56704. * * 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
  56705. * * 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
  56706. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56709. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56711. * @param name defines the name of the mesh
  56712. * @param options defines the options used to create the mesh
  56713. * @param scene defines the hosting scene
  56714. * @returns the extruded shape mesh
  56715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56717. */
  56718. static ExtrudeShape(name: string, options: {
  56719. shape: Vector3[];
  56720. path: Vector3[];
  56721. scale?: number;
  56722. rotation?: number;
  56723. cap?: number;
  56724. updatable?: boolean;
  56725. sideOrientation?: number;
  56726. frontUVs?: Vector4;
  56727. backUVs?: Vector4;
  56728. instance?: Mesh;
  56729. invertUV?: boolean;
  56730. }, scene?: Nullable<Scene>): Mesh;
  56731. /**
  56732. * Creates an custom extruded shape mesh.
  56733. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56734. * * 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.
  56735. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56736. * * 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
  56737. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56738. * * 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
  56739. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56740. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56741. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56742. * * 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
  56743. * * 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
  56744. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56747. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56749. * @param name defines the name of the mesh
  56750. * @param options defines the options used to create the mesh
  56751. * @param scene defines the hosting scene
  56752. * @returns the custom extruded shape mesh
  56753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56754. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56755. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56756. */
  56757. static ExtrudeShapeCustom(name: string, options: {
  56758. shape: Vector3[];
  56759. path: Vector3[];
  56760. scaleFunction?: any;
  56761. rotationFunction?: any;
  56762. ribbonCloseArray?: boolean;
  56763. ribbonClosePath?: boolean;
  56764. cap?: number;
  56765. updatable?: boolean;
  56766. sideOrientation?: number;
  56767. frontUVs?: Vector4;
  56768. backUVs?: Vector4;
  56769. instance?: Mesh;
  56770. invertUV?: boolean;
  56771. }, scene?: Nullable<Scene>): Mesh;
  56772. /**
  56773. * Creates lathe mesh.
  56774. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56775. * * 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
  56776. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56777. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56778. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56779. * * 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
  56780. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56781. * * 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
  56782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56786. * @param name defines the name of the mesh
  56787. * @param options defines the options used to create the mesh
  56788. * @param scene defines the hosting scene
  56789. * @returns the lathe mesh
  56790. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56791. */
  56792. static CreateLathe(name: string, options: {
  56793. shape: Vector3[];
  56794. radius?: number;
  56795. tessellation?: number;
  56796. clip?: number;
  56797. arc?: number;
  56798. closed?: boolean;
  56799. updatable?: boolean;
  56800. sideOrientation?: number;
  56801. frontUVs?: Vector4;
  56802. backUVs?: Vector4;
  56803. cap?: number;
  56804. invertUV?: boolean;
  56805. }, scene?: Nullable<Scene>): Mesh;
  56806. /**
  56807. * Creates a tiled plane mesh
  56808. * * You can set a limited pattern arrangement with the tiles
  56809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56812. * @param name defines the name of the mesh
  56813. * @param options defines the options used to create the mesh
  56814. * @param scene defines the hosting scene
  56815. * @returns the plane mesh
  56816. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56817. */
  56818. static CreateTiledPlane(name: string, options: {
  56819. pattern?: number;
  56820. tileSize?: number;
  56821. tileWidth?: number;
  56822. tileHeight?: number;
  56823. size?: number;
  56824. width?: number;
  56825. height?: number;
  56826. alignHorizontal?: number;
  56827. alignVertical?: number;
  56828. sideOrientation?: number;
  56829. frontUVs?: Vector4;
  56830. backUVs?: Vector4;
  56831. updatable?: boolean;
  56832. }, scene?: Nullable<Scene>): Mesh;
  56833. /**
  56834. * Creates a plane mesh
  56835. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56836. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56837. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56841. * @param name defines the name of the mesh
  56842. * @param options defines the options used to create the mesh
  56843. * @param scene defines the hosting scene
  56844. * @returns the plane mesh
  56845. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56846. */
  56847. static CreatePlane(name: string, options: {
  56848. size?: number;
  56849. width?: number;
  56850. height?: number;
  56851. sideOrientation?: number;
  56852. frontUVs?: Vector4;
  56853. backUVs?: Vector4;
  56854. updatable?: boolean;
  56855. sourcePlane?: Plane;
  56856. }, scene?: Nullable<Scene>): Mesh;
  56857. /**
  56858. * Creates a ground mesh
  56859. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56860. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56862. * @param name defines the name of the mesh
  56863. * @param options defines the options used to create the mesh
  56864. * @param scene defines the hosting scene
  56865. * @returns the ground mesh
  56866. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56867. */
  56868. static CreateGround(name: string, options: {
  56869. width?: number;
  56870. height?: number;
  56871. subdivisions?: number;
  56872. subdivisionsX?: number;
  56873. subdivisionsY?: number;
  56874. updatable?: boolean;
  56875. }, scene?: Nullable<Scene>): Mesh;
  56876. /**
  56877. * Creates a tiled ground mesh
  56878. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56879. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56880. * * 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
  56881. * * 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
  56882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56883. * @param name defines the name of the mesh
  56884. * @param options defines the options used to create the mesh
  56885. * @param scene defines the hosting scene
  56886. * @returns the tiled ground mesh
  56887. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56888. */
  56889. static CreateTiledGround(name: string, options: {
  56890. xmin: number;
  56891. zmin: number;
  56892. xmax: number;
  56893. zmax: number;
  56894. subdivisions?: {
  56895. w: number;
  56896. h: number;
  56897. };
  56898. precision?: {
  56899. w: number;
  56900. h: number;
  56901. };
  56902. updatable?: boolean;
  56903. }, scene?: Nullable<Scene>): Mesh;
  56904. /**
  56905. * Creates a ground mesh from a height map
  56906. * * The parameter `url` sets the URL of the height map image resource.
  56907. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56908. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56909. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56910. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56911. * * 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.
  56912. * * 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).
  56913. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56915. * @param name defines the name of the mesh
  56916. * @param url defines the url to the height map
  56917. * @param options defines the options used to create the mesh
  56918. * @param scene defines the hosting scene
  56919. * @returns the ground mesh
  56920. * @see https://doc.babylonjs.com/babylon101/height_map
  56921. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56922. */
  56923. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56924. width?: number;
  56925. height?: number;
  56926. subdivisions?: number;
  56927. minHeight?: number;
  56928. maxHeight?: number;
  56929. colorFilter?: Color3;
  56930. alphaFilter?: number;
  56931. updatable?: boolean;
  56932. onReady?: (mesh: GroundMesh) => void;
  56933. }, scene?: Nullable<Scene>): GroundMesh;
  56934. /**
  56935. * Creates a polygon mesh
  56936. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56937. * * 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
  56938. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56941. * * Remember you can only change the shape positions, not their number when updating a polygon
  56942. * @param name defines the name of the mesh
  56943. * @param options defines the options used to create the mesh
  56944. * @param scene defines the hosting scene
  56945. * @param earcutInjection can be used to inject your own earcut reference
  56946. * @returns the polygon mesh
  56947. */
  56948. static CreatePolygon(name: string, options: {
  56949. shape: Vector3[];
  56950. holes?: Vector3[][];
  56951. depth?: number;
  56952. faceUV?: Vector4[];
  56953. faceColors?: Color4[];
  56954. updatable?: boolean;
  56955. sideOrientation?: number;
  56956. frontUVs?: Vector4;
  56957. backUVs?: Vector4;
  56958. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56959. /**
  56960. * Creates an extruded polygon mesh, with depth in the Y direction.
  56961. * * 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)
  56962. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56963. * @param name defines the name of the mesh
  56964. * @param options defines the options used to create the mesh
  56965. * @param scene defines the hosting scene
  56966. * @param earcutInjection can be used to inject your own earcut reference
  56967. * @returns the polygon mesh
  56968. */
  56969. static ExtrudePolygon(name: string, options: {
  56970. shape: Vector3[];
  56971. holes?: Vector3[][];
  56972. depth?: number;
  56973. faceUV?: Vector4[];
  56974. faceColors?: Color4[];
  56975. updatable?: boolean;
  56976. sideOrientation?: number;
  56977. frontUVs?: Vector4;
  56978. backUVs?: Vector4;
  56979. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56980. /**
  56981. * Creates a tube mesh.
  56982. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56983. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56984. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56985. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56986. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56987. * * 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)
  56988. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56989. * * 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
  56990. * * 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
  56991. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56992. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56993. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56995. * @param name defines the name of the mesh
  56996. * @param options defines the options used to create the mesh
  56997. * @param scene defines the hosting scene
  56998. * @returns the tube mesh
  56999. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57000. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  57001. */
  57002. static CreateTube(name: string, options: {
  57003. path: Vector3[];
  57004. radius?: number;
  57005. tessellation?: number;
  57006. radiusFunction?: {
  57007. (i: number, distance: number): number;
  57008. };
  57009. cap?: number;
  57010. arc?: number;
  57011. updatable?: boolean;
  57012. sideOrientation?: number;
  57013. frontUVs?: Vector4;
  57014. backUVs?: Vector4;
  57015. instance?: Mesh;
  57016. invertUV?: boolean;
  57017. }, scene?: Nullable<Scene>): Mesh;
  57018. /**
  57019. * Creates a polyhedron mesh
  57020. * * 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
  57021. * * The parameter `size` (positive float, default 1) sets the polygon size
  57022. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57023. * * 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`
  57024. * * 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
  57025. * * 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)`)
  57026. * * 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
  57027. * * 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
  57028. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57029. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57031. * @param name defines the name of the mesh
  57032. * @param options defines the options used to create the mesh
  57033. * @param scene defines the hosting scene
  57034. * @returns the polyhedron mesh
  57035. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57036. */
  57037. static CreatePolyhedron(name: string, options: {
  57038. type?: number;
  57039. size?: number;
  57040. sizeX?: number;
  57041. sizeY?: number;
  57042. sizeZ?: number;
  57043. custom?: any;
  57044. faceUV?: Vector4[];
  57045. faceColors?: Color4[];
  57046. flat?: boolean;
  57047. updatable?: boolean;
  57048. sideOrientation?: number;
  57049. frontUVs?: Vector4;
  57050. backUVs?: Vector4;
  57051. }, scene?: Nullable<Scene>): Mesh;
  57052. /**
  57053. * Creates a decal mesh.
  57054. * 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
  57055. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57056. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57057. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57058. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57059. * @param name defines the name of the mesh
  57060. * @param sourceMesh defines the mesh where the decal must be applied
  57061. * @param options defines the options used to create the mesh
  57062. * @param scene defines the hosting scene
  57063. * @returns the decal mesh
  57064. * @see https://doc.babylonjs.com/how_to/decals
  57065. */
  57066. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57067. position?: Vector3;
  57068. normal?: Vector3;
  57069. size?: Vector3;
  57070. angle?: number;
  57071. }): Mesh;
  57072. }
  57073. }
  57074. declare module "babylonjs/Meshes/meshSimplification" {
  57075. import { Mesh } from "babylonjs/Meshes/mesh";
  57076. /**
  57077. * A simplifier interface for future simplification implementations
  57078. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57079. */
  57080. export interface ISimplifier {
  57081. /**
  57082. * Simplification of a given mesh according to the given settings.
  57083. * Since this requires computation, it is assumed that the function runs async.
  57084. * @param settings The settings of the simplification, including quality and distance
  57085. * @param successCallback A callback that will be called after the mesh was simplified.
  57086. * @param errorCallback in case of an error, this callback will be called. optional.
  57087. */
  57088. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57089. }
  57090. /**
  57091. * Expected simplification settings.
  57092. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57093. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57094. */
  57095. export interface ISimplificationSettings {
  57096. /**
  57097. * Gets or sets the expected quality
  57098. */
  57099. quality: number;
  57100. /**
  57101. * Gets or sets the distance when this optimized version should be used
  57102. */
  57103. distance: number;
  57104. /**
  57105. * Gets an already optimized mesh
  57106. */
  57107. optimizeMesh?: boolean;
  57108. }
  57109. /**
  57110. * Class used to specify simplification options
  57111. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57112. */
  57113. export class SimplificationSettings implements ISimplificationSettings {
  57114. /** expected quality */
  57115. quality: number;
  57116. /** distance when this optimized version should be used */
  57117. distance: number;
  57118. /** already optimized mesh */
  57119. optimizeMesh?: boolean | undefined;
  57120. /**
  57121. * Creates a SimplificationSettings
  57122. * @param quality expected quality
  57123. * @param distance distance when this optimized version should be used
  57124. * @param optimizeMesh already optimized mesh
  57125. */
  57126. constructor(
  57127. /** expected quality */
  57128. quality: number,
  57129. /** distance when this optimized version should be used */
  57130. distance: number,
  57131. /** already optimized mesh */
  57132. optimizeMesh?: boolean | undefined);
  57133. }
  57134. /**
  57135. * Interface used to define a simplification task
  57136. */
  57137. export interface ISimplificationTask {
  57138. /**
  57139. * Array of settings
  57140. */
  57141. settings: Array<ISimplificationSettings>;
  57142. /**
  57143. * Simplification type
  57144. */
  57145. simplificationType: SimplificationType;
  57146. /**
  57147. * Mesh to simplify
  57148. */
  57149. mesh: Mesh;
  57150. /**
  57151. * Callback called on success
  57152. */
  57153. successCallback?: () => void;
  57154. /**
  57155. * Defines if parallel processing can be used
  57156. */
  57157. parallelProcessing: boolean;
  57158. }
  57159. /**
  57160. * Queue used to order the simplification tasks
  57161. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57162. */
  57163. export class SimplificationQueue {
  57164. private _simplificationArray;
  57165. /**
  57166. * Gets a boolean indicating that the process is still running
  57167. */
  57168. running: boolean;
  57169. /**
  57170. * Creates a new queue
  57171. */
  57172. constructor();
  57173. /**
  57174. * Adds a new simplification task
  57175. * @param task defines a task to add
  57176. */
  57177. addTask(task: ISimplificationTask): void;
  57178. /**
  57179. * Execute next task
  57180. */
  57181. executeNext(): void;
  57182. /**
  57183. * Execute a simplification task
  57184. * @param task defines the task to run
  57185. */
  57186. runSimplification(task: ISimplificationTask): void;
  57187. private getSimplifier;
  57188. }
  57189. /**
  57190. * The implemented types of simplification
  57191. * At the moment only Quadratic Error Decimation is implemented
  57192. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57193. */
  57194. export enum SimplificationType {
  57195. /** Quadratic error decimation */
  57196. QUADRATIC = 0
  57197. }
  57198. }
  57199. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57200. import { Scene } from "babylonjs/scene";
  57201. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57202. import { ISceneComponent } from "babylonjs/sceneComponent";
  57203. module "babylonjs/scene" {
  57204. interface Scene {
  57205. /** @hidden (Backing field) */
  57206. _simplificationQueue: SimplificationQueue;
  57207. /**
  57208. * Gets or sets the simplification queue attached to the scene
  57209. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57210. */
  57211. simplificationQueue: SimplificationQueue;
  57212. }
  57213. }
  57214. module "babylonjs/Meshes/mesh" {
  57215. interface Mesh {
  57216. /**
  57217. * Simplify the mesh according to the given array of settings.
  57218. * Function will return immediately and will simplify async
  57219. * @param settings a collection of simplification settings
  57220. * @param parallelProcessing should all levels calculate parallel or one after the other
  57221. * @param simplificationType the type of simplification to run
  57222. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57223. * @returns the current mesh
  57224. */
  57225. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57226. }
  57227. }
  57228. /**
  57229. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57230. * created in a scene
  57231. */
  57232. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57233. /**
  57234. * The component name helpfull to identify the component in the list of scene components.
  57235. */
  57236. readonly name: string;
  57237. /**
  57238. * The scene the component belongs to.
  57239. */
  57240. scene: Scene;
  57241. /**
  57242. * Creates a new instance of the component for the given scene
  57243. * @param scene Defines the scene to register the component in
  57244. */
  57245. constructor(scene: Scene);
  57246. /**
  57247. * Registers the component in a given scene
  57248. */
  57249. register(): void;
  57250. /**
  57251. * Rebuilds the elements related to this component in case of
  57252. * context lost for instance.
  57253. */
  57254. rebuild(): void;
  57255. /**
  57256. * Disposes the component and the associated ressources
  57257. */
  57258. dispose(): void;
  57259. private _beforeCameraUpdate;
  57260. }
  57261. }
  57262. declare module "babylonjs/Meshes/Builders/index" {
  57263. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57264. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57265. export * from "babylonjs/Meshes/Builders/discBuilder";
  57266. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57267. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57268. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57269. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57270. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57271. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57272. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57273. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57274. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57275. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57276. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57277. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57278. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57279. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57280. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57281. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57282. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57283. }
  57284. declare module "babylonjs/Meshes/index" {
  57285. export * from "babylonjs/Meshes/abstractMesh";
  57286. export * from "babylonjs/Meshes/buffer";
  57287. export * from "babylonjs/Meshes/Compression/index";
  57288. export * from "babylonjs/Meshes/csg";
  57289. export * from "babylonjs/Meshes/geometry";
  57290. export * from "babylonjs/Meshes/groundMesh";
  57291. export * from "babylonjs/Meshes/trailMesh";
  57292. export * from "babylonjs/Meshes/instancedMesh";
  57293. export * from "babylonjs/Meshes/linesMesh";
  57294. export * from "babylonjs/Meshes/mesh";
  57295. export * from "babylonjs/Meshes/mesh.vertexData";
  57296. export * from "babylonjs/Meshes/meshBuilder";
  57297. export * from "babylonjs/Meshes/meshSimplification";
  57298. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57299. export * from "babylonjs/Meshes/polygonMesh";
  57300. export * from "babylonjs/Meshes/subMesh";
  57301. export * from "babylonjs/Meshes/meshLODLevel";
  57302. export * from "babylonjs/Meshes/transformNode";
  57303. export * from "babylonjs/Meshes/Builders/index";
  57304. export * from "babylonjs/Meshes/dataBuffer";
  57305. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57306. }
  57307. declare module "babylonjs/Morph/index" {
  57308. export * from "babylonjs/Morph/morphTarget";
  57309. export * from "babylonjs/Morph/morphTargetManager";
  57310. }
  57311. declare module "babylonjs/Navigation/INavigationEngine" {
  57312. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57313. import { Vector3 } from "babylonjs/Maths/math";
  57314. import { Mesh } from "babylonjs/Meshes/mesh";
  57315. import { Scene } from "babylonjs/scene";
  57316. /**
  57317. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57318. */
  57319. export interface INavigationEnginePlugin {
  57320. /**
  57321. * plugin name
  57322. */
  57323. name: string;
  57324. /**
  57325. * Creates a navigation mesh
  57326. * @param meshes array of all the geometry used to compute the navigatio mesh
  57327. * @param parameters bunch of parameters used to filter geometry
  57328. */
  57329. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57330. /**
  57331. * Create a navigation mesh debug mesh
  57332. * @param scene is where the mesh will be added
  57333. * @returns debug display mesh
  57334. */
  57335. createDebugNavMesh(scene: Scene): Mesh;
  57336. /**
  57337. * Get a navigation mesh constrained position, closest to the parameter position
  57338. * @param position world position
  57339. * @returns the closest point to position constrained by the navigation mesh
  57340. */
  57341. getClosestPoint(position: Vector3): Vector3;
  57342. /**
  57343. * Get a navigation mesh constrained position, within a particular radius
  57344. * @param position world position
  57345. * @param maxRadius the maximum distance to the constrained world position
  57346. * @returns the closest point to position constrained by the navigation mesh
  57347. */
  57348. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57349. /**
  57350. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57351. * @param start world position
  57352. * @param end world position
  57353. * @returns array containing world position composing the path
  57354. */
  57355. computePath(start: Vector3, end: Vector3): Vector3[];
  57356. /**
  57357. * If this plugin is supported
  57358. * @returns true if plugin is supported
  57359. */
  57360. isSupported(): boolean;
  57361. /**
  57362. * Create a new Crowd so you can add agents
  57363. * @param maxAgents the maximum agent count in the crowd
  57364. * @param maxAgentRadius the maximum radius an agent can have
  57365. * @param scene to attach the crowd to
  57366. * @returns the crowd you can add agents to
  57367. */
  57368. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57369. /**
  57370. * Release all resources
  57371. */
  57372. dispose(): void;
  57373. }
  57374. /**
  57375. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57376. */
  57377. export interface ICrowd {
  57378. /**
  57379. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57380. * You can attach anything to that node. The node position is updated in the scene update tick.
  57381. * @param pos world position that will be constrained by the navigation mesh
  57382. * @param parameters agent parameters
  57383. * @param transform hooked to the agent that will be update by the scene
  57384. * @returns agent index
  57385. */
  57386. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57387. /**
  57388. * Returns the agent position in world space
  57389. * @param index agent index returned by addAgent
  57390. * @returns world space position
  57391. */
  57392. getAgentPosition(index: number): Vector3;
  57393. /**
  57394. * Gets the agent velocity in world space
  57395. * @param index agent index returned by addAgent
  57396. * @returns world space velocity
  57397. */
  57398. getAgentVelocity(index: number): Vector3;
  57399. /**
  57400. * remove a particular agent previously created
  57401. * @param index agent index returned by addAgent
  57402. */
  57403. removeAgent(index: number): void;
  57404. /**
  57405. * get the list of all agents attached to this crowd
  57406. * @returns list of agent indices
  57407. */
  57408. getAgents(): number[];
  57409. /**
  57410. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57411. * @param deltaTime in seconds
  57412. */
  57413. update(deltaTime: number): void;
  57414. /**
  57415. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57416. * @param index agent index returned by addAgent
  57417. * @param destination targeted world position
  57418. */
  57419. agentGoto(index: number, destination: Vector3): void;
  57420. /**
  57421. * Release all resources
  57422. */
  57423. dispose(): void;
  57424. }
  57425. /**
  57426. * Configures an agent
  57427. */
  57428. export interface IAgentParameters {
  57429. /**
  57430. * Agent radius. [Limit: >= 0]
  57431. */
  57432. radius: number;
  57433. /**
  57434. * Agent height. [Limit: > 0]
  57435. */
  57436. height: number;
  57437. /**
  57438. * Maximum allowed acceleration. [Limit: >= 0]
  57439. */
  57440. maxAcceleration: number;
  57441. /**
  57442. * Maximum allowed speed. [Limit: >= 0]
  57443. */
  57444. maxSpeed: number;
  57445. /**
  57446. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57447. */
  57448. collisionQueryRange: number;
  57449. /**
  57450. * The path visibility optimization range. [Limit: > 0]
  57451. */
  57452. pathOptimizationRange: number;
  57453. /**
  57454. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57455. */
  57456. separationWeight: number;
  57457. }
  57458. /**
  57459. * Configures the navigation mesh creation
  57460. */
  57461. export interface INavMeshParameters {
  57462. /**
  57463. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57464. */
  57465. cs: number;
  57466. /**
  57467. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57468. */
  57469. ch: number;
  57470. /**
  57471. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57472. */
  57473. walkableSlopeAngle: number;
  57474. /**
  57475. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57476. * be considered walkable. [Limit: >= 3] [Units: vx]
  57477. */
  57478. walkableHeight: number;
  57479. /**
  57480. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57481. */
  57482. walkableClimb: number;
  57483. /**
  57484. * The distance to erode/shrink the walkable area of the heightfield away from
  57485. * obstructions. [Limit: >=0] [Units: vx]
  57486. */
  57487. walkableRadius: number;
  57488. /**
  57489. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57490. */
  57491. maxEdgeLen: number;
  57492. /**
  57493. * The maximum distance a simplfied contour's border edges should deviate
  57494. * the original raw contour. [Limit: >=0] [Units: vx]
  57495. */
  57496. maxSimplificationError: number;
  57497. /**
  57498. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57499. */
  57500. minRegionArea: number;
  57501. /**
  57502. * Any regions with a span count smaller than this value will, if possible,
  57503. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57504. */
  57505. mergeRegionArea: number;
  57506. /**
  57507. * The maximum number of vertices allowed for polygons generated during the
  57508. * contour to polygon conversion process. [Limit: >= 3]
  57509. */
  57510. maxVertsPerPoly: number;
  57511. /**
  57512. * Sets the sampling distance to use when generating the detail mesh.
  57513. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57514. */
  57515. detailSampleDist: number;
  57516. /**
  57517. * The maximum distance the detail mesh surface should deviate from heightfield
  57518. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57519. */
  57520. detailSampleMaxError: number;
  57521. }
  57522. }
  57523. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57524. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57525. import { Mesh } from "babylonjs/Meshes/mesh";
  57526. import { Scene } from "babylonjs/scene";
  57527. import { Vector3 } from "babylonjs/Maths/math";
  57528. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57529. /**
  57530. * RecastJS navigation plugin
  57531. */
  57532. export class RecastJSPlugin implements INavigationEnginePlugin {
  57533. /**
  57534. * Reference to the Recast library
  57535. */
  57536. bjsRECAST: any;
  57537. /**
  57538. * plugin name
  57539. */
  57540. name: string;
  57541. /**
  57542. * the first navmesh created. We might extend this to support multiple navmeshes
  57543. */
  57544. navMesh: any;
  57545. /**
  57546. * Initializes the recastJS plugin
  57547. * @param recastInjection can be used to inject your own recast reference
  57548. */
  57549. constructor(recastInjection?: any);
  57550. /**
  57551. * Creates a navigation mesh
  57552. * @param meshes array of all the geometry used to compute the navigatio mesh
  57553. * @param parameters bunch of parameters used to filter geometry
  57554. */
  57555. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57556. /**
  57557. * Create a navigation mesh debug mesh
  57558. * @param scene is where the mesh will be added
  57559. * @returns debug display mesh
  57560. */
  57561. createDebugNavMesh(scene: Scene): Mesh;
  57562. /**
  57563. * Get a navigation mesh constrained position, closest to the parameter position
  57564. * @param position world position
  57565. * @returns the closest point to position constrained by the navigation mesh
  57566. */
  57567. getClosestPoint(position: Vector3): Vector3;
  57568. /**
  57569. * Get a navigation mesh constrained position, within a particular radius
  57570. * @param position world position
  57571. * @param maxRadius the maximum distance to the constrained world position
  57572. * @returns the closest point to position constrained by the navigation mesh
  57573. */
  57574. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57575. /**
  57576. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57577. * @param start world position
  57578. * @param end world position
  57579. * @returns array containing world position composing the path
  57580. */
  57581. computePath(start: Vector3, end: Vector3): Vector3[];
  57582. /**
  57583. * Create a new Crowd so you can add agents
  57584. * @param maxAgents the maximum agent count in the crowd
  57585. * @param maxAgentRadius the maximum radius an agent can have
  57586. * @param scene to attach the crowd to
  57587. * @returns the crowd you can add agents to
  57588. */
  57589. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57590. /**
  57591. * Disposes
  57592. */
  57593. dispose(): void;
  57594. /**
  57595. * If this plugin is supported
  57596. * @returns true if plugin is supported
  57597. */
  57598. isSupported(): boolean;
  57599. }
  57600. /**
  57601. * Recast detour crowd implementation
  57602. */
  57603. export class RecastJSCrowd implements ICrowd {
  57604. /**
  57605. * Recast/detour plugin
  57606. */
  57607. bjsRECASTPlugin: RecastJSPlugin;
  57608. /**
  57609. * Link to the detour crowd
  57610. */
  57611. recastCrowd: any;
  57612. /**
  57613. * One transform per agent
  57614. */
  57615. transforms: TransformNode[];
  57616. /**
  57617. * All agents created
  57618. */
  57619. agents: number[];
  57620. /**
  57621. * Link to the scene is kept to unregister the crowd from the scene
  57622. */
  57623. private _scene;
  57624. /**
  57625. * Observer for crowd updates
  57626. */
  57627. private _onBeforeAnimationsObserver;
  57628. /**
  57629. * Constructor
  57630. * @param plugin recastJS plugin
  57631. * @param maxAgents the maximum agent count in the crowd
  57632. * @param maxAgentRadius the maximum radius an agent can have
  57633. * @param scene to attach the crowd to
  57634. * @returns the crowd you can add agents to
  57635. */
  57636. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57637. /**
  57638. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57639. * You can attach anything to that node. The node position is updated in the scene update tick.
  57640. * @param pos world position that will be constrained by the navigation mesh
  57641. * @param parameters agent parameters
  57642. * @param transform hooked to the agent that will be update by the scene
  57643. * @returns agent index
  57644. */
  57645. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57646. /**
  57647. * Returns the agent position in world space
  57648. * @param index agent index returned by addAgent
  57649. * @returns world space position
  57650. */
  57651. getAgentPosition(index: number): Vector3;
  57652. /**
  57653. * Returns the agent velocity in world space
  57654. * @param index agent index returned by addAgent
  57655. * @returns world space velocity
  57656. */
  57657. getAgentVelocity(index: number): Vector3;
  57658. /**
  57659. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57660. * @param index agent index returned by addAgent
  57661. * @param destination targeted world position
  57662. */
  57663. agentGoto(index: number, destination: Vector3): void;
  57664. /**
  57665. * remove a particular agent previously created
  57666. * @param index agent index returned by addAgent
  57667. */
  57668. removeAgent(index: number): void;
  57669. /**
  57670. * get the list of all agents attached to this crowd
  57671. * @returns list of agent indices
  57672. */
  57673. getAgents(): number[];
  57674. /**
  57675. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57676. * @param deltaTime in seconds
  57677. */
  57678. update(deltaTime: number): void;
  57679. /**
  57680. * Release all resources
  57681. */
  57682. dispose(): void;
  57683. }
  57684. }
  57685. declare module "babylonjs/Navigation/Plugins/index" {
  57686. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57687. }
  57688. declare module "babylonjs/Navigation/index" {
  57689. export * from "babylonjs/Navigation/INavigationEngine";
  57690. export * from "babylonjs/Navigation/Plugins/index";
  57691. }
  57692. declare module "babylonjs/Offline/database" {
  57693. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57694. /**
  57695. * Class used to enable access to IndexedDB
  57696. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57697. */
  57698. export class Database implements IOfflineProvider {
  57699. private _callbackManifestChecked;
  57700. private _currentSceneUrl;
  57701. private _db;
  57702. private _enableSceneOffline;
  57703. private _enableTexturesOffline;
  57704. private _manifestVersionFound;
  57705. private _mustUpdateRessources;
  57706. private _hasReachedQuota;
  57707. private _isSupported;
  57708. private _idbFactory;
  57709. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57710. private static IsUASupportingBlobStorage;
  57711. /**
  57712. * Gets a boolean indicating if Database storate is enabled (off by default)
  57713. */
  57714. static IDBStorageEnabled: boolean;
  57715. /**
  57716. * Gets a boolean indicating if scene must be saved in the database
  57717. */
  57718. readonly enableSceneOffline: boolean;
  57719. /**
  57720. * Gets a boolean indicating if textures must be saved in the database
  57721. */
  57722. readonly enableTexturesOffline: boolean;
  57723. /**
  57724. * Creates a new Database
  57725. * @param urlToScene defines the url to load the scene
  57726. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57727. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57728. */
  57729. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57730. private static _ParseURL;
  57731. private static _ReturnFullUrlLocation;
  57732. private _checkManifestFile;
  57733. /**
  57734. * Open the database and make it available
  57735. * @param successCallback defines the callback to call on success
  57736. * @param errorCallback defines the callback to call on error
  57737. */
  57738. open(successCallback: () => void, errorCallback: () => void): void;
  57739. /**
  57740. * Loads an image from the database
  57741. * @param url defines the url to load from
  57742. * @param image defines the target DOM image
  57743. */
  57744. loadImage(url: string, image: HTMLImageElement): void;
  57745. private _loadImageFromDBAsync;
  57746. private _saveImageIntoDBAsync;
  57747. private _checkVersionFromDB;
  57748. private _loadVersionFromDBAsync;
  57749. private _saveVersionIntoDBAsync;
  57750. /**
  57751. * Loads a file from database
  57752. * @param url defines the URL to load from
  57753. * @param sceneLoaded defines a callback to call on success
  57754. * @param progressCallBack defines a callback to call when progress changed
  57755. * @param errorCallback defines a callback to call on error
  57756. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57757. */
  57758. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57759. private _loadFileAsync;
  57760. private _saveFileAsync;
  57761. /**
  57762. * Validates if xhr data is correct
  57763. * @param xhr defines the request to validate
  57764. * @param dataType defines the expected data type
  57765. * @returns true if data is correct
  57766. */
  57767. private static _ValidateXHRData;
  57768. }
  57769. }
  57770. declare module "babylonjs/Offline/index" {
  57771. export * from "babylonjs/Offline/database";
  57772. export * from "babylonjs/Offline/IOfflineProvider";
  57773. }
  57774. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57775. /** @hidden */
  57776. export var gpuUpdateParticlesPixelShader: {
  57777. name: string;
  57778. shader: string;
  57779. };
  57780. }
  57781. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57782. /** @hidden */
  57783. export var gpuUpdateParticlesVertexShader: {
  57784. name: string;
  57785. shader: string;
  57786. };
  57787. }
  57788. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57789. /** @hidden */
  57790. export var clipPlaneFragmentDeclaration2: {
  57791. name: string;
  57792. shader: string;
  57793. };
  57794. }
  57795. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57796. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57797. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57798. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57799. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57800. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57801. /** @hidden */
  57802. export var gpuRenderParticlesPixelShader: {
  57803. name: string;
  57804. shader: string;
  57805. };
  57806. }
  57807. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57808. /** @hidden */
  57809. export var clipPlaneVertexDeclaration2: {
  57810. name: string;
  57811. shader: string;
  57812. };
  57813. }
  57814. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57815. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57816. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57817. /** @hidden */
  57818. export var gpuRenderParticlesVertexShader: {
  57819. name: string;
  57820. shader: string;
  57821. };
  57822. }
  57823. declare module "babylonjs/Particles/gpuParticleSystem" {
  57824. import { Nullable } from "babylonjs/types";
  57825. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57826. import { Observable } from "babylonjs/Misc/observable";
  57827. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57828. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57829. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57830. import { Scene, IDisposable } from "babylonjs/scene";
  57831. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57832. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57833. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57834. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57835. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57836. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57837. /**
  57838. * This represents a GPU particle system in Babylon
  57839. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57840. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57841. */
  57842. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57843. /**
  57844. * The layer mask we are rendering the particles through.
  57845. */
  57846. layerMask: number;
  57847. private _capacity;
  57848. private _activeCount;
  57849. private _currentActiveCount;
  57850. private _accumulatedCount;
  57851. private _renderEffect;
  57852. private _updateEffect;
  57853. private _buffer0;
  57854. private _buffer1;
  57855. private _spriteBuffer;
  57856. private _updateVAO;
  57857. private _renderVAO;
  57858. private _targetIndex;
  57859. private _sourceBuffer;
  57860. private _targetBuffer;
  57861. private _engine;
  57862. private _currentRenderId;
  57863. private _started;
  57864. private _stopped;
  57865. private _timeDelta;
  57866. private _randomTexture;
  57867. private _randomTexture2;
  57868. private _attributesStrideSize;
  57869. private _updateEffectOptions;
  57870. private _randomTextureSize;
  57871. private _actualFrame;
  57872. private readonly _rawTextureWidth;
  57873. /**
  57874. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57875. */
  57876. static readonly IsSupported: boolean;
  57877. /**
  57878. * An event triggered when the system is disposed.
  57879. */
  57880. onDisposeObservable: Observable<GPUParticleSystem>;
  57881. /**
  57882. * Gets the maximum number of particles active at the same time.
  57883. * @returns The max number of active particles.
  57884. */
  57885. getCapacity(): number;
  57886. /**
  57887. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57888. * to override the particles.
  57889. */
  57890. forceDepthWrite: boolean;
  57891. /**
  57892. * Gets or set the number of active particles
  57893. */
  57894. activeParticleCount: number;
  57895. private _preWarmDone;
  57896. /**
  57897. * Is this system ready to be used/rendered
  57898. * @return true if the system is ready
  57899. */
  57900. isReady(): boolean;
  57901. /**
  57902. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57903. * @returns True if it has been started, otherwise false.
  57904. */
  57905. isStarted(): boolean;
  57906. /**
  57907. * Starts the particle system and begins to emit
  57908. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57909. */
  57910. start(delay?: number): void;
  57911. /**
  57912. * Stops the particle system.
  57913. */
  57914. stop(): void;
  57915. /**
  57916. * Remove all active particles
  57917. */
  57918. reset(): void;
  57919. /**
  57920. * Returns the string "GPUParticleSystem"
  57921. * @returns a string containing the class name
  57922. */
  57923. getClassName(): string;
  57924. private _colorGradientsTexture;
  57925. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57926. /**
  57927. * Adds a new color gradient
  57928. * @param gradient defines the gradient to use (between 0 and 1)
  57929. * @param color1 defines the color to affect to the specified gradient
  57930. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57931. * @returns the current particle system
  57932. */
  57933. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57934. /**
  57935. * Remove a specific color gradient
  57936. * @param gradient defines the gradient to remove
  57937. * @returns the current particle system
  57938. */
  57939. removeColorGradient(gradient: number): GPUParticleSystem;
  57940. private _angularSpeedGradientsTexture;
  57941. private _sizeGradientsTexture;
  57942. private _velocityGradientsTexture;
  57943. private _limitVelocityGradientsTexture;
  57944. private _dragGradientsTexture;
  57945. private _addFactorGradient;
  57946. /**
  57947. * Adds a new size gradient
  57948. * @param gradient defines the gradient to use (between 0 and 1)
  57949. * @param factor defines the size factor to affect to the specified gradient
  57950. * @returns the current particle system
  57951. */
  57952. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57953. /**
  57954. * Remove a specific size gradient
  57955. * @param gradient defines the gradient to remove
  57956. * @returns the current particle system
  57957. */
  57958. removeSizeGradient(gradient: number): GPUParticleSystem;
  57959. /**
  57960. * Adds a new angular speed gradient
  57961. * @param gradient defines the gradient to use (between 0 and 1)
  57962. * @param factor defines the angular speed to affect to the specified gradient
  57963. * @returns the current particle system
  57964. */
  57965. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57966. /**
  57967. * Remove a specific angular speed gradient
  57968. * @param gradient defines the gradient to remove
  57969. * @returns the current particle system
  57970. */
  57971. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57972. /**
  57973. * Adds a new velocity gradient
  57974. * @param gradient defines the gradient to use (between 0 and 1)
  57975. * @param factor defines the velocity to affect to the specified gradient
  57976. * @returns the current particle system
  57977. */
  57978. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57979. /**
  57980. * Remove a specific velocity gradient
  57981. * @param gradient defines the gradient to remove
  57982. * @returns the current particle system
  57983. */
  57984. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57985. /**
  57986. * Adds a new limit velocity gradient
  57987. * @param gradient defines the gradient to use (between 0 and 1)
  57988. * @param factor defines the limit velocity value to affect to the specified gradient
  57989. * @returns the current particle system
  57990. */
  57991. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57992. /**
  57993. * Remove a specific limit velocity gradient
  57994. * @param gradient defines the gradient to remove
  57995. * @returns the current particle system
  57996. */
  57997. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57998. /**
  57999. * Adds a new drag gradient
  58000. * @param gradient defines the gradient to use (between 0 and 1)
  58001. * @param factor defines the drag value to affect to the specified gradient
  58002. * @returns the current particle system
  58003. */
  58004. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  58005. /**
  58006. * Remove a specific drag gradient
  58007. * @param gradient defines the gradient to remove
  58008. * @returns the current particle system
  58009. */
  58010. removeDragGradient(gradient: number): GPUParticleSystem;
  58011. /**
  58012. * Not supported by GPUParticleSystem
  58013. * @param gradient defines the gradient to use (between 0 and 1)
  58014. * @param factor defines the emit rate value to affect to the specified gradient
  58015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58016. * @returns the current particle system
  58017. */
  58018. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58019. /**
  58020. * Not supported by GPUParticleSystem
  58021. * @param gradient defines the gradient to remove
  58022. * @returns the current particle system
  58023. */
  58024. removeEmitRateGradient(gradient: number): IParticleSystem;
  58025. /**
  58026. * Not supported by GPUParticleSystem
  58027. * @param gradient defines the gradient to use (between 0 and 1)
  58028. * @param factor defines the start size value to affect to the specified gradient
  58029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58030. * @returns the current particle system
  58031. */
  58032. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58033. /**
  58034. * Not supported by GPUParticleSystem
  58035. * @param gradient defines the gradient to remove
  58036. * @returns the current particle system
  58037. */
  58038. removeStartSizeGradient(gradient: number): IParticleSystem;
  58039. /**
  58040. * Not supported by GPUParticleSystem
  58041. * @param gradient defines the gradient to use (between 0 and 1)
  58042. * @param min defines the color remap minimal range
  58043. * @param max defines the color remap maximal range
  58044. * @returns the current particle system
  58045. */
  58046. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58047. /**
  58048. * Not supported by GPUParticleSystem
  58049. * @param gradient defines the gradient to remove
  58050. * @returns the current particle system
  58051. */
  58052. removeColorRemapGradient(): IParticleSystem;
  58053. /**
  58054. * Not supported by GPUParticleSystem
  58055. * @param gradient defines the gradient to use (between 0 and 1)
  58056. * @param min defines the alpha remap minimal range
  58057. * @param max defines the alpha remap maximal range
  58058. * @returns the current particle system
  58059. */
  58060. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58061. /**
  58062. * Not supported by GPUParticleSystem
  58063. * @param gradient defines the gradient to remove
  58064. * @returns the current particle system
  58065. */
  58066. removeAlphaRemapGradient(): IParticleSystem;
  58067. /**
  58068. * Not supported by GPUParticleSystem
  58069. * @param gradient defines the gradient to use (between 0 and 1)
  58070. * @param color defines the color to affect to the specified gradient
  58071. * @returns the current particle system
  58072. */
  58073. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58074. /**
  58075. * Not supported by GPUParticleSystem
  58076. * @param gradient defines the gradient to remove
  58077. * @returns the current particle system
  58078. */
  58079. removeRampGradient(): IParticleSystem;
  58080. /**
  58081. * Not supported by GPUParticleSystem
  58082. * @returns the list of ramp gradients
  58083. */
  58084. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58085. /**
  58086. * Not supported by GPUParticleSystem
  58087. * Gets or sets a boolean indicating that ramp gradients must be used
  58088. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58089. */
  58090. useRampGradients: boolean;
  58091. /**
  58092. * Not supported by GPUParticleSystem
  58093. * @param gradient defines the gradient to use (between 0 and 1)
  58094. * @param factor defines the life time factor to affect to the specified gradient
  58095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58096. * @returns the current particle system
  58097. */
  58098. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58099. /**
  58100. * Not supported by GPUParticleSystem
  58101. * @param gradient defines the gradient to remove
  58102. * @returns the current particle system
  58103. */
  58104. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58105. /**
  58106. * Instantiates a GPU particle system.
  58107. * 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.
  58108. * @param name The name of the particle system
  58109. * @param options The options used to create the system
  58110. * @param scene The scene the particle system belongs to
  58111. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58112. */
  58113. constructor(name: string, options: Partial<{
  58114. capacity: number;
  58115. randomTextureSize: number;
  58116. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58117. protected _reset(): void;
  58118. private _createUpdateVAO;
  58119. private _createRenderVAO;
  58120. private _initialize;
  58121. /** @hidden */
  58122. _recreateUpdateEffect(): void;
  58123. /** @hidden */
  58124. _recreateRenderEffect(): void;
  58125. /**
  58126. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58127. * @param preWarm defines if we are in the pre-warmimg phase
  58128. */
  58129. animate(preWarm?: boolean): void;
  58130. private _createFactorGradientTexture;
  58131. private _createSizeGradientTexture;
  58132. private _createAngularSpeedGradientTexture;
  58133. private _createVelocityGradientTexture;
  58134. private _createLimitVelocityGradientTexture;
  58135. private _createDragGradientTexture;
  58136. private _createColorGradientTexture;
  58137. /**
  58138. * Renders the particle system in its current state
  58139. * @param preWarm defines if the system should only update the particles but not render them
  58140. * @returns the current number of particles
  58141. */
  58142. render(preWarm?: boolean): number;
  58143. /**
  58144. * Rebuilds the particle system
  58145. */
  58146. rebuild(): void;
  58147. private _releaseBuffers;
  58148. private _releaseVAOs;
  58149. /**
  58150. * Disposes the particle system and free the associated resources
  58151. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58152. */
  58153. dispose(disposeTexture?: boolean): void;
  58154. /**
  58155. * Clones the particle system.
  58156. * @param name The name of the cloned object
  58157. * @param newEmitter The new emitter to use
  58158. * @returns the cloned particle system
  58159. */
  58160. clone(name: string, newEmitter: any): GPUParticleSystem;
  58161. /**
  58162. * Serializes the particle system to a JSON object.
  58163. * @returns the JSON object
  58164. */
  58165. serialize(): any;
  58166. /**
  58167. * Parses a JSON object to create a GPU particle system.
  58168. * @param parsedParticleSystem The JSON object to parse
  58169. * @param scene The scene to create the particle system in
  58170. * @param rootUrl The root url to use to load external dependencies like texture
  58171. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58172. * @returns the parsed GPU particle system
  58173. */
  58174. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58175. }
  58176. }
  58177. declare module "babylonjs/Particles/particleSystemSet" {
  58178. import { Nullable } from "babylonjs/types";
  58179. import { Color3 } from "babylonjs/Maths/math.color";
  58180. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58182. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58183. import { Scene, IDisposable } from "babylonjs/scene";
  58184. /**
  58185. * Represents a set of particle systems working together to create a specific effect
  58186. */
  58187. export class ParticleSystemSet implements IDisposable {
  58188. private _emitterCreationOptions;
  58189. private _emitterNode;
  58190. /**
  58191. * Gets the particle system list
  58192. */
  58193. systems: IParticleSystem[];
  58194. /**
  58195. * Gets the emitter node used with this set
  58196. */
  58197. readonly emitterNode: Nullable<TransformNode>;
  58198. /**
  58199. * Creates a new emitter mesh as a sphere
  58200. * @param options defines the options used to create the sphere
  58201. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58202. * @param scene defines the hosting scene
  58203. */
  58204. setEmitterAsSphere(options: {
  58205. diameter: number;
  58206. segments: number;
  58207. color: Color3;
  58208. }, renderingGroupId: number, scene: Scene): void;
  58209. /**
  58210. * Starts all particle systems of the set
  58211. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58212. */
  58213. start(emitter?: AbstractMesh): void;
  58214. /**
  58215. * Release all associated resources
  58216. */
  58217. dispose(): void;
  58218. /**
  58219. * Serialize the set into a JSON compatible object
  58220. * @returns a JSON compatible representation of the set
  58221. */
  58222. serialize(): any;
  58223. /**
  58224. * Parse a new ParticleSystemSet from a serialized source
  58225. * @param data defines a JSON compatible representation of the set
  58226. * @param scene defines the hosting scene
  58227. * @param gpu defines if we want GPU particles or CPU particles
  58228. * @returns a new ParticleSystemSet
  58229. */
  58230. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58231. }
  58232. }
  58233. declare module "babylonjs/Particles/particleHelper" {
  58234. import { Nullable } from "babylonjs/types";
  58235. import { Scene } from "babylonjs/scene";
  58236. import { Vector3 } from "babylonjs/Maths/math.vector";
  58237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58238. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58239. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58240. /**
  58241. * This class is made for on one-liner static method to help creating particle system set.
  58242. */
  58243. export class ParticleHelper {
  58244. /**
  58245. * Gets or sets base Assets URL
  58246. */
  58247. static BaseAssetsUrl: string;
  58248. /**
  58249. * Create a default particle system that you can tweak
  58250. * @param emitter defines the emitter to use
  58251. * @param capacity defines the system capacity (default is 500 particles)
  58252. * @param scene defines the hosting scene
  58253. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58254. * @returns the new Particle system
  58255. */
  58256. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58257. /**
  58258. * This is the main static method (one-liner) of this helper to create different particle systems
  58259. * @param type This string represents the type to the particle system to create
  58260. * @param scene The scene where the particle system should live
  58261. * @param gpu If the system will use gpu
  58262. * @returns the ParticleSystemSet created
  58263. */
  58264. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58265. /**
  58266. * Static function used to export a particle system to a ParticleSystemSet variable.
  58267. * Please note that the emitter shape is not exported
  58268. * @param systems defines the particle systems to export
  58269. * @returns the created particle system set
  58270. */
  58271. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58272. }
  58273. }
  58274. declare module "babylonjs/Particles/particleSystemComponent" {
  58275. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58276. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58277. import "babylonjs/Shaders/particles.vertex";
  58278. module "babylonjs/Engines/engine" {
  58279. interface Engine {
  58280. /**
  58281. * Create an effect to use with particle systems.
  58282. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58283. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58284. * @param uniformsNames defines a list of attribute names
  58285. * @param samplers defines an array of string used to represent textures
  58286. * @param defines defines the string containing the defines to use to compile the shaders
  58287. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58288. * @param onCompiled defines a function to call when the effect creation is successful
  58289. * @param onError defines a function to call when the effect creation has failed
  58290. * @returns the new Effect
  58291. */
  58292. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58293. }
  58294. }
  58295. module "babylonjs/Meshes/mesh" {
  58296. interface Mesh {
  58297. /**
  58298. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58299. * @returns an array of IParticleSystem
  58300. */
  58301. getEmittedParticleSystems(): IParticleSystem[];
  58302. /**
  58303. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58304. * @returns an array of IParticleSystem
  58305. */
  58306. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58307. }
  58308. }
  58309. /**
  58310. * @hidden
  58311. */
  58312. export var _IDoNeedToBeInTheBuild: number;
  58313. }
  58314. declare module "babylonjs/Particles/index" {
  58315. export * from "babylonjs/Particles/baseParticleSystem";
  58316. export * from "babylonjs/Particles/EmitterTypes/index";
  58317. export * from "babylonjs/Particles/gpuParticleSystem";
  58318. export * from "babylonjs/Particles/IParticleSystem";
  58319. export * from "babylonjs/Particles/particle";
  58320. export * from "babylonjs/Particles/particleHelper";
  58321. export * from "babylonjs/Particles/particleSystem";
  58322. export * from "babylonjs/Particles/particleSystemComponent";
  58323. export * from "babylonjs/Particles/particleSystemSet";
  58324. export * from "babylonjs/Particles/solidParticle";
  58325. export * from "babylonjs/Particles/solidParticleSystem";
  58326. export * from "babylonjs/Particles/subEmitter";
  58327. }
  58328. declare module "babylonjs/Physics/physicsEngineComponent" {
  58329. import { Nullable } from "babylonjs/types";
  58330. import { Observable, Observer } from "babylonjs/Misc/observable";
  58331. import { Vector3 } from "babylonjs/Maths/math.vector";
  58332. import { Mesh } from "babylonjs/Meshes/mesh";
  58333. import { ISceneComponent } from "babylonjs/sceneComponent";
  58334. import { Scene } from "babylonjs/scene";
  58335. import { Node } from "babylonjs/node";
  58336. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58337. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58338. module "babylonjs/scene" {
  58339. interface Scene {
  58340. /** @hidden (Backing field) */
  58341. _physicsEngine: Nullable<IPhysicsEngine>;
  58342. /**
  58343. * Gets the current physics engine
  58344. * @returns a IPhysicsEngine or null if none attached
  58345. */
  58346. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58347. /**
  58348. * Enables physics to the current scene
  58349. * @param gravity defines the scene's gravity for the physics engine
  58350. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58351. * @return a boolean indicating if the physics engine was initialized
  58352. */
  58353. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58354. /**
  58355. * Disables and disposes the physics engine associated with the scene
  58356. */
  58357. disablePhysicsEngine(): void;
  58358. /**
  58359. * Gets a boolean indicating if there is an active physics engine
  58360. * @returns a boolean indicating if there is an active physics engine
  58361. */
  58362. isPhysicsEnabled(): boolean;
  58363. /**
  58364. * Deletes a physics compound impostor
  58365. * @param compound defines the compound to delete
  58366. */
  58367. deleteCompoundImpostor(compound: any): void;
  58368. /**
  58369. * An event triggered when physic simulation is about to be run
  58370. */
  58371. onBeforePhysicsObservable: Observable<Scene>;
  58372. /**
  58373. * An event triggered when physic simulation has been done
  58374. */
  58375. onAfterPhysicsObservable: Observable<Scene>;
  58376. }
  58377. }
  58378. module "babylonjs/Meshes/abstractMesh" {
  58379. interface AbstractMesh {
  58380. /** @hidden */
  58381. _physicsImpostor: Nullable<PhysicsImpostor>;
  58382. /**
  58383. * Gets or sets impostor used for physic simulation
  58384. * @see http://doc.babylonjs.com/features/physics_engine
  58385. */
  58386. physicsImpostor: Nullable<PhysicsImpostor>;
  58387. /**
  58388. * Gets the current physics impostor
  58389. * @see http://doc.babylonjs.com/features/physics_engine
  58390. * @returns a physics impostor or null
  58391. */
  58392. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58393. /** Apply a physic impulse to the mesh
  58394. * @param force defines the force to apply
  58395. * @param contactPoint defines where to apply the force
  58396. * @returns the current mesh
  58397. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58398. */
  58399. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58400. /**
  58401. * Creates a physic joint between two meshes
  58402. * @param otherMesh defines the other mesh to use
  58403. * @param pivot1 defines the pivot to use on this mesh
  58404. * @param pivot2 defines the pivot to use on the other mesh
  58405. * @param options defines additional options (can be plugin dependent)
  58406. * @returns the current mesh
  58407. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58408. */
  58409. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58410. /** @hidden */
  58411. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58412. }
  58413. }
  58414. /**
  58415. * Defines the physics engine scene component responsible to manage a physics engine
  58416. */
  58417. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58418. /**
  58419. * The component name helpful to identify the component in the list of scene components.
  58420. */
  58421. readonly name: string;
  58422. /**
  58423. * The scene the component belongs to.
  58424. */
  58425. scene: Scene;
  58426. /**
  58427. * Creates a new instance of the component for the given scene
  58428. * @param scene Defines the scene to register the component in
  58429. */
  58430. constructor(scene: Scene);
  58431. /**
  58432. * Registers the component in a given scene
  58433. */
  58434. register(): void;
  58435. /**
  58436. * Rebuilds the elements related to this component in case of
  58437. * context lost for instance.
  58438. */
  58439. rebuild(): void;
  58440. /**
  58441. * Disposes the component and the associated ressources
  58442. */
  58443. dispose(): void;
  58444. }
  58445. }
  58446. declare module "babylonjs/Physics/physicsHelper" {
  58447. import { Nullable } from "babylonjs/types";
  58448. import { Vector3 } from "babylonjs/Maths/math.vector";
  58449. import { Mesh } from "babylonjs/Meshes/mesh";
  58450. import { Scene } from "babylonjs/scene";
  58451. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58452. /**
  58453. * A helper for physics simulations
  58454. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58455. */
  58456. export class PhysicsHelper {
  58457. private _scene;
  58458. private _physicsEngine;
  58459. /**
  58460. * Initializes the Physics helper
  58461. * @param scene Babylon.js scene
  58462. */
  58463. constructor(scene: Scene);
  58464. /**
  58465. * Applies a radial explosion impulse
  58466. * @param origin the origin of the explosion
  58467. * @param radiusOrEventOptions the radius or the options of radial explosion
  58468. * @param strength the explosion strength
  58469. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58470. * @returns A physics radial explosion event, or null
  58471. */
  58472. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58473. /**
  58474. * Applies a radial explosion force
  58475. * @param origin the origin of the explosion
  58476. * @param radiusOrEventOptions the radius or the options of radial explosion
  58477. * @param strength the explosion strength
  58478. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58479. * @returns A physics radial explosion event, or null
  58480. */
  58481. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58482. /**
  58483. * Creates a gravitational field
  58484. * @param origin the origin of the explosion
  58485. * @param radiusOrEventOptions the radius or the options of radial explosion
  58486. * @param strength the explosion strength
  58487. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58488. * @returns A physics gravitational field event, or null
  58489. */
  58490. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58491. /**
  58492. * Creates a physics updraft event
  58493. * @param origin the origin of the updraft
  58494. * @param radiusOrEventOptions the radius or the options of the updraft
  58495. * @param strength the strength of the updraft
  58496. * @param height the height of the updraft
  58497. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58498. * @returns A physics updraft event, or null
  58499. */
  58500. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58501. /**
  58502. * Creates a physics vortex event
  58503. * @param origin the of the vortex
  58504. * @param radiusOrEventOptions the radius or the options of the vortex
  58505. * @param strength the strength of the vortex
  58506. * @param height the height of the vortex
  58507. * @returns a Physics vortex event, or null
  58508. * A physics vortex event or null
  58509. */
  58510. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58511. }
  58512. /**
  58513. * Represents a physics radial explosion event
  58514. */
  58515. class PhysicsRadialExplosionEvent {
  58516. private _scene;
  58517. private _options;
  58518. private _sphere;
  58519. private _dataFetched;
  58520. /**
  58521. * Initializes a radial explosioin event
  58522. * @param _scene BabylonJS scene
  58523. * @param _options The options for the vortex event
  58524. */
  58525. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58526. /**
  58527. * Returns the data related to the radial explosion event (sphere).
  58528. * @returns The radial explosion event data
  58529. */
  58530. getData(): PhysicsRadialExplosionEventData;
  58531. /**
  58532. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58533. * @param impostor A physics imposter
  58534. * @param origin the origin of the explosion
  58535. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58536. */
  58537. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58538. /**
  58539. * Triggers affecterd impostors callbacks
  58540. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58541. */
  58542. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58543. /**
  58544. * Disposes the sphere.
  58545. * @param force Specifies if the sphere should be disposed by force
  58546. */
  58547. dispose(force?: boolean): void;
  58548. /*** Helpers ***/
  58549. private _prepareSphere;
  58550. private _intersectsWithSphere;
  58551. }
  58552. /**
  58553. * Represents a gravitational field event
  58554. */
  58555. class PhysicsGravitationalFieldEvent {
  58556. private _physicsHelper;
  58557. private _scene;
  58558. private _origin;
  58559. private _options;
  58560. private _tickCallback;
  58561. private _sphere;
  58562. private _dataFetched;
  58563. /**
  58564. * Initializes the physics gravitational field event
  58565. * @param _physicsHelper A physics helper
  58566. * @param _scene BabylonJS scene
  58567. * @param _origin The origin position of the gravitational field event
  58568. * @param _options The options for the vortex event
  58569. */
  58570. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58571. /**
  58572. * Returns the data related to the gravitational field event (sphere).
  58573. * @returns A gravitational field event
  58574. */
  58575. getData(): PhysicsGravitationalFieldEventData;
  58576. /**
  58577. * Enables the gravitational field.
  58578. */
  58579. enable(): void;
  58580. /**
  58581. * Disables the gravitational field.
  58582. */
  58583. disable(): void;
  58584. /**
  58585. * Disposes the sphere.
  58586. * @param force The force to dispose from the gravitational field event
  58587. */
  58588. dispose(force?: boolean): void;
  58589. private _tick;
  58590. }
  58591. /**
  58592. * Represents a physics updraft event
  58593. */
  58594. class PhysicsUpdraftEvent {
  58595. private _scene;
  58596. private _origin;
  58597. private _options;
  58598. private _physicsEngine;
  58599. private _originTop;
  58600. private _originDirection;
  58601. private _tickCallback;
  58602. private _cylinder;
  58603. private _cylinderPosition;
  58604. private _dataFetched;
  58605. /**
  58606. * Initializes the physics updraft event
  58607. * @param _scene BabylonJS scene
  58608. * @param _origin The origin position of the updraft
  58609. * @param _options The options for the updraft event
  58610. */
  58611. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58612. /**
  58613. * Returns the data related to the updraft event (cylinder).
  58614. * @returns A physics updraft event
  58615. */
  58616. getData(): PhysicsUpdraftEventData;
  58617. /**
  58618. * Enables the updraft.
  58619. */
  58620. enable(): void;
  58621. /**
  58622. * Disables the updraft.
  58623. */
  58624. disable(): void;
  58625. /**
  58626. * Disposes the cylinder.
  58627. * @param force Specifies if the updraft should be disposed by force
  58628. */
  58629. dispose(force?: boolean): void;
  58630. private getImpostorHitData;
  58631. private _tick;
  58632. /*** Helpers ***/
  58633. private _prepareCylinder;
  58634. private _intersectsWithCylinder;
  58635. }
  58636. /**
  58637. * Represents a physics vortex event
  58638. */
  58639. class PhysicsVortexEvent {
  58640. private _scene;
  58641. private _origin;
  58642. private _options;
  58643. private _physicsEngine;
  58644. private _originTop;
  58645. private _tickCallback;
  58646. private _cylinder;
  58647. private _cylinderPosition;
  58648. private _dataFetched;
  58649. /**
  58650. * Initializes the physics vortex event
  58651. * @param _scene The BabylonJS scene
  58652. * @param _origin The origin position of the vortex
  58653. * @param _options The options for the vortex event
  58654. */
  58655. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58656. /**
  58657. * Returns the data related to the vortex event (cylinder).
  58658. * @returns The physics vortex event data
  58659. */
  58660. getData(): PhysicsVortexEventData;
  58661. /**
  58662. * Enables the vortex.
  58663. */
  58664. enable(): void;
  58665. /**
  58666. * Disables the cortex.
  58667. */
  58668. disable(): void;
  58669. /**
  58670. * Disposes the sphere.
  58671. * @param force
  58672. */
  58673. dispose(force?: boolean): void;
  58674. private getImpostorHitData;
  58675. private _tick;
  58676. /*** Helpers ***/
  58677. private _prepareCylinder;
  58678. private _intersectsWithCylinder;
  58679. }
  58680. /**
  58681. * Options fot the radial explosion event
  58682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58683. */
  58684. export class PhysicsRadialExplosionEventOptions {
  58685. /**
  58686. * The radius of the sphere for the radial explosion.
  58687. */
  58688. radius: number;
  58689. /**
  58690. * The strenth of the explosion.
  58691. */
  58692. strength: number;
  58693. /**
  58694. * The strenght of the force in correspondence to the distance of the affected object
  58695. */
  58696. falloff: PhysicsRadialImpulseFalloff;
  58697. /**
  58698. * Sphere options for the radial explosion.
  58699. */
  58700. sphere: {
  58701. segments: number;
  58702. diameter: number;
  58703. };
  58704. /**
  58705. * Sphere options for the radial explosion.
  58706. */
  58707. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58708. }
  58709. /**
  58710. * Options fot the updraft event
  58711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58712. */
  58713. export class PhysicsUpdraftEventOptions {
  58714. /**
  58715. * The radius of the cylinder for the vortex
  58716. */
  58717. radius: number;
  58718. /**
  58719. * The strenth of the updraft.
  58720. */
  58721. strength: number;
  58722. /**
  58723. * The height of the cylinder for the updraft.
  58724. */
  58725. height: number;
  58726. /**
  58727. * The mode for the the updraft.
  58728. */
  58729. updraftMode: PhysicsUpdraftMode;
  58730. }
  58731. /**
  58732. * Options fot the vortex event
  58733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58734. */
  58735. export class PhysicsVortexEventOptions {
  58736. /**
  58737. * The radius of the cylinder for the vortex
  58738. */
  58739. radius: number;
  58740. /**
  58741. * The strenth of the vortex.
  58742. */
  58743. strength: number;
  58744. /**
  58745. * The height of the cylinder for the vortex.
  58746. */
  58747. height: number;
  58748. /**
  58749. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58750. */
  58751. centripetalForceThreshold: number;
  58752. /**
  58753. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58754. */
  58755. centripetalForceMultiplier: number;
  58756. /**
  58757. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58758. */
  58759. centrifugalForceMultiplier: number;
  58760. /**
  58761. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58762. */
  58763. updraftForceMultiplier: number;
  58764. }
  58765. /**
  58766. * The strenght of the force in correspondence to the distance of the affected object
  58767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58768. */
  58769. export enum PhysicsRadialImpulseFalloff {
  58770. /** Defines that impulse is constant in strength across it's whole radius */
  58771. Constant = 0,
  58772. /** Defines that impulse gets weaker if it's further from the origin */
  58773. Linear = 1
  58774. }
  58775. /**
  58776. * The strength of the force in correspondence to the distance of the affected object
  58777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58778. */
  58779. export enum PhysicsUpdraftMode {
  58780. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58781. Center = 0,
  58782. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58783. Perpendicular = 1
  58784. }
  58785. /**
  58786. * Interface for a physics hit data
  58787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58788. */
  58789. export interface PhysicsHitData {
  58790. /**
  58791. * The force applied at the contact point
  58792. */
  58793. force: Vector3;
  58794. /**
  58795. * The contact point
  58796. */
  58797. contactPoint: Vector3;
  58798. /**
  58799. * The distance from the origin to the contact point
  58800. */
  58801. distanceFromOrigin: number;
  58802. }
  58803. /**
  58804. * Interface for radial explosion event data
  58805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58806. */
  58807. export interface PhysicsRadialExplosionEventData {
  58808. /**
  58809. * A sphere used for the radial explosion event
  58810. */
  58811. sphere: Mesh;
  58812. }
  58813. /**
  58814. * Interface for gravitational field event data
  58815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58816. */
  58817. export interface PhysicsGravitationalFieldEventData {
  58818. /**
  58819. * A sphere mesh used for the gravitational field event
  58820. */
  58821. sphere: Mesh;
  58822. }
  58823. /**
  58824. * Interface for updraft event data
  58825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58826. */
  58827. export interface PhysicsUpdraftEventData {
  58828. /**
  58829. * A cylinder used for the updraft event
  58830. */
  58831. cylinder: Mesh;
  58832. }
  58833. /**
  58834. * Interface for vortex event data
  58835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58836. */
  58837. export interface PhysicsVortexEventData {
  58838. /**
  58839. * A cylinder used for the vortex event
  58840. */
  58841. cylinder: Mesh;
  58842. }
  58843. /**
  58844. * Interface for an affected physics impostor
  58845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58846. */
  58847. export interface PhysicsAffectedImpostorWithData {
  58848. /**
  58849. * The impostor affected by the effect
  58850. */
  58851. impostor: PhysicsImpostor;
  58852. /**
  58853. * The data about the hit/horce from the explosion
  58854. */
  58855. hitData: PhysicsHitData;
  58856. }
  58857. }
  58858. declare module "babylonjs/Physics/Plugins/index" {
  58859. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  58860. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  58861. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  58862. }
  58863. declare module "babylonjs/Physics/index" {
  58864. export * from "babylonjs/Physics/IPhysicsEngine";
  58865. export * from "babylonjs/Physics/physicsEngine";
  58866. export * from "babylonjs/Physics/physicsEngineComponent";
  58867. export * from "babylonjs/Physics/physicsHelper";
  58868. export * from "babylonjs/Physics/physicsImpostor";
  58869. export * from "babylonjs/Physics/physicsJoint";
  58870. export * from "babylonjs/Physics/Plugins/index";
  58871. }
  58872. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  58873. /** @hidden */
  58874. export var blackAndWhitePixelShader: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  58880. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58881. import { Camera } from "babylonjs/Cameras/camera";
  58882. import { Engine } from "babylonjs/Engines/engine";
  58883. import "babylonjs/Shaders/blackAndWhite.fragment";
  58884. /**
  58885. * Post process used to render in black and white
  58886. */
  58887. export class BlackAndWhitePostProcess extends PostProcess {
  58888. /**
  58889. * Linear about to convert he result to black and white (default: 1)
  58890. */
  58891. degree: number;
  58892. /**
  58893. * Creates a black and white post process
  58894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58895. * @param name The name of the effect.
  58896. * @param options The required width/height ratio to downsize to before computing the render pass.
  58897. * @param camera The camera to apply the render pass to.
  58898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58899. * @param engine The engine which the post process will be applied. (default: current engine)
  58900. * @param reusable If the post process can be reused on the same frame. (default: false)
  58901. */
  58902. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58903. }
  58904. }
  58905. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  58906. import { Nullable } from "babylonjs/types";
  58907. import { Camera } from "babylonjs/Cameras/camera";
  58908. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58909. import { Engine } from "babylonjs/Engines/engine";
  58910. /**
  58911. * This represents a set of one or more post processes in Babylon.
  58912. * A post process can be used to apply a shader to a texture after it is rendered.
  58913. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58914. */
  58915. export class PostProcessRenderEffect {
  58916. private _postProcesses;
  58917. private _getPostProcesses;
  58918. private _singleInstance;
  58919. private _cameras;
  58920. private _indicesForCamera;
  58921. /**
  58922. * Name of the effect
  58923. * @hidden
  58924. */
  58925. _name: string;
  58926. /**
  58927. * Instantiates a post process render effect.
  58928. * A post process can be used to apply a shader to a texture after it is rendered.
  58929. * @param engine The engine the effect is tied to
  58930. * @param name The name of the effect
  58931. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58932. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58933. */
  58934. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58935. /**
  58936. * Checks if all the post processes in the effect are supported.
  58937. */
  58938. readonly isSupported: boolean;
  58939. /**
  58940. * Updates the current state of the effect
  58941. * @hidden
  58942. */
  58943. _update(): void;
  58944. /**
  58945. * Attaches the effect on cameras
  58946. * @param cameras The camera to attach to.
  58947. * @hidden
  58948. */
  58949. _attachCameras(cameras: Camera): void;
  58950. /**
  58951. * Attaches the effect on cameras
  58952. * @param cameras The camera to attach to.
  58953. * @hidden
  58954. */
  58955. _attachCameras(cameras: Camera[]): void;
  58956. /**
  58957. * Detaches the effect on cameras
  58958. * @param cameras The camera to detatch from.
  58959. * @hidden
  58960. */
  58961. _detachCameras(cameras: Camera): void;
  58962. /**
  58963. * Detatches the effect on cameras
  58964. * @param cameras The camera to detatch from.
  58965. * @hidden
  58966. */
  58967. _detachCameras(cameras: Camera[]): void;
  58968. /**
  58969. * Enables the effect on given cameras
  58970. * @param cameras The camera to enable.
  58971. * @hidden
  58972. */
  58973. _enable(cameras: Camera): void;
  58974. /**
  58975. * Enables the effect on given cameras
  58976. * @param cameras The camera to enable.
  58977. * @hidden
  58978. */
  58979. _enable(cameras: Nullable<Camera[]>): void;
  58980. /**
  58981. * Disables the effect on the given cameras
  58982. * @param cameras The camera to disable.
  58983. * @hidden
  58984. */
  58985. _disable(cameras: Camera): void;
  58986. /**
  58987. * Disables the effect on the given cameras
  58988. * @param cameras The camera to disable.
  58989. * @hidden
  58990. */
  58991. _disable(cameras: Nullable<Camera[]>): void;
  58992. /**
  58993. * Gets a list of the post processes contained in the effect.
  58994. * @param camera The camera to get the post processes on.
  58995. * @returns The list of the post processes in the effect.
  58996. */
  58997. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58998. }
  58999. }
  59000. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  59001. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59002. /** @hidden */
  59003. export var extractHighlightsPixelShader: {
  59004. name: string;
  59005. shader: string;
  59006. };
  59007. }
  59008. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  59009. import { Nullable } from "babylonjs/types";
  59010. import { Camera } from "babylonjs/Cameras/camera";
  59011. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59012. import { Engine } from "babylonjs/Engines/engine";
  59013. import "babylonjs/Shaders/extractHighlights.fragment";
  59014. /**
  59015. * 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.
  59016. */
  59017. export class ExtractHighlightsPostProcess extends PostProcess {
  59018. /**
  59019. * The luminance threshold, pixels below this value will be set to black.
  59020. */
  59021. threshold: number;
  59022. /** @hidden */
  59023. _exposure: number;
  59024. /**
  59025. * Post process which has the input texture to be used when performing highlight extraction
  59026. * @hidden
  59027. */
  59028. _inputPostProcess: Nullable<PostProcess>;
  59029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59030. }
  59031. }
  59032. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59033. /** @hidden */
  59034. export var bloomMergePixelShader: {
  59035. name: string;
  59036. shader: string;
  59037. };
  59038. }
  59039. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59041. import { Nullable } from "babylonjs/types";
  59042. import { Engine } from "babylonjs/Engines/engine";
  59043. import { Camera } from "babylonjs/Cameras/camera";
  59044. import "babylonjs/Shaders/bloomMerge.fragment";
  59045. /**
  59046. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59047. */
  59048. export class BloomMergePostProcess extends PostProcess {
  59049. /** Weight of the bloom to be added to the original input. */
  59050. weight: number;
  59051. /**
  59052. * Creates a new instance of @see BloomMergePostProcess
  59053. * @param name The name of the effect.
  59054. * @param originalFromInput Post process which's input will be used for the merge.
  59055. * @param blurred Blurred highlights post process which's output will be used.
  59056. * @param weight Weight of the bloom to be added to the original input.
  59057. * @param options The required width/height ratio to downsize to before computing the render pass.
  59058. * @param camera The camera to apply the render pass to.
  59059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59060. * @param engine The engine which the post process will be applied. (default: current engine)
  59061. * @param reusable If the post process can be reused on the same frame. (default: false)
  59062. * @param textureType Type of textures used when performing the post process. (default: 0)
  59063. * @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)
  59064. */
  59065. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59066. /** Weight of the bloom to be added to the original input. */
  59067. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59068. }
  59069. }
  59070. declare module "babylonjs/PostProcesses/bloomEffect" {
  59071. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59073. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59074. import { Camera } from "babylonjs/Cameras/camera";
  59075. import { Scene } from "babylonjs/scene";
  59076. /**
  59077. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59078. */
  59079. export class BloomEffect extends PostProcessRenderEffect {
  59080. private bloomScale;
  59081. /**
  59082. * @hidden Internal
  59083. */
  59084. _effects: Array<PostProcess>;
  59085. /**
  59086. * @hidden Internal
  59087. */
  59088. _downscale: ExtractHighlightsPostProcess;
  59089. private _blurX;
  59090. private _blurY;
  59091. private _merge;
  59092. /**
  59093. * The luminance threshold to find bright areas of the image to bloom.
  59094. */
  59095. threshold: number;
  59096. /**
  59097. * The strength of the bloom.
  59098. */
  59099. weight: number;
  59100. /**
  59101. * Specifies the size of the bloom blur kernel, relative to the final output size
  59102. */
  59103. kernel: number;
  59104. /**
  59105. * Creates a new instance of @see BloomEffect
  59106. * @param scene The scene the effect belongs to.
  59107. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59108. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59109. * @param bloomWeight The the strength of bloom.
  59110. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59111. * @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)
  59112. */
  59113. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59114. /**
  59115. * Disposes each of the internal effects for a given camera.
  59116. * @param camera The camera to dispose the effect on.
  59117. */
  59118. disposeEffects(camera: Camera): void;
  59119. /**
  59120. * @hidden Internal
  59121. */
  59122. _updateEffects(): void;
  59123. /**
  59124. * Internal
  59125. * @returns if all the contained post processes are ready.
  59126. * @hidden
  59127. */
  59128. _isReady(): boolean;
  59129. }
  59130. }
  59131. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59132. /** @hidden */
  59133. export var chromaticAberrationPixelShader: {
  59134. name: string;
  59135. shader: string;
  59136. };
  59137. }
  59138. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59139. import { Vector2 } from "babylonjs/Maths/math.vector";
  59140. import { Nullable } from "babylonjs/types";
  59141. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59142. import { Camera } from "babylonjs/Cameras/camera";
  59143. import { Engine } from "babylonjs/Engines/engine";
  59144. import "babylonjs/Shaders/chromaticAberration.fragment";
  59145. /**
  59146. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59147. */
  59148. export class ChromaticAberrationPostProcess extends PostProcess {
  59149. /**
  59150. * The amount of seperation of rgb channels (default: 30)
  59151. */
  59152. aberrationAmount: number;
  59153. /**
  59154. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59155. */
  59156. radialIntensity: number;
  59157. /**
  59158. * 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))
  59159. */
  59160. direction: Vector2;
  59161. /**
  59162. * 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))
  59163. */
  59164. centerPosition: Vector2;
  59165. /**
  59166. * Creates a new instance ChromaticAberrationPostProcess
  59167. * @param name The name of the effect.
  59168. * @param screenWidth The width of the screen to apply the effect on.
  59169. * @param screenHeight The height of the screen to apply the effect on.
  59170. * @param options The required width/height ratio to downsize to before computing the render pass.
  59171. * @param camera The camera to apply the render pass to.
  59172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59173. * @param engine The engine which the post process will be applied. (default: current engine)
  59174. * @param reusable If the post process can be reused on the same frame. (default: false)
  59175. * @param textureType Type of textures used when performing the post process. (default: 0)
  59176. * @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)
  59177. */
  59178. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59179. }
  59180. }
  59181. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59182. /** @hidden */
  59183. export var circleOfConfusionPixelShader: {
  59184. name: string;
  59185. shader: string;
  59186. };
  59187. }
  59188. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59189. import { Nullable } from "babylonjs/types";
  59190. import { Engine } from "babylonjs/Engines/engine";
  59191. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59192. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59193. import { Camera } from "babylonjs/Cameras/camera";
  59194. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59195. /**
  59196. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59197. */
  59198. export class CircleOfConfusionPostProcess extends PostProcess {
  59199. /**
  59200. * 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.
  59201. */
  59202. lensSize: number;
  59203. /**
  59204. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59205. */
  59206. fStop: number;
  59207. /**
  59208. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59209. */
  59210. focusDistance: number;
  59211. /**
  59212. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59213. */
  59214. focalLength: number;
  59215. private _depthTexture;
  59216. /**
  59217. * Creates a new instance CircleOfConfusionPostProcess
  59218. * @param name The name of the effect.
  59219. * @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.
  59220. * @param options The required width/height ratio to downsize to before computing the render pass.
  59221. * @param camera The camera to apply the render pass to.
  59222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59223. * @param engine The engine which the post process will be applied. (default: current engine)
  59224. * @param reusable If the post process can be reused on the same frame. (default: false)
  59225. * @param textureType Type of textures used when performing the post process. (default: 0)
  59226. * @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)
  59227. */
  59228. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59229. /**
  59230. * 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.
  59231. */
  59232. depthTexture: RenderTargetTexture;
  59233. }
  59234. }
  59235. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59236. /** @hidden */
  59237. export var colorCorrectionPixelShader: {
  59238. name: string;
  59239. shader: string;
  59240. };
  59241. }
  59242. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59244. import { Engine } from "babylonjs/Engines/engine";
  59245. import { Camera } from "babylonjs/Cameras/camera";
  59246. import "babylonjs/Shaders/colorCorrection.fragment";
  59247. /**
  59248. *
  59249. * This post-process allows the modification of rendered colors by using
  59250. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59251. *
  59252. * The object needs to be provided an url to a texture containing the color
  59253. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59254. * Use an image editing software to tweak the LUT to match your needs.
  59255. *
  59256. * For an example of a color LUT, see here:
  59257. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59258. * For explanations on color grading, see here:
  59259. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59260. *
  59261. */
  59262. export class ColorCorrectionPostProcess extends PostProcess {
  59263. private _colorTableTexture;
  59264. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59265. }
  59266. }
  59267. declare module "babylonjs/Shaders/convolution.fragment" {
  59268. /** @hidden */
  59269. export var convolutionPixelShader: {
  59270. name: string;
  59271. shader: string;
  59272. };
  59273. }
  59274. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59275. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59276. import { Nullable } from "babylonjs/types";
  59277. import { Camera } from "babylonjs/Cameras/camera";
  59278. import { Engine } from "babylonjs/Engines/engine";
  59279. import "babylonjs/Shaders/convolution.fragment";
  59280. /**
  59281. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59282. * input texture to perform effects such as edge detection or sharpening
  59283. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59284. */
  59285. export class ConvolutionPostProcess extends PostProcess {
  59286. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59287. kernel: number[];
  59288. /**
  59289. * Creates a new instance ConvolutionPostProcess
  59290. * @param name The name of the effect.
  59291. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59292. * @param options The required width/height ratio to downsize to before computing the render pass.
  59293. * @param camera The camera to apply the render pass to.
  59294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59295. * @param engine The engine which the post process will be applied. (default: current engine)
  59296. * @param reusable If the post process can be reused on the same frame. (default: false)
  59297. * @param textureType Type of textures used when performing the post process. (default: 0)
  59298. */
  59299. constructor(name: string,
  59300. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59301. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59302. /**
  59303. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59304. */
  59305. static EdgeDetect0Kernel: number[];
  59306. /**
  59307. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59308. */
  59309. static EdgeDetect1Kernel: number[];
  59310. /**
  59311. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59312. */
  59313. static EdgeDetect2Kernel: number[];
  59314. /**
  59315. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59316. */
  59317. static SharpenKernel: number[];
  59318. /**
  59319. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59320. */
  59321. static EmbossKernel: number[];
  59322. /**
  59323. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59324. */
  59325. static GaussianKernel: number[];
  59326. }
  59327. }
  59328. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59329. import { Nullable } from "babylonjs/types";
  59330. import { Vector2 } from "babylonjs/Maths/math.vector";
  59331. import { Camera } from "babylonjs/Cameras/camera";
  59332. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59333. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59334. import { Engine } from "babylonjs/Engines/engine";
  59335. import { Scene } from "babylonjs/scene";
  59336. /**
  59337. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59338. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59339. * based on samples that have a large difference in distance than the center pixel.
  59340. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59341. */
  59342. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59343. direction: Vector2;
  59344. /**
  59345. * Creates a new instance CircleOfConfusionPostProcess
  59346. * @param name The name of the effect.
  59347. * @param scene The scene the effect belongs to.
  59348. * @param direction The direction the blur should be applied.
  59349. * @param kernel The size of the kernel used to blur.
  59350. * @param options The required width/height ratio to downsize to before computing the render pass.
  59351. * @param camera The camera to apply the render pass to.
  59352. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59353. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59355. * @param engine The engine which the post process will be applied. (default: current engine)
  59356. * @param reusable If the post process can be reused on the same frame. (default: false)
  59357. * @param textureType Type of textures used when performing the post process. (default: 0)
  59358. * @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)
  59359. */
  59360. 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);
  59361. }
  59362. }
  59363. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59364. /** @hidden */
  59365. export var depthOfFieldMergePixelShader: {
  59366. name: string;
  59367. shader: string;
  59368. };
  59369. }
  59370. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59371. import { Nullable } from "babylonjs/types";
  59372. import { Camera } from "babylonjs/Cameras/camera";
  59373. import { Effect } from "babylonjs/Materials/effect";
  59374. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59375. import { Engine } from "babylonjs/Engines/engine";
  59376. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59377. /**
  59378. * Options to be set when merging outputs from the default pipeline.
  59379. */
  59380. export class DepthOfFieldMergePostProcessOptions {
  59381. /**
  59382. * The original image to merge on top of
  59383. */
  59384. originalFromInput: PostProcess;
  59385. /**
  59386. * Parameters to perform the merge of the depth of field effect
  59387. */
  59388. depthOfField?: {
  59389. circleOfConfusion: PostProcess;
  59390. blurSteps: Array<PostProcess>;
  59391. };
  59392. /**
  59393. * Parameters to perform the merge of bloom effect
  59394. */
  59395. bloom?: {
  59396. blurred: PostProcess;
  59397. weight: number;
  59398. };
  59399. }
  59400. /**
  59401. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59402. */
  59403. export class DepthOfFieldMergePostProcess extends PostProcess {
  59404. private blurSteps;
  59405. /**
  59406. * Creates a new instance of DepthOfFieldMergePostProcess
  59407. * @param name The name of the effect.
  59408. * @param originalFromInput Post process which's input will be used for the merge.
  59409. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59410. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59411. * @param options The required width/height ratio to downsize to before computing the render pass.
  59412. * @param camera The camera to apply the render pass to.
  59413. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59414. * @param engine The engine which the post process will be applied. (default: current engine)
  59415. * @param reusable If the post process can be reused on the same frame. (default: false)
  59416. * @param textureType Type of textures used when performing the post process. (default: 0)
  59417. * @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)
  59418. */
  59419. 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);
  59420. /**
  59421. * Updates the effect with the current post process compile time values and recompiles the shader.
  59422. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59423. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59424. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59425. * @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
  59426. * @param onCompiled Called when the shader has been compiled.
  59427. * @param onError Called if there is an error when compiling a shader.
  59428. */
  59429. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59430. }
  59431. }
  59432. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59433. import { Nullable } from "babylonjs/types";
  59434. import { Camera } from "babylonjs/Cameras/camera";
  59435. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59437. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59438. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59439. import { Scene } from "babylonjs/scene";
  59440. /**
  59441. * Specifies the level of max blur that should be applied when using the depth of field effect
  59442. */
  59443. export enum DepthOfFieldEffectBlurLevel {
  59444. /**
  59445. * Subtle blur
  59446. */
  59447. Low = 0,
  59448. /**
  59449. * Medium blur
  59450. */
  59451. Medium = 1,
  59452. /**
  59453. * Large blur
  59454. */
  59455. High = 2
  59456. }
  59457. /**
  59458. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59459. */
  59460. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59461. private _circleOfConfusion;
  59462. /**
  59463. * @hidden Internal, blurs from high to low
  59464. */
  59465. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59466. private _depthOfFieldBlurY;
  59467. private _dofMerge;
  59468. /**
  59469. * @hidden Internal post processes in depth of field effect
  59470. */
  59471. _effects: Array<PostProcess>;
  59472. /**
  59473. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59474. */
  59475. focalLength: number;
  59476. /**
  59477. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59478. */
  59479. fStop: number;
  59480. /**
  59481. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59482. */
  59483. focusDistance: number;
  59484. /**
  59485. * 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.
  59486. */
  59487. lensSize: number;
  59488. /**
  59489. * Creates a new instance DepthOfFieldEffect
  59490. * @param scene The scene the effect belongs to.
  59491. * @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.
  59492. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59493. * @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)
  59494. */
  59495. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59496. /**
  59497. * Get the current class name of the current effet
  59498. * @returns "DepthOfFieldEffect"
  59499. */
  59500. getClassName(): string;
  59501. /**
  59502. * 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.
  59503. */
  59504. depthTexture: RenderTargetTexture;
  59505. /**
  59506. * Disposes each of the internal effects for a given camera.
  59507. * @param camera The camera to dispose the effect on.
  59508. */
  59509. disposeEffects(camera: Camera): void;
  59510. /**
  59511. * @hidden Internal
  59512. */
  59513. _updateEffects(): void;
  59514. /**
  59515. * Internal
  59516. * @returns if all the contained post processes are ready.
  59517. * @hidden
  59518. */
  59519. _isReady(): boolean;
  59520. }
  59521. }
  59522. declare module "babylonjs/Shaders/displayPass.fragment" {
  59523. /** @hidden */
  59524. export var displayPassPixelShader: {
  59525. name: string;
  59526. shader: string;
  59527. };
  59528. }
  59529. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59530. import { Nullable } from "babylonjs/types";
  59531. import { Camera } from "babylonjs/Cameras/camera";
  59532. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59533. import { Engine } from "babylonjs/Engines/engine";
  59534. import "babylonjs/Shaders/displayPass.fragment";
  59535. /**
  59536. * DisplayPassPostProcess which produces an output the same as it's input
  59537. */
  59538. export class DisplayPassPostProcess extends PostProcess {
  59539. /**
  59540. * Creates the DisplayPassPostProcess
  59541. * @param name The name of the effect.
  59542. * @param options The required width/height ratio to downsize to before computing the render pass.
  59543. * @param camera The camera to apply the render pass to.
  59544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59545. * @param engine The engine which the post process will be applied. (default: current engine)
  59546. * @param reusable If the post process can be reused on the same frame. (default: false)
  59547. */
  59548. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59549. }
  59550. }
  59551. declare module "babylonjs/Shaders/filter.fragment" {
  59552. /** @hidden */
  59553. export var filterPixelShader: {
  59554. name: string;
  59555. shader: string;
  59556. };
  59557. }
  59558. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59559. import { Nullable } from "babylonjs/types";
  59560. import { Matrix } from "babylonjs/Maths/math.vector";
  59561. import { Camera } from "babylonjs/Cameras/camera";
  59562. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59563. import { Engine } from "babylonjs/Engines/engine";
  59564. import "babylonjs/Shaders/filter.fragment";
  59565. /**
  59566. * Applies a kernel filter to the image
  59567. */
  59568. export class FilterPostProcess extends PostProcess {
  59569. /** The matrix to be applied to the image */
  59570. kernelMatrix: Matrix;
  59571. /**
  59572. *
  59573. * @param name The name of the effect.
  59574. * @param kernelMatrix The matrix to be applied to the image
  59575. * @param options The required width/height ratio to downsize to before computing the render pass.
  59576. * @param camera The camera to apply the render pass to.
  59577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59578. * @param engine The engine which the post process will be applied. (default: current engine)
  59579. * @param reusable If the post process can be reused on the same frame. (default: false)
  59580. */
  59581. constructor(name: string,
  59582. /** The matrix to be applied to the image */
  59583. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59584. }
  59585. }
  59586. declare module "babylonjs/Shaders/fxaa.fragment" {
  59587. /** @hidden */
  59588. export var fxaaPixelShader: {
  59589. name: string;
  59590. shader: string;
  59591. };
  59592. }
  59593. declare module "babylonjs/Shaders/fxaa.vertex" {
  59594. /** @hidden */
  59595. export var fxaaVertexShader: {
  59596. name: string;
  59597. shader: string;
  59598. };
  59599. }
  59600. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59601. import { Nullable } from "babylonjs/types";
  59602. import { Camera } from "babylonjs/Cameras/camera";
  59603. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59604. import { Engine } from "babylonjs/Engines/engine";
  59605. import "babylonjs/Shaders/fxaa.fragment";
  59606. import "babylonjs/Shaders/fxaa.vertex";
  59607. /**
  59608. * Fxaa post process
  59609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59610. */
  59611. export class FxaaPostProcess extends PostProcess {
  59612. /** @hidden */
  59613. texelWidth: number;
  59614. /** @hidden */
  59615. texelHeight: number;
  59616. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59617. private _getDefines;
  59618. }
  59619. }
  59620. declare module "babylonjs/Shaders/grain.fragment" {
  59621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59622. /** @hidden */
  59623. export var grainPixelShader: {
  59624. name: string;
  59625. shader: string;
  59626. };
  59627. }
  59628. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59629. import { Nullable } from "babylonjs/types";
  59630. import { Camera } from "babylonjs/Cameras/camera";
  59631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59632. import { Engine } from "babylonjs/Engines/engine";
  59633. import "babylonjs/Shaders/grain.fragment";
  59634. /**
  59635. * The GrainPostProcess adds noise to the image at mid luminance levels
  59636. */
  59637. export class GrainPostProcess extends PostProcess {
  59638. /**
  59639. * The intensity of the grain added (default: 30)
  59640. */
  59641. intensity: number;
  59642. /**
  59643. * If the grain should be randomized on every frame
  59644. */
  59645. animated: boolean;
  59646. /**
  59647. * Creates a new instance of @see GrainPostProcess
  59648. * @param name The name of the effect.
  59649. * @param options The required width/height ratio to downsize to before computing the render pass.
  59650. * @param camera The camera to apply the render pass to.
  59651. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59652. * @param engine The engine which the post process will be applied. (default: current engine)
  59653. * @param reusable If the post process can be reused on the same frame. (default: false)
  59654. * @param textureType Type of textures used when performing the post process. (default: 0)
  59655. * @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)
  59656. */
  59657. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59658. }
  59659. }
  59660. declare module "babylonjs/Shaders/highlights.fragment" {
  59661. /** @hidden */
  59662. export var highlightsPixelShader: {
  59663. name: string;
  59664. shader: string;
  59665. };
  59666. }
  59667. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59668. import { Nullable } from "babylonjs/types";
  59669. import { Camera } from "babylonjs/Cameras/camera";
  59670. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59671. import { Engine } from "babylonjs/Engines/engine";
  59672. import "babylonjs/Shaders/highlights.fragment";
  59673. /**
  59674. * Extracts highlights from the image
  59675. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59676. */
  59677. export class HighlightsPostProcess extends PostProcess {
  59678. /**
  59679. * Extracts highlights from the image
  59680. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59681. * @param name The name of the effect.
  59682. * @param options The required width/height ratio to downsize to before computing the render pass.
  59683. * @param camera The camera to apply the render pass to.
  59684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59685. * @param engine The engine which the post process will be applied. (default: current engine)
  59686. * @param reusable If the post process can be reused on the same frame. (default: false)
  59687. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59688. */
  59689. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59690. }
  59691. }
  59692. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59693. /** @hidden */
  59694. export var mrtFragmentDeclaration: {
  59695. name: string;
  59696. shader: string;
  59697. };
  59698. }
  59699. declare module "babylonjs/Shaders/geometry.fragment" {
  59700. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59701. /** @hidden */
  59702. export var geometryPixelShader: {
  59703. name: string;
  59704. shader: string;
  59705. };
  59706. }
  59707. declare module "babylonjs/Shaders/geometry.vertex" {
  59708. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59709. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59710. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59711. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59712. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59713. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59714. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59715. /** @hidden */
  59716. export var geometryVertexShader: {
  59717. name: string;
  59718. shader: string;
  59719. };
  59720. }
  59721. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59722. import { Matrix } from "babylonjs/Maths/math.vector";
  59723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59724. import { Mesh } from "babylonjs/Meshes/mesh";
  59725. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59726. import { Effect } from "babylonjs/Materials/effect";
  59727. import { Scene } from "babylonjs/scene";
  59728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59729. import "babylonjs/Shaders/geometry.fragment";
  59730. import "babylonjs/Shaders/geometry.vertex";
  59731. /** @hidden */
  59732. interface ISavedTransformationMatrix {
  59733. world: Matrix;
  59734. viewProjection: Matrix;
  59735. }
  59736. /**
  59737. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59738. */
  59739. export class GeometryBufferRenderer {
  59740. /**
  59741. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59742. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59743. */
  59744. static readonly POSITION_TEXTURE_TYPE: number;
  59745. /**
  59746. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59747. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59748. */
  59749. static readonly VELOCITY_TEXTURE_TYPE: number;
  59750. /**
  59751. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59752. * in order to compute objects velocities when enableVelocity is set to "true"
  59753. * @hidden
  59754. */
  59755. _previousTransformationMatrices: {
  59756. [index: number]: ISavedTransformationMatrix;
  59757. };
  59758. /**
  59759. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59760. * in order to compute objects velocities when enableVelocity is set to "true"
  59761. * @hidden
  59762. */
  59763. _previousBonesTransformationMatrices: {
  59764. [index: number]: Float32Array;
  59765. };
  59766. /**
  59767. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59768. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59769. */
  59770. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59771. private _scene;
  59772. private _multiRenderTarget;
  59773. private _ratio;
  59774. private _enablePosition;
  59775. private _enableVelocity;
  59776. private _positionIndex;
  59777. private _velocityIndex;
  59778. protected _effect: Effect;
  59779. protected _cachedDefines: string;
  59780. /**
  59781. * Set the render list (meshes to be rendered) used in the G buffer.
  59782. */
  59783. renderList: Mesh[];
  59784. /**
  59785. * Gets wether or not G buffer are supported by the running hardware.
  59786. * This requires draw buffer supports
  59787. */
  59788. readonly isSupported: boolean;
  59789. /**
  59790. * Returns the index of the given texture type in the G-Buffer textures array
  59791. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59792. * @returns the index of the given texture type in the G-Buffer textures array
  59793. */
  59794. getTextureIndex(textureType: number): number;
  59795. /**
  59796. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59797. */
  59798. /**
  59799. * Sets whether or not objects positions are enabled for the G buffer.
  59800. */
  59801. enablePosition: boolean;
  59802. /**
  59803. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59804. */
  59805. /**
  59806. * Sets wether or not objects velocities are enabled for the G buffer.
  59807. */
  59808. enableVelocity: boolean;
  59809. /**
  59810. * Gets the scene associated with the buffer.
  59811. */
  59812. readonly scene: Scene;
  59813. /**
  59814. * Gets the ratio used by the buffer during its creation.
  59815. * How big is the buffer related to the main canvas.
  59816. */
  59817. readonly ratio: number;
  59818. /** @hidden */
  59819. static _SceneComponentInitialization: (scene: Scene) => void;
  59820. /**
  59821. * Creates a new G Buffer for the scene
  59822. * @param scene The scene the buffer belongs to
  59823. * @param ratio How big is the buffer related to the main canvas.
  59824. */
  59825. constructor(scene: Scene, ratio?: number);
  59826. /**
  59827. * Checks wether everything is ready to render a submesh to the G buffer.
  59828. * @param subMesh the submesh to check readiness for
  59829. * @param useInstances is the mesh drawn using instance or not
  59830. * @returns true if ready otherwise false
  59831. */
  59832. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59833. /**
  59834. * Gets the current underlying G Buffer.
  59835. * @returns the buffer
  59836. */
  59837. getGBuffer(): MultiRenderTarget;
  59838. /**
  59839. * Gets the number of samples used to render the buffer (anti aliasing).
  59840. */
  59841. /**
  59842. * Sets the number of samples used to render the buffer (anti aliasing).
  59843. */
  59844. samples: number;
  59845. /**
  59846. * Disposes the renderer and frees up associated resources.
  59847. */
  59848. dispose(): void;
  59849. protected _createRenderTargets(): void;
  59850. private _copyBonesTransformationMatrices;
  59851. }
  59852. }
  59853. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  59854. import { Nullable } from "babylonjs/types";
  59855. import { Scene } from "babylonjs/scene";
  59856. import { ISceneComponent } from "babylonjs/sceneComponent";
  59857. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  59858. module "babylonjs/scene" {
  59859. interface Scene {
  59860. /** @hidden (Backing field) */
  59861. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59862. /**
  59863. * Gets or Sets the current geometry buffer associated to the scene.
  59864. */
  59865. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59866. /**
  59867. * Enables a GeometryBufferRender and associates it with the scene
  59868. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59869. * @returns the GeometryBufferRenderer
  59870. */
  59871. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59872. /**
  59873. * Disables the GeometryBufferRender associated with the scene
  59874. */
  59875. disableGeometryBufferRenderer(): void;
  59876. }
  59877. }
  59878. /**
  59879. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59880. * in several rendering techniques.
  59881. */
  59882. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59883. /**
  59884. * The component name helpful to identify the component in the list of scene components.
  59885. */
  59886. readonly name: string;
  59887. /**
  59888. * The scene the component belongs to.
  59889. */
  59890. scene: Scene;
  59891. /**
  59892. * Creates a new instance of the component for the given scene
  59893. * @param scene Defines the scene to register the component in
  59894. */
  59895. constructor(scene: Scene);
  59896. /**
  59897. * Registers the component in a given scene
  59898. */
  59899. register(): void;
  59900. /**
  59901. * Rebuilds the elements related to this component in case of
  59902. * context lost for instance.
  59903. */
  59904. rebuild(): void;
  59905. /**
  59906. * Disposes the component and the associated ressources
  59907. */
  59908. dispose(): void;
  59909. private _gatherRenderTargets;
  59910. }
  59911. }
  59912. declare module "babylonjs/Shaders/motionBlur.fragment" {
  59913. /** @hidden */
  59914. export var motionBlurPixelShader: {
  59915. name: string;
  59916. shader: string;
  59917. };
  59918. }
  59919. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  59920. import { Nullable } from "babylonjs/types";
  59921. import { Camera } from "babylonjs/Cameras/camera";
  59922. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59923. import { Scene } from "babylonjs/scene";
  59924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59925. import "babylonjs/Animations/animatable";
  59926. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59927. import "babylonjs/Shaders/motionBlur.fragment";
  59928. import { Engine } from "babylonjs/Engines/engine";
  59929. /**
  59930. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59931. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59932. * As an example, all you have to do is to create the post-process:
  59933. * var mb = new BABYLON.MotionBlurPostProcess(
  59934. * 'mb', // The name of the effect.
  59935. * scene, // The scene containing the objects to blur according to their velocity.
  59936. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59937. * camera // The camera to apply the render pass to.
  59938. * );
  59939. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59940. */
  59941. export class MotionBlurPostProcess extends PostProcess {
  59942. /**
  59943. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59944. */
  59945. motionStrength: number;
  59946. /**
  59947. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59948. */
  59949. /**
  59950. * Sets the number of iterations to be used for motion blur quality
  59951. */
  59952. motionBlurSamples: number;
  59953. private _motionBlurSamples;
  59954. private _geometryBufferRenderer;
  59955. /**
  59956. * Creates a new instance MotionBlurPostProcess
  59957. * @param name The name of the effect.
  59958. * @param scene The scene containing the objects to blur according to their velocity.
  59959. * @param options The required width/height ratio to downsize to before computing the render pass.
  59960. * @param camera The camera to apply the render pass to.
  59961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59962. * @param engine The engine which the post process will be applied. (default: current engine)
  59963. * @param reusable If the post process can be reused on the same frame. (default: false)
  59964. * @param textureType Type of textures used when performing the post process. (default: 0)
  59965. * @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)
  59966. */
  59967. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59968. /**
  59969. * Excludes the given skinned mesh from computing bones velocities.
  59970. * 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.
  59971. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59972. */
  59973. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59974. /**
  59975. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59976. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59977. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59978. */
  59979. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59980. /**
  59981. * Disposes the post process.
  59982. * @param camera The camera to dispose the post process on.
  59983. */
  59984. dispose(camera?: Camera): void;
  59985. }
  59986. }
  59987. declare module "babylonjs/Shaders/refraction.fragment" {
  59988. /** @hidden */
  59989. export var refractionPixelShader: {
  59990. name: string;
  59991. shader: string;
  59992. };
  59993. }
  59994. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  59995. import { Color3 } from "babylonjs/Maths/math.color";
  59996. import { Camera } from "babylonjs/Cameras/camera";
  59997. import { Texture } from "babylonjs/Materials/Textures/texture";
  59998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59999. import { Engine } from "babylonjs/Engines/engine";
  60000. import "babylonjs/Shaders/refraction.fragment";
  60001. /**
  60002. * Post process which applies a refractin texture
  60003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60004. */
  60005. export class RefractionPostProcess extends PostProcess {
  60006. /** the base color of the refraction (used to taint the rendering) */
  60007. color: Color3;
  60008. /** simulated refraction depth */
  60009. depth: number;
  60010. /** the coefficient of the base color (0 to remove base color tainting) */
  60011. colorLevel: number;
  60012. private _refTexture;
  60013. private _ownRefractionTexture;
  60014. /**
  60015. * Gets or sets the refraction texture
  60016. * Please note that you are responsible for disposing the texture if you set it manually
  60017. */
  60018. refractionTexture: Texture;
  60019. /**
  60020. * Initializes the RefractionPostProcess
  60021. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60022. * @param name The name of the effect.
  60023. * @param refractionTextureUrl Url of the refraction texture to use
  60024. * @param color the base color of the refraction (used to taint the rendering)
  60025. * @param depth simulated refraction depth
  60026. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60027. * @param camera The camera to apply the render pass to.
  60028. * @param options The required width/height ratio to downsize to before computing the render pass.
  60029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60030. * @param engine The engine which the post process will be applied. (default: current engine)
  60031. * @param reusable If the post process can be reused on the same frame. (default: false)
  60032. */
  60033. constructor(name: string, refractionTextureUrl: string,
  60034. /** the base color of the refraction (used to taint the rendering) */
  60035. color: Color3,
  60036. /** simulated refraction depth */
  60037. depth: number,
  60038. /** the coefficient of the base color (0 to remove base color tainting) */
  60039. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60040. /**
  60041. * Disposes of the post process
  60042. * @param camera Camera to dispose post process on
  60043. */
  60044. dispose(camera: Camera): void;
  60045. }
  60046. }
  60047. declare module "babylonjs/Shaders/sharpen.fragment" {
  60048. /** @hidden */
  60049. export var sharpenPixelShader: {
  60050. name: string;
  60051. shader: string;
  60052. };
  60053. }
  60054. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60055. import { Nullable } from "babylonjs/types";
  60056. import { Camera } from "babylonjs/Cameras/camera";
  60057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60058. import "babylonjs/Shaders/sharpen.fragment";
  60059. import { Engine } from "babylonjs/Engines/engine";
  60060. /**
  60061. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60062. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60063. */
  60064. export class SharpenPostProcess extends PostProcess {
  60065. /**
  60066. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60067. */
  60068. colorAmount: number;
  60069. /**
  60070. * How much sharpness should be applied (default: 0.3)
  60071. */
  60072. edgeAmount: number;
  60073. /**
  60074. * Creates a new instance ConvolutionPostProcess
  60075. * @param name The name of the effect.
  60076. * @param options The required width/height ratio to downsize to before computing the render pass.
  60077. * @param camera The camera to apply the render pass to.
  60078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60079. * @param engine The engine which the post process will be applied. (default: current engine)
  60080. * @param reusable If the post process can be reused on the same frame. (default: false)
  60081. * @param textureType Type of textures used when performing the post process. (default: 0)
  60082. * @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)
  60083. */
  60084. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60085. }
  60086. }
  60087. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60088. import { Nullable } from "babylonjs/types";
  60089. import { Camera } from "babylonjs/Cameras/camera";
  60090. import { Engine } from "babylonjs/Engines/engine";
  60091. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60092. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60093. /**
  60094. * PostProcessRenderPipeline
  60095. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60096. */
  60097. export class PostProcessRenderPipeline {
  60098. private engine;
  60099. private _renderEffects;
  60100. private _renderEffectsForIsolatedPass;
  60101. /**
  60102. * List of inspectable custom properties (used by the Inspector)
  60103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60104. */
  60105. inspectableCustomProperties: IInspectable[];
  60106. /**
  60107. * @hidden
  60108. */
  60109. protected _cameras: Camera[];
  60110. /** @hidden */
  60111. _name: string;
  60112. /**
  60113. * Gets pipeline name
  60114. */
  60115. readonly name: string;
  60116. /**
  60117. * Initializes a PostProcessRenderPipeline
  60118. * @param engine engine to add the pipeline to
  60119. * @param name name of the pipeline
  60120. */
  60121. constructor(engine: Engine, name: string);
  60122. /**
  60123. * Gets the class name
  60124. * @returns "PostProcessRenderPipeline"
  60125. */
  60126. getClassName(): string;
  60127. /**
  60128. * If all the render effects in the pipeline are supported
  60129. */
  60130. readonly isSupported: boolean;
  60131. /**
  60132. * Adds an effect to the pipeline
  60133. * @param renderEffect the effect to add
  60134. */
  60135. addEffect(renderEffect: PostProcessRenderEffect): void;
  60136. /** @hidden */
  60137. _rebuild(): void;
  60138. /** @hidden */
  60139. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60140. /** @hidden */
  60141. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60142. /** @hidden */
  60143. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60144. /** @hidden */
  60145. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60146. /** @hidden */
  60147. _attachCameras(cameras: Camera, unique: boolean): void;
  60148. /** @hidden */
  60149. _attachCameras(cameras: Camera[], unique: boolean): void;
  60150. /** @hidden */
  60151. _detachCameras(cameras: Camera): void;
  60152. /** @hidden */
  60153. _detachCameras(cameras: Nullable<Camera[]>): void;
  60154. /** @hidden */
  60155. _update(): void;
  60156. /** @hidden */
  60157. _reset(): void;
  60158. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60159. /**
  60160. * Disposes of the pipeline
  60161. */
  60162. dispose(): void;
  60163. }
  60164. }
  60165. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60166. import { Camera } from "babylonjs/Cameras/camera";
  60167. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60168. /**
  60169. * PostProcessRenderPipelineManager class
  60170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60171. */
  60172. export class PostProcessRenderPipelineManager {
  60173. private _renderPipelines;
  60174. /**
  60175. * Initializes a PostProcessRenderPipelineManager
  60176. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60177. */
  60178. constructor();
  60179. /**
  60180. * Gets the list of supported render pipelines
  60181. */
  60182. readonly supportedPipelines: PostProcessRenderPipeline[];
  60183. /**
  60184. * Adds a pipeline to the manager
  60185. * @param renderPipeline The pipeline to add
  60186. */
  60187. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60188. /**
  60189. * Attaches a camera to the pipeline
  60190. * @param renderPipelineName The name of the pipeline to attach to
  60191. * @param cameras the camera to attach
  60192. * @param unique if the camera can be attached multiple times to the pipeline
  60193. */
  60194. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60195. /**
  60196. * Detaches a camera from the pipeline
  60197. * @param renderPipelineName The name of the pipeline to detach from
  60198. * @param cameras the camera to detach
  60199. */
  60200. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60201. /**
  60202. * Enables an effect by name on a pipeline
  60203. * @param renderPipelineName the name of the pipeline to enable the effect in
  60204. * @param renderEffectName the name of the effect to enable
  60205. * @param cameras the cameras that the effect should be enabled on
  60206. */
  60207. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60208. /**
  60209. * Disables an effect by name on a pipeline
  60210. * @param renderPipelineName the name of the pipeline to disable the effect in
  60211. * @param renderEffectName the name of the effect to disable
  60212. * @param cameras the cameras that the effect should be disabled on
  60213. */
  60214. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60215. /**
  60216. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60217. */
  60218. update(): void;
  60219. /** @hidden */
  60220. _rebuild(): void;
  60221. /**
  60222. * Disposes of the manager and pipelines
  60223. */
  60224. dispose(): void;
  60225. }
  60226. }
  60227. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60228. import { ISceneComponent } from "babylonjs/sceneComponent";
  60229. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60230. import { Scene } from "babylonjs/scene";
  60231. module "babylonjs/scene" {
  60232. interface Scene {
  60233. /** @hidden (Backing field) */
  60234. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60235. /**
  60236. * Gets the postprocess render pipeline manager
  60237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60238. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60239. */
  60240. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60241. }
  60242. }
  60243. /**
  60244. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60245. */
  60246. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60247. /**
  60248. * The component name helpfull to identify the component in the list of scene components.
  60249. */
  60250. readonly name: string;
  60251. /**
  60252. * The scene the component belongs to.
  60253. */
  60254. scene: Scene;
  60255. /**
  60256. * Creates a new instance of the component for the given scene
  60257. * @param scene Defines the scene to register the component in
  60258. */
  60259. constructor(scene: Scene);
  60260. /**
  60261. * Registers the component in a given scene
  60262. */
  60263. register(): void;
  60264. /**
  60265. * Rebuilds the elements related to this component in case of
  60266. * context lost for instance.
  60267. */
  60268. rebuild(): void;
  60269. /**
  60270. * Disposes the component and the associated ressources
  60271. */
  60272. dispose(): void;
  60273. private _gatherRenderTargets;
  60274. }
  60275. }
  60276. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60277. import { Nullable } from "babylonjs/types";
  60278. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60279. import { Camera } from "babylonjs/Cameras/camera";
  60280. import { IDisposable } from "babylonjs/scene";
  60281. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60282. import { Scene } from "babylonjs/scene";
  60283. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60284. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60285. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60286. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60287. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60288. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60289. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60290. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60291. import { Animation } from "babylonjs/Animations/animation";
  60292. /**
  60293. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60294. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60295. */
  60296. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60297. private _scene;
  60298. private _camerasToBeAttached;
  60299. /**
  60300. * ID of the sharpen post process,
  60301. */
  60302. private readonly SharpenPostProcessId;
  60303. /**
  60304. * @ignore
  60305. * ID of the image processing post process;
  60306. */
  60307. readonly ImageProcessingPostProcessId: string;
  60308. /**
  60309. * @ignore
  60310. * ID of the Fast Approximate Anti-Aliasing post process;
  60311. */
  60312. readonly FxaaPostProcessId: string;
  60313. /**
  60314. * ID of the chromatic aberration post process,
  60315. */
  60316. private readonly ChromaticAberrationPostProcessId;
  60317. /**
  60318. * ID of the grain post process
  60319. */
  60320. private readonly GrainPostProcessId;
  60321. /**
  60322. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60323. */
  60324. sharpen: SharpenPostProcess;
  60325. private _sharpenEffect;
  60326. private bloom;
  60327. /**
  60328. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60329. */
  60330. depthOfField: DepthOfFieldEffect;
  60331. /**
  60332. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60333. */
  60334. fxaa: FxaaPostProcess;
  60335. /**
  60336. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60337. */
  60338. imageProcessing: ImageProcessingPostProcess;
  60339. /**
  60340. * Chromatic aberration post process which will shift rgb colors in the image
  60341. */
  60342. chromaticAberration: ChromaticAberrationPostProcess;
  60343. private _chromaticAberrationEffect;
  60344. /**
  60345. * Grain post process which add noise to the image
  60346. */
  60347. grain: GrainPostProcess;
  60348. private _grainEffect;
  60349. /**
  60350. * Glow post process which adds a glow to emissive areas of the image
  60351. */
  60352. private _glowLayer;
  60353. /**
  60354. * Animations which can be used to tweak settings over a period of time
  60355. */
  60356. animations: Animation[];
  60357. private _imageProcessingConfigurationObserver;
  60358. private _sharpenEnabled;
  60359. private _bloomEnabled;
  60360. private _depthOfFieldEnabled;
  60361. private _depthOfFieldBlurLevel;
  60362. private _fxaaEnabled;
  60363. private _imageProcessingEnabled;
  60364. private _defaultPipelineTextureType;
  60365. private _bloomScale;
  60366. private _chromaticAberrationEnabled;
  60367. private _grainEnabled;
  60368. private _buildAllowed;
  60369. /**
  60370. * Gets active scene
  60371. */
  60372. readonly scene: Scene;
  60373. /**
  60374. * Enable or disable the sharpen process from the pipeline
  60375. */
  60376. sharpenEnabled: boolean;
  60377. private _resizeObserver;
  60378. private _hardwareScaleLevel;
  60379. private _bloomKernel;
  60380. /**
  60381. * Specifies the size of the bloom blur kernel, relative to the final output size
  60382. */
  60383. bloomKernel: number;
  60384. /**
  60385. * Specifies the weight of the bloom in the final rendering
  60386. */
  60387. private _bloomWeight;
  60388. /**
  60389. * Specifies the luma threshold for the area that will be blurred by the bloom
  60390. */
  60391. private _bloomThreshold;
  60392. private _hdr;
  60393. /**
  60394. * The strength of the bloom.
  60395. */
  60396. bloomWeight: number;
  60397. /**
  60398. * The strength of the bloom.
  60399. */
  60400. bloomThreshold: number;
  60401. /**
  60402. * The scale of the bloom, lower value will provide better performance.
  60403. */
  60404. bloomScale: number;
  60405. /**
  60406. * Enable or disable the bloom from the pipeline
  60407. */
  60408. bloomEnabled: boolean;
  60409. private _rebuildBloom;
  60410. /**
  60411. * If the depth of field is enabled.
  60412. */
  60413. depthOfFieldEnabled: boolean;
  60414. /**
  60415. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60416. */
  60417. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60418. /**
  60419. * If the anti aliasing is enabled.
  60420. */
  60421. fxaaEnabled: boolean;
  60422. private _samples;
  60423. /**
  60424. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60425. */
  60426. samples: number;
  60427. /**
  60428. * If image processing is enabled.
  60429. */
  60430. imageProcessingEnabled: boolean;
  60431. /**
  60432. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60433. */
  60434. glowLayerEnabled: boolean;
  60435. /**
  60436. * Gets the glow layer (or null if not defined)
  60437. */
  60438. readonly glowLayer: Nullable<GlowLayer>;
  60439. /**
  60440. * Enable or disable the chromaticAberration process from the pipeline
  60441. */
  60442. chromaticAberrationEnabled: boolean;
  60443. /**
  60444. * Enable or disable the grain process from the pipeline
  60445. */
  60446. grainEnabled: boolean;
  60447. /**
  60448. * @constructor
  60449. * @param name - The rendering pipeline name (default: "")
  60450. * @param hdr - If high dynamic range textures should be used (default: true)
  60451. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60452. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60453. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60454. */
  60455. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60456. /**
  60457. * Get the class name
  60458. * @returns "DefaultRenderingPipeline"
  60459. */
  60460. getClassName(): string;
  60461. /**
  60462. * Force the compilation of the entire pipeline.
  60463. */
  60464. prepare(): void;
  60465. private _hasCleared;
  60466. private _prevPostProcess;
  60467. private _prevPrevPostProcess;
  60468. private _setAutoClearAndTextureSharing;
  60469. private _depthOfFieldSceneObserver;
  60470. private _buildPipeline;
  60471. private _disposePostProcesses;
  60472. /**
  60473. * Adds a camera to the pipeline
  60474. * @param camera the camera to be added
  60475. */
  60476. addCamera(camera: Camera): void;
  60477. /**
  60478. * Removes a camera from the pipeline
  60479. * @param camera the camera to remove
  60480. */
  60481. removeCamera(camera: Camera): void;
  60482. /**
  60483. * Dispose of the pipeline and stop all post processes
  60484. */
  60485. dispose(): void;
  60486. /**
  60487. * Serialize the rendering pipeline (Used when exporting)
  60488. * @returns the serialized object
  60489. */
  60490. serialize(): any;
  60491. /**
  60492. * Parse the serialized pipeline
  60493. * @param source Source pipeline.
  60494. * @param scene The scene to load the pipeline to.
  60495. * @param rootUrl The URL of the serialized pipeline.
  60496. * @returns An instantiated pipeline from the serialized object.
  60497. */
  60498. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60499. }
  60500. }
  60501. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60502. /** @hidden */
  60503. export var lensHighlightsPixelShader: {
  60504. name: string;
  60505. shader: string;
  60506. };
  60507. }
  60508. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60509. /** @hidden */
  60510. export var depthOfFieldPixelShader: {
  60511. name: string;
  60512. shader: string;
  60513. };
  60514. }
  60515. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60516. import { Camera } from "babylonjs/Cameras/camera";
  60517. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60518. import { Scene } from "babylonjs/scene";
  60519. import "babylonjs/Shaders/chromaticAberration.fragment";
  60520. import "babylonjs/Shaders/lensHighlights.fragment";
  60521. import "babylonjs/Shaders/depthOfField.fragment";
  60522. /**
  60523. * BABYLON.JS Chromatic Aberration GLSL Shader
  60524. * Author: Olivier Guyot
  60525. * Separates very slightly R, G and B colors on the edges of the screen
  60526. * Inspired by Francois Tarlier & Martins Upitis
  60527. */
  60528. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60529. /**
  60530. * @ignore
  60531. * The chromatic aberration PostProcess id in the pipeline
  60532. */
  60533. LensChromaticAberrationEffect: string;
  60534. /**
  60535. * @ignore
  60536. * The highlights enhancing PostProcess id in the pipeline
  60537. */
  60538. HighlightsEnhancingEffect: string;
  60539. /**
  60540. * @ignore
  60541. * The depth-of-field PostProcess id in the pipeline
  60542. */
  60543. LensDepthOfFieldEffect: string;
  60544. private _scene;
  60545. private _depthTexture;
  60546. private _grainTexture;
  60547. private _chromaticAberrationPostProcess;
  60548. private _highlightsPostProcess;
  60549. private _depthOfFieldPostProcess;
  60550. private _edgeBlur;
  60551. private _grainAmount;
  60552. private _chromaticAberration;
  60553. private _distortion;
  60554. private _highlightsGain;
  60555. private _highlightsThreshold;
  60556. private _dofDistance;
  60557. private _dofAperture;
  60558. private _dofDarken;
  60559. private _dofPentagon;
  60560. private _blurNoise;
  60561. /**
  60562. * @constructor
  60563. *
  60564. * Effect parameters are as follow:
  60565. * {
  60566. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60567. * edge_blur: number; // from 0 to x (1 for realism)
  60568. * distortion: number; // from 0 to x (1 for realism)
  60569. * grain_amount: number; // from 0 to 1
  60570. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60571. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60572. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60573. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60574. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60575. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60576. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60577. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60578. * }
  60579. * Note: if an effect parameter is unset, effect is disabled
  60580. *
  60581. * @param name The rendering pipeline name
  60582. * @param parameters - An object containing all parameters (see above)
  60583. * @param scene The scene linked to this pipeline
  60584. * @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)
  60585. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60586. */
  60587. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60588. /**
  60589. * Get the class name
  60590. * @returns "LensRenderingPipeline"
  60591. */
  60592. getClassName(): string;
  60593. /**
  60594. * Gets associated scene
  60595. */
  60596. readonly scene: Scene;
  60597. /**
  60598. * Gets or sets the edge blur
  60599. */
  60600. edgeBlur: number;
  60601. /**
  60602. * Gets or sets the grain amount
  60603. */
  60604. grainAmount: number;
  60605. /**
  60606. * Gets or sets the chromatic aberration amount
  60607. */
  60608. chromaticAberration: number;
  60609. /**
  60610. * Gets or sets the depth of field aperture
  60611. */
  60612. dofAperture: number;
  60613. /**
  60614. * Gets or sets the edge distortion
  60615. */
  60616. edgeDistortion: number;
  60617. /**
  60618. * Gets or sets the depth of field distortion
  60619. */
  60620. dofDistortion: number;
  60621. /**
  60622. * Gets or sets the darken out of focus amount
  60623. */
  60624. darkenOutOfFocus: number;
  60625. /**
  60626. * Gets or sets a boolean indicating if blur noise is enabled
  60627. */
  60628. blurNoise: boolean;
  60629. /**
  60630. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60631. */
  60632. pentagonBokeh: boolean;
  60633. /**
  60634. * Gets or sets the highlight grain amount
  60635. */
  60636. highlightsGain: number;
  60637. /**
  60638. * Gets or sets the highlight threshold
  60639. */
  60640. highlightsThreshold: number;
  60641. /**
  60642. * Sets the amount of blur at the edges
  60643. * @param amount blur amount
  60644. */
  60645. setEdgeBlur(amount: number): void;
  60646. /**
  60647. * Sets edge blur to 0
  60648. */
  60649. disableEdgeBlur(): void;
  60650. /**
  60651. * Sets the amout of grain
  60652. * @param amount Amount of grain
  60653. */
  60654. setGrainAmount(amount: number): void;
  60655. /**
  60656. * Set grain amount to 0
  60657. */
  60658. disableGrain(): void;
  60659. /**
  60660. * Sets the chromatic aberration amount
  60661. * @param amount amount of chromatic aberration
  60662. */
  60663. setChromaticAberration(amount: number): void;
  60664. /**
  60665. * Sets chromatic aberration amount to 0
  60666. */
  60667. disableChromaticAberration(): void;
  60668. /**
  60669. * Sets the EdgeDistortion amount
  60670. * @param amount amount of EdgeDistortion
  60671. */
  60672. setEdgeDistortion(amount: number): void;
  60673. /**
  60674. * Sets edge distortion to 0
  60675. */
  60676. disableEdgeDistortion(): void;
  60677. /**
  60678. * Sets the FocusDistance amount
  60679. * @param amount amount of FocusDistance
  60680. */
  60681. setFocusDistance(amount: number): void;
  60682. /**
  60683. * Disables depth of field
  60684. */
  60685. disableDepthOfField(): void;
  60686. /**
  60687. * Sets the Aperture amount
  60688. * @param amount amount of Aperture
  60689. */
  60690. setAperture(amount: number): void;
  60691. /**
  60692. * Sets the DarkenOutOfFocus amount
  60693. * @param amount amount of DarkenOutOfFocus
  60694. */
  60695. setDarkenOutOfFocus(amount: number): void;
  60696. private _pentagonBokehIsEnabled;
  60697. /**
  60698. * Creates a pentagon bokeh effect
  60699. */
  60700. enablePentagonBokeh(): void;
  60701. /**
  60702. * Disables the pentagon bokeh effect
  60703. */
  60704. disablePentagonBokeh(): void;
  60705. /**
  60706. * Enables noise blur
  60707. */
  60708. enableNoiseBlur(): void;
  60709. /**
  60710. * Disables noise blur
  60711. */
  60712. disableNoiseBlur(): void;
  60713. /**
  60714. * Sets the HighlightsGain amount
  60715. * @param amount amount of HighlightsGain
  60716. */
  60717. setHighlightsGain(amount: number): void;
  60718. /**
  60719. * Sets the HighlightsThreshold amount
  60720. * @param amount amount of HighlightsThreshold
  60721. */
  60722. setHighlightsThreshold(amount: number): void;
  60723. /**
  60724. * Disables highlights
  60725. */
  60726. disableHighlights(): void;
  60727. /**
  60728. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60729. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60730. */
  60731. dispose(disableDepthRender?: boolean): void;
  60732. private _createChromaticAberrationPostProcess;
  60733. private _createHighlightsPostProcess;
  60734. private _createDepthOfFieldPostProcess;
  60735. private _createGrainTexture;
  60736. }
  60737. }
  60738. declare module "babylonjs/Shaders/ssao2.fragment" {
  60739. /** @hidden */
  60740. export var ssao2PixelShader: {
  60741. name: string;
  60742. shader: string;
  60743. };
  60744. }
  60745. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60746. /** @hidden */
  60747. export var ssaoCombinePixelShader: {
  60748. name: string;
  60749. shader: string;
  60750. };
  60751. }
  60752. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60753. import { Camera } from "babylonjs/Cameras/camera";
  60754. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60755. import { Scene } from "babylonjs/scene";
  60756. import "babylonjs/Shaders/ssao2.fragment";
  60757. import "babylonjs/Shaders/ssaoCombine.fragment";
  60758. /**
  60759. * Render pipeline to produce ssao effect
  60760. */
  60761. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60762. /**
  60763. * @ignore
  60764. * The PassPostProcess id in the pipeline that contains the original scene color
  60765. */
  60766. SSAOOriginalSceneColorEffect: string;
  60767. /**
  60768. * @ignore
  60769. * The SSAO PostProcess id in the pipeline
  60770. */
  60771. SSAORenderEffect: string;
  60772. /**
  60773. * @ignore
  60774. * The horizontal blur PostProcess id in the pipeline
  60775. */
  60776. SSAOBlurHRenderEffect: string;
  60777. /**
  60778. * @ignore
  60779. * The vertical blur PostProcess id in the pipeline
  60780. */
  60781. SSAOBlurVRenderEffect: string;
  60782. /**
  60783. * @ignore
  60784. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60785. */
  60786. SSAOCombineRenderEffect: string;
  60787. /**
  60788. * The output strength of the SSAO post-process. Default value is 1.0.
  60789. */
  60790. totalStrength: number;
  60791. /**
  60792. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60793. */
  60794. maxZ: number;
  60795. /**
  60796. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60797. */
  60798. minZAspect: number;
  60799. private _samples;
  60800. /**
  60801. * Number of samples used for the SSAO calculations. Default value is 8
  60802. */
  60803. samples: number;
  60804. private _textureSamples;
  60805. /**
  60806. * Number of samples to use for antialiasing
  60807. */
  60808. textureSamples: number;
  60809. /**
  60810. * Ratio object used for SSAO ratio and blur ratio
  60811. */
  60812. private _ratio;
  60813. /**
  60814. * Dynamically generated sphere sampler.
  60815. */
  60816. private _sampleSphere;
  60817. /**
  60818. * Blur filter offsets
  60819. */
  60820. private _samplerOffsets;
  60821. private _expensiveBlur;
  60822. /**
  60823. * If bilateral blur should be used
  60824. */
  60825. expensiveBlur: boolean;
  60826. /**
  60827. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60828. */
  60829. radius: number;
  60830. /**
  60831. * The base color of the SSAO post-process
  60832. * The final result is "base + ssao" between [0, 1]
  60833. */
  60834. base: number;
  60835. /**
  60836. * Support test.
  60837. */
  60838. static readonly IsSupported: boolean;
  60839. private _scene;
  60840. private _depthTexture;
  60841. private _normalTexture;
  60842. private _randomTexture;
  60843. private _originalColorPostProcess;
  60844. private _ssaoPostProcess;
  60845. private _blurHPostProcess;
  60846. private _blurVPostProcess;
  60847. private _ssaoCombinePostProcess;
  60848. private _firstUpdate;
  60849. /**
  60850. * Gets active scene
  60851. */
  60852. readonly scene: Scene;
  60853. /**
  60854. * @constructor
  60855. * @param name The rendering pipeline name
  60856. * @param scene The scene linked to this pipeline
  60857. * @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 }
  60858. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60859. */
  60860. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60861. /**
  60862. * Get the class name
  60863. * @returns "SSAO2RenderingPipeline"
  60864. */
  60865. getClassName(): string;
  60866. /**
  60867. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60868. */
  60869. dispose(disableGeometryBufferRenderer?: boolean): void;
  60870. private _createBlurPostProcess;
  60871. /** @hidden */
  60872. _rebuild(): void;
  60873. private _bits;
  60874. private _radicalInverse_VdC;
  60875. private _hammersley;
  60876. private _hemisphereSample_uniform;
  60877. private _generateHemisphere;
  60878. private _createSSAOPostProcess;
  60879. private _createSSAOCombinePostProcess;
  60880. private _createRandomTexture;
  60881. /**
  60882. * Serialize the rendering pipeline (Used when exporting)
  60883. * @returns the serialized object
  60884. */
  60885. serialize(): any;
  60886. /**
  60887. * Parse the serialized pipeline
  60888. * @param source Source pipeline.
  60889. * @param scene The scene to load the pipeline to.
  60890. * @param rootUrl The URL of the serialized pipeline.
  60891. * @returns An instantiated pipeline from the serialized object.
  60892. */
  60893. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60894. }
  60895. }
  60896. declare module "babylonjs/Shaders/ssao.fragment" {
  60897. /** @hidden */
  60898. export var ssaoPixelShader: {
  60899. name: string;
  60900. shader: string;
  60901. };
  60902. }
  60903. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  60904. import { Camera } from "babylonjs/Cameras/camera";
  60905. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60906. import { Scene } from "babylonjs/scene";
  60907. import "babylonjs/Shaders/ssao.fragment";
  60908. import "babylonjs/Shaders/ssaoCombine.fragment";
  60909. /**
  60910. * Render pipeline to produce ssao effect
  60911. */
  60912. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60913. /**
  60914. * @ignore
  60915. * The PassPostProcess id in the pipeline that contains the original scene color
  60916. */
  60917. SSAOOriginalSceneColorEffect: string;
  60918. /**
  60919. * @ignore
  60920. * The SSAO PostProcess id in the pipeline
  60921. */
  60922. SSAORenderEffect: string;
  60923. /**
  60924. * @ignore
  60925. * The horizontal blur PostProcess id in the pipeline
  60926. */
  60927. SSAOBlurHRenderEffect: string;
  60928. /**
  60929. * @ignore
  60930. * The vertical blur PostProcess id in the pipeline
  60931. */
  60932. SSAOBlurVRenderEffect: string;
  60933. /**
  60934. * @ignore
  60935. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60936. */
  60937. SSAOCombineRenderEffect: string;
  60938. /**
  60939. * The output strength of the SSAO post-process. Default value is 1.0.
  60940. */
  60941. totalStrength: number;
  60942. /**
  60943. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60944. */
  60945. radius: number;
  60946. /**
  60947. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60948. * Must not be equal to fallOff and superior to fallOff.
  60949. * Default value is 0.0075
  60950. */
  60951. area: number;
  60952. /**
  60953. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60954. * Must not be equal to area and inferior to area.
  60955. * Default value is 0.000001
  60956. */
  60957. fallOff: number;
  60958. /**
  60959. * The base color of the SSAO post-process
  60960. * The final result is "base + ssao" between [0, 1]
  60961. */
  60962. base: number;
  60963. private _scene;
  60964. private _depthTexture;
  60965. private _randomTexture;
  60966. private _originalColorPostProcess;
  60967. private _ssaoPostProcess;
  60968. private _blurHPostProcess;
  60969. private _blurVPostProcess;
  60970. private _ssaoCombinePostProcess;
  60971. private _firstUpdate;
  60972. /**
  60973. * Gets active scene
  60974. */
  60975. readonly scene: Scene;
  60976. /**
  60977. * @constructor
  60978. * @param name - The rendering pipeline name
  60979. * @param scene - The scene linked to this pipeline
  60980. * @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 }
  60981. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60982. */
  60983. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60984. /**
  60985. * Get the class name
  60986. * @returns "SSAORenderingPipeline"
  60987. */
  60988. getClassName(): string;
  60989. /**
  60990. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60991. */
  60992. dispose(disableDepthRender?: boolean): void;
  60993. private _createBlurPostProcess;
  60994. /** @hidden */
  60995. _rebuild(): void;
  60996. private _createSSAOPostProcess;
  60997. private _createSSAOCombinePostProcess;
  60998. private _createRandomTexture;
  60999. }
  61000. }
  61001. declare module "babylonjs/Shaders/standard.fragment" {
  61002. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61003. /** @hidden */
  61004. export var standardPixelShader: {
  61005. name: string;
  61006. shader: string;
  61007. };
  61008. }
  61009. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  61010. import { Nullable } from "babylonjs/types";
  61011. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  61012. import { Camera } from "babylonjs/Cameras/camera";
  61013. import { Texture } from "babylonjs/Materials/Textures/texture";
  61014. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61015. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61016. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61017. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61018. import { IDisposable } from "babylonjs/scene";
  61019. import { SpotLight } from "babylonjs/Lights/spotLight";
  61020. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61021. import { Scene } from "babylonjs/scene";
  61022. import { Animation } from "babylonjs/Animations/animation";
  61023. import "babylonjs/Shaders/standard.fragment";
  61024. /**
  61025. * Standard rendering pipeline
  61026. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61027. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61028. */
  61029. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61030. /**
  61031. * Public members
  61032. */
  61033. /**
  61034. * Post-process which contains the original scene color before the pipeline applies all the effects
  61035. */
  61036. originalPostProcess: Nullable<PostProcess>;
  61037. /**
  61038. * Post-process used to down scale an image x4
  61039. */
  61040. downSampleX4PostProcess: Nullable<PostProcess>;
  61041. /**
  61042. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61043. */
  61044. brightPassPostProcess: Nullable<PostProcess>;
  61045. /**
  61046. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61047. */
  61048. blurHPostProcesses: PostProcess[];
  61049. /**
  61050. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61051. */
  61052. blurVPostProcesses: PostProcess[];
  61053. /**
  61054. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61055. */
  61056. textureAdderPostProcess: Nullable<PostProcess>;
  61057. /**
  61058. * Post-process used to create volumetric lighting effect
  61059. */
  61060. volumetricLightPostProcess: Nullable<PostProcess>;
  61061. /**
  61062. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61063. */
  61064. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61065. /**
  61066. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61067. */
  61068. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61069. /**
  61070. * Post-process used to merge the volumetric light effect and the real scene color
  61071. */
  61072. volumetricLightMergePostProces: Nullable<PostProcess>;
  61073. /**
  61074. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61075. */
  61076. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61077. /**
  61078. * Base post-process used to calculate the average luminance of the final image for HDR
  61079. */
  61080. luminancePostProcess: Nullable<PostProcess>;
  61081. /**
  61082. * Post-processes used to create down sample post-processes in order to get
  61083. * the average luminance of the final image for HDR
  61084. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61085. */
  61086. luminanceDownSamplePostProcesses: PostProcess[];
  61087. /**
  61088. * Post-process used to create a HDR effect (light adaptation)
  61089. */
  61090. hdrPostProcess: Nullable<PostProcess>;
  61091. /**
  61092. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61093. */
  61094. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61095. /**
  61096. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61097. */
  61098. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61099. /**
  61100. * Post-process used to merge the final HDR post-process and the real scene color
  61101. */
  61102. hdrFinalPostProcess: Nullable<PostProcess>;
  61103. /**
  61104. * Post-process used to create a lens flare effect
  61105. */
  61106. lensFlarePostProcess: Nullable<PostProcess>;
  61107. /**
  61108. * Post-process that merges the result of the lens flare post-process and the real scene color
  61109. */
  61110. lensFlareComposePostProcess: Nullable<PostProcess>;
  61111. /**
  61112. * Post-process used to create a motion blur effect
  61113. */
  61114. motionBlurPostProcess: Nullable<PostProcess>;
  61115. /**
  61116. * Post-process used to create a depth of field effect
  61117. */
  61118. depthOfFieldPostProcess: Nullable<PostProcess>;
  61119. /**
  61120. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61121. */
  61122. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61123. /**
  61124. * Represents the brightness threshold in order to configure the illuminated surfaces
  61125. */
  61126. brightThreshold: number;
  61127. /**
  61128. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61129. */
  61130. blurWidth: number;
  61131. /**
  61132. * Sets if the blur for highlighted surfaces must be only horizontal
  61133. */
  61134. horizontalBlur: boolean;
  61135. /**
  61136. * Gets the overall exposure used by the pipeline
  61137. */
  61138. /**
  61139. * Sets the overall exposure used by the pipeline
  61140. */
  61141. exposure: number;
  61142. /**
  61143. * Texture used typically to simulate "dirty" on camera lens
  61144. */
  61145. lensTexture: Nullable<Texture>;
  61146. /**
  61147. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61148. */
  61149. volumetricLightCoefficient: number;
  61150. /**
  61151. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61152. */
  61153. volumetricLightPower: number;
  61154. /**
  61155. * Used the set the blur intensity to smooth the volumetric lights
  61156. */
  61157. volumetricLightBlurScale: number;
  61158. /**
  61159. * Light (spot or directional) used to generate the volumetric lights rays
  61160. * The source light must have a shadow generate so the pipeline can get its
  61161. * depth map
  61162. */
  61163. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61164. /**
  61165. * For eye adaptation, represents the minimum luminance the eye can see
  61166. */
  61167. hdrMinimumLuminance: number;
  61168. /**
  61169. * For eye adaptation, represents the decrease luminance speed
  61170. */
  61171. hdrDecreaseRate: number;
  61172. /**
  61173. * For eye adaptation, represents the increase luminance speed
  61174. */
  61175. hdrIncreaseRate: number;
  61176. /**
  61177. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61178. */
  61179. /**
  61180. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61181. */
  61182. hdrAutoExposure: boolean;
  61183. /**
  61184. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61185. */
  61186. lensColorTexture: Nullable<Texture>;
  61187. /**
  61188. * The overall strengh for the lens flare effect
  61189. */
  61190. lensFlareStrength: number;
  61191. /**
  61192. * Dispersion coefficient for lens flare ghosts
  61193. */
  61194. lensFlareGhostDispersal: number;
  61195. /**
  61196. * Main lens flare halo width
  61197. */
  61198. lensFlareHaloWidth: number;
  61199. /**
  61200. * Based on the lens distortion effect, defines how much the lens flare result
  61201. * is distorted
  61202. */
  61203. lensFlareDistortionStrength: number;
  61204. /**
  61205. * Lens star texture must be used to simulate rays on the flares and is available
  61206. * in the documentation
  61207. */
  61208. lensStarTexture: Nullable<Texture>;
  61209. /**
  61210. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61211. * flare effect by taking account of the dirt texture
  61212. */
  61213. lensFlareDirtTexture: Nullable<Texture>;
  61214. /**
  61215. * Represents the focal length for the depth of field effect
  61216. */
  61217. depthOfFieldDistance: number;
  61218. /**
  61219. * Represents the blur intensity for the blurred part of the depth of field effect
  61220. */
  61221. depthOfFieldBlurWidth: number;
  61222. /**
  61223. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61224. */
  61225. /**
  61226. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61227. */
  61228. motionStrength: number;
  61229. /**
  61230. * Gets wether or not the motion blur post-process is object based or screen based.
  61231. */
  61232. /**
  61233. * Sets wether or not the motion blur post-process should be object based or screen based
  61234. */
  61235. objectBasedMotionBlur: boolean;
  61236. /**
  61237. * List of animations for the pipeline (IAnimatable implementation)
  61238. */
  61239. animations: Animation[];
  61240. /**
  61241. * Private members
  61242. */
  61243. private _scene;
  61244. private _currentDepthOfFieldSource;
  61245. private _basePostProcess;
  61246. private _fixedExposure;
  61247. private _currentExposure;
  61248. private _hdrAutoExposure;
  61249. private _hdrCurrentLuminance;
  61250. private _motionStrength;
  61251. private _isObjectBasedMotionBlur;
  61252. private _floatTextureType;
  61253. private _ratio;
  61254. private _bloomEnabled;
  61255. private _depthOfFieldEnabled;
  61256. private _vlsEnabled;
  61257. private _lensFlareEnabled;
  61258. private _hdrEnabled;
  61259. private _motionBlurEnabled;
  61260. private _fxaaEnabled;
  61261. private _motionBlurSamples;
  61262. private _volumetricLightStepsCount;
  61263. private _samples;
  61264. /**
  61265. * @ignore
  61266. * Specifies if the bloom pipeline is enabled
  61267. */
  61268. BloomEnabled: boolean;
  61269. /**
  61270. * @ignore
  61271. * Specifies if the depth of field pipeline is enabed
  61272. */
  61273. DepthOfFieldEnabled: boolean;
  61274. /**
  61275. * @ignore
  61276. * Specifies if the lens flare pipeline is enabed
  61277. */
  61278. LensFlareEnabled: boolean;
  61279. /**
  61280. * @ignore
  61281. * Specifies if the HDR pipeline is enabled
  61282. */
  61283. HDREnabled: boolean;
  61284. /**
  61285. * @ignore
  61286. * Specifies if the volumetric lights scattering effect is enabled
  61287. */
  61288. VLSEnabled: boolean;
  61289. /**
  61290. * @ignore
  61291. * Specifies if the motion blur effect is enabled
  61292. */
  61293. MotionBlurEnabled: boolean;
  61294. /**
  61295. * Specifies if anti-aliasing is enabled
  61296. */
  61297. fxaaEnabled: boolean;
  61298. /**
  61299. * Specifies the number of steps used to calculate the volumetric lights
  61300. * Typically in interval [50, 200]
  61301. */
  61302. volumetricLightStepsCount: number;
  61303. /**
  61304. * Specifies the number of samples used for the motion blur effect
  61305. * Typically in interval [16, 64]
  61306. */
  61307. motionBlurSamples: number;
  61308. /**
  61309. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61310. */
  61311. samples: number;
  61312. /**
  61313. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61314. * @constructor
  61315. * @param name The rendering pipeline name
  61316. * @param scene The scene linked to this pipeline
  61317. * @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)
  61318. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61319. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61320. */
  61321. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61322. private _buildPipeline;
  61323. private _createDownSampleX4PostProcess;
  61324. private _createBrightPassPostProcess;
  61325. private _createBlurPostProcesses;
  61326. private _createTextureAdderPostProcess;
  61327. private _createVolumetricLightPostProcess;
  61328. private _createLuminancePostProcesses;
  61329. private _createHdrPostProcess;
  61330. private _createLensFlarePostProcess;
  61331. private _createDepthOfFieldPostProcess;
  61332. private _createMotionBlurPostProcess;
  61333. private _getDepthTexture;
  61334. private _disposePostProcesses;
  61335. /**
  61336. * Dispose of the pipeline and stop all post processes
  61337. */
  61338. dispose(): void;
  61339. /**
  61340. * Serialize the rendering pipeline (Used when exporting)
  61341. * @returns the serialized object
  61342. */
  61343. serialize(): any;
  61344. /**
  61345. * Parse the serialized pipeline
  61346. * @param source Source pipeline.
  61347. * @param scene The scene to load the pipeline to.
  61348. * @param rootUrl The URL of the serialized pipeline.
  61349. * @returns An instantiated pipeline from the serialized object.
  61350. */
  61351. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61352. /**
  61353. * Luminance steps
  61354. */
  61355. static LuminanceSteps: number;
  61356. }
  61357. }
  61358. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61359. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61360. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61361. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61362. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61363. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61364. }
  61365. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61366. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61367. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61368. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61369. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61370. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61371. }
  61372. declare module "babylonjs/Shaders/tonemap.fragment" {
  61373. /** @hidden */
  61374. export var tonemapPixelShader: {
  61375. name: string;
  61376. shader: string;
  61377. };
  61378. }
  61379. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61380. import { Camera } from "babylonjs/Cameras/camera";
  61381. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61382. import "babylonjs/Shaders/tonemap.fragment";
  61383. import { Engine } from "babylonjs/Engines/engine";
  61384. /** Defines operator used for tonemapping */
  61385. export enum TonemappingOperator {
  61386. /** Hable */
  61387. Hable = 0,
  61388. /** Reinhard */
  61389. Reinhard = 1,
  61390. /** HejiDawson */
  61391. HejiDawson = 2,
  61392. /** Photographic */
  61393. Photographic = 3
  61394. }
  61395. /**
  61396. * Defines a post process to apply tone mapping
  61397. */
  61398. export class TonemapPostProcess extends PostProcess {
  61399. private _operator;
  61400. /** Defines the required exposure adjustement */
  61401. exposureAdjustment: number;
  61402. /**
  61403. * Creates a new TonemapPostProcess
  61404. * @param name defines the name of the postprocess
  61405. * @param _operator defines the operator to use
  61406. * @param exposureAdjustment defines the required exposure adjustement
  61407. * @param camera defines the camera to use (can be null)
  61408. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61409. * @param engine defines the hosting engine (can be ignore if camera is set)
  61410. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61411. */
  61412. constructor(name: string, _operator: TonemappingOperator,
  61413. /** Defines the required exposure adjustement */
  61414. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61415. }
  61416. }
  61417. declare module "babylonjs/Shaders/depth.vertex" {
  61418. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61419. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61420. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61421. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61423. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61424. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61425. /** @hidden */
  61426. export var depthVertexShader: {
  61427. name: string;
  61428. shader: string;
  61429. };
  61430. }
  61431. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61432. /** @hidden */
  61433. export var volumetricLightScatteringPixelShader: {
  61434. name: string;
  61435. shader: string;
  61436. };
  61437. }
  61438. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61439. /** @hidden */
  61440. export var volumetricLightScatteringPassPixelShader: {
  61441. name: string;
  61442. shader: string;
  61443. };
  61444. }
  61445. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61446. import { Vector3 } from "babylonjs/Maths/math.vector";
  61447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61448. import { Mesh } from "babylonjs/Meshes/mesh";
  61449. import { Camera } from "babylonjs/Cameras/camera";
  61450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61452. import { Scene } from "babylonjs/scene";
  61453. import "babylonjs/Meshes/Builders/planeBuilder";
  61454. import "babylonjs/Shaders/depth.vertex";
  61455. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61456. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61457. import { Engine } from "babylonjs/Engines/engine";
  61458. /**
  61459. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61460. */
  61461. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61462. private _volumetricLightScatteringPass;
  61463. private _volumetricLightScatteringRTT;
  61464. private _viewPort;
  61465. private _screenCoordinates;
  61466. private _cachedDefines;
  61467. /**
  61468. * If not undefined, the mesh position is computed from the attached node position
  61469. */
  61470. attachedNode: {
  61471. position: Vector3;
  61472. };
  61473. /**
  61474. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61475. */
  61476. customMeshPosition: Vector3;
  61477. /**
  61478. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61479. */
  61480. useCustomMeshPosition: boolean;
  61481. /**
  61482. * If the post-process should inverse the light scattering direction
  61483. */
  61484. invert: boolean;
  61485. /**
  61486. * The internal mesh used by the post-process
  61487. */
  61488. mesh: Mesh;
  61489. /**
  61490. * @hidden
  61491. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61492. */
  61493. useDiffuseColor: boolean;
  61494. /**
  61495. * Array containing the excluded meshes not rendered in the internal pass
  61496. */
  61497. excludedMeshes: AbstractMesh[];
  61498. /**
  61499. * Controls the overall intensity of the post-process
  61500. */
  61501. exposure: number;
  61502. /**
  61503. * Dissipates each sample's contribution in range [0, 1]
  61504. */
  61505. decay: number;
  61506. /**
  61507. * Controls the overall intensity of each sample
  61508. */
  61509. weight: number;
  61510. /**
  61511. * Controls the density of each sample
  61512. */
  61513. density: number;
  61514. /**
  61515. * @constructor
  61516. * @param name The post-process name
  61517. * @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)
  61518. * @param camera The camera that the post-process will be attached to
  61519. * @param mesh The mesh used to create the light scattering
  61520. * @param samples The post-process quality, default 100
  61521. * @param samplingModeThe post-process filtering mode
  61522. * @param engine The babylon engine
  61523. * @param reusable If the post-process is reusable
  61524. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61525. */
  61526. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61527. /**
  61528. * Returns the string "VolumetricLightScatteringPostProcess"
  61529. * @returns "VolumetricLightScatteringPostProcess"
  61530. */
  61531. getClassName(): string;
  61532. private _isReady;
  61533. /**
  61534. * Sets the new light position for light scattering effect
  61535. * @param position The new custom light position
  61536. */
  61537. setCustomMeshPosition(position: Vector3): void;
  61538. /**
  61539. * Returns the light position for light scattering effect
  61540. * @return Vector3 The custom light position
  61541. */
  61542. getCustomMeshPosition(): Vector3;
  61543. /**
  61544. * Disposes the internal assets and detaches the post-process from the camera
  61545. */
  61546. dispose(camera: Camera): void;
  61547. /**
  61548. * Returns the render target texture used by the post-process
  61549. * @return the render target texture used by the post-process
  61550. */
  61551. getPass(): RenderTargetTexture;
  61552. private _meshExcluded;
  61553. private _createPass;
  61554. private _updateMeshScreenCoordinates;
  61555. /**
  61556. * Creates a default mesh for the Volumeric Light Scattering post-process
  61557. * @param name The mesh name
  61558. * @param scene The scene where to create the mesh
  61559. * @return the default mesh
  61560. */
  61561. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61562. }
  61563. }
  61564. declare module "babylonjs/PostProcesses/index" {
  61565. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61566. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61567. export * from "babylonjs/PostProcesses/bloomEffect";
  61568. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61569. export * from "babylonjs/PostProcesses/blurPostProcess";
  61570. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61571. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61572. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61573. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61574. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61575. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61576. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61577. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61578. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61579. export * from "babylonjs/PostProcesses/filterPostProcess";
  61580. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61581. export * from "babylonjs/PostProcesses/grainPostProcess";
  61582. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61583. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61584. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61585. export * from "babylonjs/PostProcesses/passPostProcess";
  61586. export * from "babylonjs/PostProcesses/postProcess";
  61587. export * from "babylonjs/PostProcesses/postProcessManager";
  61588. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61589. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61590. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61591. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61592. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61593. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61594. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61595. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61596. }
  61597. declare module "babylonjs/Probes/index" {
  61598. export * from "babylonjs/Probes/reflectionProbe";
  61599. }
  61600. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61601. import { Scene } from "babylonjs/scene";
  61602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61603. import { SmartArray } from "babylonjs/Misc/smartArray";
  61604. import { ISceneComponent } from "babylonjs/sceneComponent";
  61605. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61606. import "babylonjs/Meshes/Builders/boxBuilder";
  61607. import "babylonjs/Shaders/color.fragment";
  61608. import "babylonjs/Shaders/color.vertex";
  61609. import { Color3 } from "babylonjs/Maths/math.color";
  61610. module "babylonjs/scene" {
  61611. interface Scene {
  61612. /** @hidden (Backing field) */
  61613. _boundingBoxRenderer: BoundingBoxRenderer;
  61614. /** @hidden (Backing field) */
  61615. _forceShowBoundingBoxes: boolean;
  61616. /**
  61617. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61618. */
  61619. forceShowBoundingBoxes: boolean;
  61620. /**
  61621. * Gets the bounding box renderer associated with the scene
  61622. * @returns a BoundingBoxRenderer
  61623. */
  61624. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61625. }
  61626. }
  61627. module "babylonjs/Meshes/abstractMesh" {
  61628. interface AbstractMesh {
  61629. /** @hidden (Backing field) */
  61630. _showBoundingBox: boolean;
  61631. /**
  61632. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61633. */
  61634. showBoundingBox: boolean;
  61635. }
  61636. }
  61637. /**
  61638. * Component responsible of rendering the bounding box of the meshes in a scene.
  61639. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61640. */
  61641. export class BoundingBoxRenderer implements ISceneComponent {
  61642. /**
  61643. * The component name helpfull to identify the component in the list of scene components.
  61644. */
  61645. readonly name: string;
  61646. /**
  61647. * The scene the component belongs to.
  61648. */
  61649. scene: Scene;
  61650. /**
  61651. * Color of the bounding box lines placed in front of an object
  61652. */
  61653. frontColor: Color3;
  61654. /**
  61655. * Color of the bounding box lines placed behind an object
  61656. */
  61657. backColor: Color3;
  61658. /**
  61659. * Defines if the renderer should show the back lines or not
  61660. */
  61661. showBackLines: boolean;
  61662. /**
  61663. * @hidden
  61664. */
  61665. renderList: SmartArray<BoundingBox>;
  61666. private _colorShader;
  61667. private _vertexBuffers;
  61668. private _indexBuffer;
  61669. private _fillIndexBuffer;
  61670. private _fillIndexData;
  61671. /**
  61672. * Instantiates a new bounding box renderer in a scene.
  61673. * @param scene the scene the renderer renders in
  61674. */
  61675. constructor(scene: Scene);
  61676. /**
  61677. * Registers the component in a given scene
  61678. */
  61679. register(): void;
  61680. private _evaluateSubMesh;
  61681. private _activeMesh;
  61682. private _prepareRessources;
  61683. private _createIndexBuffer;
  61684. /**
  61685. * Rebuilds the elements related to this component in case of
  61686. * context lost for instance.
  61687. */
  61688. rebuild(): void;
  61689. /**
  61690. * @hidden
  61691. */
  61692. reset(): void;
  61693. /**
  61694. * Render the bounding boxes of a specific rendering group
  61695. * @param renderingGroupId defines the rendering group to render
  61696. */
  61697. render(renderingGroupId: number): void;
  61698. /**
  61699. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61700. * @param mesh Define the mesh to render the occlusion bounding box for
  61701. */
  61702. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61703. /**
  61704. * Dispose and release the resources attached to this renderer.
  61705. */
  61706. dispose(): void;
  61707. }
  61708. }
  61709. declare module "babylonjs/Shaders/depth.fragment" {
  61710. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61711. /** @hidden */
  61712. export var depthPixelShader: {
  61713. name: string;
  61714. shader: string;
  61715. };
  61716. }
  61717. declare module "babylonjs/Rendering/depthRenderer" {
  61718. import { Nullable } from "babylonjs/types";
  61719. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61720. import { Scene } from "babylonjs/scene";
  61721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61722. import { Camera } from "babylonjs/Cameras/camera";
  61723. import "babylonjs/Shaders/depth.fragment";
  61724. import "babylonjs/Shaders/depth.vertex";
  61725. /**
  61726. * This represents a depth renderer in Babylon.
  61727. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61728. */
  61729. export class DepthRenderer {
  61730. private _scene;
  61731. private _depthMap;
  61732. private _effect;
  61733. private readonly _storeNonLinearDepth;
  61734. private readonly _clearColor;
  61735. /** Get if the depth renderer is using packed depth or not */
  61736. readonly isPacked: boolean;
  61737. private _cachedDefines;
  61738. private _camera;
  61739. /**
  61740. * Specifiess that the depth renderer will only be used within
  61741. * the camera it is created for.
  61742. * This can help forcing its rendering during the camera processing.
  61743. */
  61744. useOnlyInActiveCamera: boolean;
  61745. /** @hidden */
  61746. static _SceneComponentInitialization: (scene: Scene) => void;
  61747. /**
  61748. * Instantiates a depth renderer
  61749. * @param scene The scene the renderer belongs to
  61750. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61751. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61752. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61753. */
  61754. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61755. /**
  61756. * Creates the depth rendering effect and checks if the effect is ready.
  61757. * @param subMesh The submesh to be used to render the depth map of
  61758. * @param useInstances If multiple world instances should be used
  61759. * @returns if the depth renderer is ready to render the depth map
  61760. */
  61761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61762. /**
  61763. * Gets the texture which the depth map will be written to.
  61764. * @returns The depth map texture
  61765. */
  61766. getDepthMap(): RenderTargetTexture;
  61767. /**
  61768. * Disposes of the depth renderer.
  61769. */
  61770. dispose(): void;
  61771. }
  61772. }
  61773. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61774. import { Nullable } from "babylonjs/types";
  61775. import { Scene } from "babylonjs/scene";
  61776. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61777. import { Camera } from "babylonjs/Cameras/camera";
  61778. import { ISceneComponent } from "babylonjs/sceneComponent";
  61779. module "babylonjs/scene" {
  61780. interface Scene {
  61781. /** @hidden (Backing field) */
  61782. _depthRenderer: {
  61783. [id: string]: DepthRenderer;
  61784. };
  61785. /**
  61786. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61787. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61788. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61789. * @returns the created depth renderer
  61790. */
  61791. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61792. /**
  61793. * Disables a depth renderer for a given camera
  61794. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61795. */
  61796. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61797. }
  61798. }
  61799. /**
  61800. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61801. * in several rendering techniques.
  61802. */
  61803. export class DepthRendererSceneComponent implements ISceneComponent {
  61804. /**
  61805. * The component name helpfull to identify the component in the list of scene components.
  61806. */
  61807. readonly name: string;
  61808. /**
  61809. * The scene the component belongs to.
  61810. */
  61811. scene: Scene;
  61812. /**
  61813. * Creates a new instance of the component for the given scene
  61814. * @param scene Defines the scene to register the component in
  61815. */
  61816. constructor(scene: Scene);
  61817. /**
  61818. * Registers the component in a given scene
  61819. */
  61820. register(): void;
  61821. /**
  61822. * Rebuilds the elements related to this component in case of
  61823. * context lost for instance.
  61824. */
  61825. rebuild(): void;
  61826. /**
  61827. * Disposes the component and the associated ressources
  61828. */
  61829. dispose(): void;
  61830. private _gatherRenderTargets;
  61831. private _gatherActiveCameraRenderTargets;
  61832. }
  61833. }
  61834. declare module "babylonjs/Shaders/outline.fragment" {
  61835. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61836. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61837. /** @hidden */
  61838. export var outlinePixelShader: {
  61839. name: string;
  61840. shader: string;
  61841. };
  61842. }
  61843. declare module "babylonjs/Shaders/outline.vertex" {
  61844. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61846. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61847. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61848. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61850. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61851. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61852. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  61853. /** @hidden */
  61854. export var outlineVertexShader: {
  61855. name: string;
  61856. shader: string;
  61857. };
  61858. }
  61859. declare module "babylonjs/Rendering/outlineRenderer" {
  61860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61861. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  61862. import { Scene } from "babylonjs/scene";
  61863. import { ISceneComponent } from "babylonjs/sceneComponent";
  61864. import "babylonjs/Shaders/outline.fragment";
  61865. import "babylonjs/Shaders/outline.vertex";
  61866. module "babylonjs/scene" {
  61867. interface Scene {
  61868. /** @hidden */
  61869. _outlineRenderer: OutlineRenderer;
  61870. /**
  61871. * Gets the outline renderer associated with the scene
  61872. * @returns a OutlineRenderer
  61873. */
  61874. getOutlineRenderer(): OutlineRenderer;
  61875. }
  61876. }
  61877. module "babylonjs/Meshes/abstractMesh" {
  61878. interface AbstractMesh {
  61879. /** @hidden (Backing field) */
  61880. _renderOutline: boolean;
  61881. /**
  61882. * Gets or sets a boolean indicating if the outline must be rendered as well
  61883. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61884. */
  61885. renderOutline: boolean;
  61886. /** @hidden (Backing field) */
  61887. _renderOverlay: boolean;
  61888. /**
  61889. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61890. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61891. */
  61892. renderOverlay: boolean;
  61893. }
  61894. }
  61895. /**
  61896. * This class is responsible to draw bothe outline/overlay of meshes.
  61897. * It should not be used directly but through the available method on mesh.
  61898. */
  61899. export class OutlineRenderer implements ISceneComponent {
  61900. /**
  61901. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61902. */
  61903. private static _StencilReference;
  61904. /**
  61905. * The name of the component. Each component must have a unique name.
  61906. */
  61907. name: string;
  61908. /**
  61909. * The scene the component belongs to.
  61910. */
  61911. scene: Scene;
  61912. /**
  61913. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61914. */
  61915. zOffset: number;
  61916. private _engine;
  61917. private _effect;
  61918. private _cachedDefines;
  61919. private _savedDepthWrite;
  61920. /**
  61921. * Instantiates a new outline renderer. (There could be only one per scene).
  61922. * @param scene Defines the scene it belongs to
  61923. */
  61924. constructor(scene: Scene);
  61925. /**
  61926. * Register the component to one instance of a scene.
  61927. */
  61928. register(): void;
  61929. /**
  61930. * Rebuilds the elements related to this component in case of
  61931. * context lost for instance.
  61932. */
  61933. rebuild(): void;
  61934. /**
  61935. * Disposes the component and the associated ressources.
  61936. */
  61937. dispose(): void;
  61938. /**
  61939. * Renders the outline in the canvas.
  61940. * @param subMesh Defines the sumesh to render
  61941. * @param batch Defines the batch of meshes in case of instances
  61942. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61943. */
  61944. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61945. /**
  61946. * Returns whether or not the outline renderer is ready for a given submesh.
  61947. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61948. * @param subMesh Defines the submesh to check readyness for
  61949. * @param useInstances Defines wheter wee are trying to render instances or not
  61950. * @returns true if ready otherwise false
  61951. */
  61952. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61953. private _beforeRenderingMesh;
  61954. private _afterRenderingMesh;
  61955. }
  61956. }
  61957. declare module "babylonjs/Rendering/index" {
  61958. export * from "babylonjs/Rendering/boundingBoxRenderer";
  61959. export * from "babylonjs/Rendering/depthRenderer";
  61960. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  61961. export * from "babylonjs/Rendering/edgesRenderer";
  61962. export * from "babylonjs/Rendering/geometryBufferRenderer";
  61963. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61964. export * from "babylonjs/Rendering/outlineRenderer";
  61965. export * from "babylonjs/Rendering/renderingGroup";
  61966. export * from "babylonjs/Rendering/renderingManager";
  61967. export * from "babylonjs/Rendering/utilityLayerRenderer";
  61968. }
  61969. declare module "babylonjs/Sprites/index" {
  61970. export * from "babylonjs/Sprites/sprite";
  61971. export * from "babylonjs/Sprites/spriteManager";
  61972. export * from "babylonjs/Sprites/spriteSceneComponent";
  61973. }
  61974. declare module "babylonjs/Misc/assetsManager" {
  61975. import { Scene } from "babylonjs/scene";
  61976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61977. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61978. import { Skeleton } from "babylonjs/Bones/skeleton";
  61979. import { Observable } from "babylonjs/Misc/observable";
  61980. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61981. import { Texture } from "babylonjs/Materials/Textures/texture";
  61982. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  61983. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  61984. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  61985. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  61986. /**
  61987. * Defines the list of states available for a task inside a AssetsManager
  61988. */
  61989. export enum AssetTaskState {
  61990. /**
  61991. * Initialization
  61992. */
  61993. INIT = 0,
  61994. /**
  61995. * Running
  61996. */
  61997. RUNNING = 1,
  61998. /**
  61999. * Done
  62000. */
  62001. DONE = 2,
  62002. /**
  62003. * Error
  62004. */
  62005. ERROR = 3
  62006. }
  62007. /**
  62008. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  62009. */
  62010. export abstract class AbstractAssetTask {
  62011. /**
  62012. * Task name
  62013. */ name: string;
  62014. /**
  62015. * Callback called when the task is successful
  62016. */
  62017. onSuccess: (task: any) => void;
  62018. /**
  62019. * Callback called when the task is not successful
  62020. */
  62021. onError: (task: any, message?: string, exception?: any) => void;
  62022. /**
  62023. * Creates a new AssetsManager
  62024. * @param name defines the name of the task
  62025. */
  62026. constructor(
  62027. /**
  62028. * Task name
  62029. */ name: string);
  62030. private _isCompleted;
  62031. private _taskState;
  62032. private _errorObject;
  62033. /**
  62034. * Get if the task is completed
  62035. */
  62036. readonly isCompleted: boolean;
  62037. /**
  62038. * Gets the current state of the task
  62039. */
  62040. readonly taskState: AssetTaskState;
  62041. /**
  62042. * Gets the current error object (if task is in error)
  62043. */
  62044. readonly errorObject: {
  62045. message?: string;
  62046. exception?: any;
  62047. };
  62048. /**
  62049. * Internal only
  62050. * @hidden
  62051. */
  62052. _setErrorObject(message?: string, exception?: any): void;
  62053. /**
  62054. * Execute the current task
  62055. * @param scene defines the scene where you want your assets to be loaded
  62056. * @param onSuccess is a callback called when the task is successfully executed
  62057. * @param onError is a callback called if an error occurs
  62058. */
  62059. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62060. /**
  62061. * Execute the current task
  62062. * @param scene defines the scene where you want your assets to be loaded
  62063. * @param onSuccess is a callback called when the task is successfully executed
  62064. * @param onError is a callback called if an error occurs
  62065. */
  62066. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62067. /**
  62068. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62069. * This can be used with failed tasks that have the reason for failure fixed.
  62070. */
  62071. reset(): void;
  62072. private onErrorCallback;
  62073. private onDoneCallback;
  62074. }
  62075. /**
  62076. * Define the interface used by progress events raised during assets loading
  62077. */
  62078. export interface IAssetsProgressEvent {
  62079. /**
  62080. * Defines the number of remaining tasks to process
  62081. */
  62082. remainingCount: number;
  62083. /**
  62084. * Defines the total number of tasks
  62085. */
  62086. totalCount: number;
  62087. /**
  62088. * Defines the task that was just processed
  62089. */
  62090. task: AbstractAssetTask;
  62091. }
  62092. /**
  62093. * Class used to share progress information about assets loading
  62094. */
  62095. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62096. /**
  62097. * Defines the number of remaining tasks to process
  62098. */
  62099. remainingCount: number;
  62100. /**
  62101. * Defines the total number of tasks
  62102. */
  62103. totalCount: number;
  62104. /**
  62105. * Defines the task that was just processed
  62106. */
  62107. task: AbstractAssetTask;
  62108. /**
  62109. * Creates a AssetsProgressEvent
  62110. * @param remainingCount defines the number of remaining tasks to process
  62111. * @param totalCount defines the total number of tasks
  62112. * @param task defines the task that was just processed
  62113. */
  62114. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62115. }
  62116. /**
  62117. * Define a task used by AssetsManager to load meshes
  62118. */
  62119. export class MeshAssetTask extends AbstractAssetTask {
  62120. /**
  62121. * Defines the name of the task
  62122. */
  62123. name: string;
  62124. /**
  62125. * Defines the list of mesh's names you want to load
  62126. */
  62127. meshesNames: any;
  62128. /**
  62129. * Defines the root url to use as a base to load your meshes and associated resources
  62130. */
  62131. rootUrl: string;
  62132. /**
  62133. * Defines the filename of the scene to load from
  62134. */
  62135. sceneFilename: string;
  62136. /**
  62137. * Gets the list of loaded meshes
  62138. */
  62139. loadedMeshes: Array<AbstractMesh>;
  62140. /**
  62141. * Gets the list of loaded particle systems
  62142. */
  62143. loadedParticleSystems: Array<IParticleSystem>;
  62144. /**
  62145. * Gets the list of loaded skeletons
  62146. */
  62147. loadedSkeletons: Array<Skeleton>;
  62148. /**
  62149. * Gets the list of loaded animation groups
  62150. */
  62151. loadedAnimationGroups: Array<AnimationGroup>;
  62152. /**
  62153. * Callback called when the task is successful
  62154. */
  62155. onSuccess: (task: MeshAssetTask) => void;
  62156. /**
  62157. * Callback called when the task is successful
  62158. */
  62159. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62160. /**
  62161. * Creates a new MeshAssetTask
  62162. * @param name defines the name of the task
  62163. * @param meshesNames defines the list of mesh's names you want to load
  62164. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62165. * @param sceneFilename defines the filename of the scene to load from
  62166. */
  62167. constructor(
  62168. /**
  62169. * Defines the name of the task
  62170. */
  62171. name: string,
  62172. /**
  62173. * Defines the list of mesh's names you want to load
  62174. */
  62175. meshesNames: any,
  62176. /**
  62177. * Defines the root url to use as a base to load your meshes and associated resources
  62178. */
  62179. rootUrl: string,
  62180. /**
  62181. * Defines the filename of the scene to load from
  62182. */
  62183. sceneFilename: string);
  62184. /**
  62185. * Execute the current task
  62186. * @param scene defines the scene where you want your assets to be loaded
  62187. * @param onSuccess is a callback called when the task is successfully executed
  62188. * @param onError is a callback called if an error occurs
  62189. */
  62190. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62191. }
  62192. /**
  62193. * Define a task used by AssetsManager to load text content
  62194. */
  62195. export class TextFileAssetTask extends AbstractAssetTask {
  62196. /**
  62197. * Defines the name of the task
  62198. */
  62199. name: string;
  62200. /**
  62201. * Defines the location of the file to load
  62202. */
  62203. url: string;
  62204. /**
  62205. * Gets the loaded text string
  62206. */
  62207. text: string;
  62208. /**
  62209. * Callback called when the task is successful
  62210. */
  62211. onSuccess: (task: TextFileAssetTask) => void;
  62212. /**
  62213. * Callback called when the task is successful
  62214. */
  62215. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62216. /**
  62217. * Creates a new TextFileAssetTask object
  62218. * @param name defines the name of the task
  62219. * @param url defines the location of the file to load
  62220. */
  62221. constructor(
  62222. /**
  62223. * Defines the name of the task
  62224. */
  62225. name: string,
  62226. /**
  62227. * Defines the location of the file to load
  62228. */
  62229. url: string);
  62230. /**
  62231. * Execute the current task
  62232. * @param scene defines the scene where you want your assets to be loaded
  62233. * @param onSuccess is a callback called when the task is successfully executed
  62234. * @param onError is a callback called if an error occurs
  62235. */
  62236. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62237. }
  62238. /**
  62239. * Define a task used by AssetsManager to load binary data
  62240. */
  62241. export class BinaryFileAssetTask extends AbstractAssetTask {
  62242. /**
  62243. * Defines the name of the task
  62244. */
  62245. name: string;
  62246. /**
  62247. * Defines the location of the file to load
  62248. */
  62249. url: string;
  62250. /**
  62251. * Gets the lodaded data (as an array buffer)
  62252. */
  62253. data: ArrayBuffer;
  62254. /**
  62255. * Callback called when the task is successful
  62256. */
  62257. onSuccess: (task: BinaryFileAssetTask) => void;
  62258. /**
  62259. * Callback called when the task is successful
  62260. */
  62261. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62262. /**
  62263. * Creates a new BinaryFileAssetTask object
  62264. * @param name defines the name of the new task
  62265. * @param url defines the location of the file to load
  62266. */
  62267. constructor(
  62268. /**
  62269. * Defines the name of the task
  62270. */
  62271. name: string,
  62272. /**
  62273. * Defines the location of the file to load
  62274. */
  62275. url: string);
  62276. /**
  62277. * Execute the current task
  62278. * @param scene defines the scene where you want your assets to be loaded
  62279. * @param onSuccess is a callback called when the task is successfully executed
  62280. * @param onError is a callback called if an error occurs
  62281. */
  62282. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62283. }
  62284. /**
  62285. * Define a task used by AssetsManager to load images
  62286. */
  62287. export class ImageAssetTask extends AbstractAssetTask {
  62288. /**
  62289. * Defines the name of the task
  62290. */
  62291. name: string;
  62292. /**
  62293. * Defines the location of the image to load
  62294. */
  62295. url: string;
  62296. /**
  62297. * Gets the loaded images
  62298. */
  62299. image: HTMLImageElement;
  62300. /**
  62301. * Callback called when the task is successful
  62302. */
  62303. onSuccess: (task: ImageAssetTask) => void;
  62304. /**
  62305. * Callback called when the task is successful
  62306. */
  62307. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62308. /**
  62309. * Creates a new ImageAssetTask
  62310. * @param name defines the name of the task
  62311. * @param url defines the location of the image to load
  62312. */
  62313. constructor(
  62314. /**
  62315. * Defines the name of the task
  62316. */
  62317. name: string,
  62318. /**
  62319. * Defines the location of the image to load
  62320. */
  62321. url: string);
  62322. /**
  62323. * Execute the current task
  62324. * @param scene defines the scene where you want your assets to be loaded
  62325. * @param onSuccess is a callback called when the task is successfully executed
  62326. * @param onError is a callback called if an error occurs
  62327. */
  62328. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62329. }
  62330. /**
  62331. * Defines the interface used by texture loading tasks
  62332. */
  62333. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62334. /**
  62335. * Gets the loaded texture
  62336. */
  62337. texture: TEX;
  62338. }
  62339. /**
  62340. * Define a task used by AssetsManager to load 2D textures
  62341. */
  62342. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62343. /**
  62344. * Defines the name of the task
  62345. */
  62346. name: string;
  62347. /**
  62348. * Defines the location of the file to load
  62349. */
  62350. url: string;
  62351. /**
  62352. * Defines if mipmap should not be generated (default is false)
  62353. */
  62354. noMipmap?: boolean | undefined;
  62355. /**
  62356. * Defines if texture must be inverted on Y axis (default is false)
  62357. */
  62358. invertY?: boolean | undefined;
  62359. /**
  62360. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62361. */
  62362. samplingMode: number;
  62363. /**
  62364. * Gets the loaded texture
  62365. */
  62366. texture: Texture;
  62367. /**
  62368. * Callback called when the task is successful
  62369. */
  62370. onSuccess: (task: TextureAssetTask) => void;
  62371. /**
  62372. * Callback called when the task is successful
  62373. */
  62374. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62375. /**
  62376. * Creates a new TextureAssetTask object
  62377. * @param name defines the name of the task
  62378. * @param url defines the location of the file to load
  62379. * @param noMipmap defines if mipmap should not be generated (default is false)
  62380. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62381. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62382. */
  62383. constructor(
  62384. /**
  62385. * Defines the name of the task
  62386. */
  62387. name: string,
  62388. /**
  62389. * Defines the location of the file to load
  62390. */
  62391. url: string,
  62392. /**
  62393. * Defines if mipmap should not be generated (default is false)
  62394. */
  62395. noMipmap?: boolean | undefined,
  62396. /**
  62397. * Defines if texture must be inverted on Y axis (default is false)
  62398. */
  62399. invertY?: boolean | undefined,
  62400. /**
  62401. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62402. */
  62403. samplingMode?: number);
  62404. /**
  62405. * Execute the current task
  62406. * @param scene defines the scene where you want your assets to be loaded
  62407. * @param onSuccess is a callback called when the task is successfully executed
  62408. * @param onError is a callback called if an error occurs
  62409. */
  62410. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62411. }
  62412. /**
  62413. * Define a task used by AssetsManager to load cube textures
  62414. */
  62415. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62416. /**
  62417. * Defines the name of the task
  62418. */
  62419. name: string;
  62420. /**
  62421. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62422. */
  62423. url: string;
  62424. /**
  62425. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62426. */
  62427. extensions?: string[] | undefined;
  62428. /**
  62429. * Defines if mipmaps should not be generated (default is false)
  62430. */
  62431. noMipmap?: boolean | undefined;
  62432. /**
  62433. * Defines the explicit list of files (undefined by default)
  62434. */
  62435. files?: string[] | undefined;
  62436. /**
  62437. * Gets the loaded texture
  62438. */
  62439. texture: CubeTexture;
  62440. /**
  62441. * Callback called when the task is successful
  62442. */
  62443. onSuccess: (task: CubeTextureAssetTask) => void;
  62444. /**
  62445. * Callback called when the task is successful
  62446. */
  62447. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62448. /**
  62449. * Creates a new CubeTextureAssetTask
  62450. * @param name defines the name of the task
  62451. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62452. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62453. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62454. * @param files defines the explicit list of files (undefined by default)
  62455. */
  62456. constructor(
  62457. /**
  62458. * Defines the name of the task
  62459. */
  62460. name: string,
  62461. /**
  62462. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62463. */
  62464. url: string,
  62465. /**
  62466. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62467. */
  62468. extensions?: string[] | undefined,
  62469. /**
  62470. * Defines if mipmaps should not be generated (default is false)
  62471. */
  62472. noMipmap?: boolean | undefined,
  62473. /**
  62474. * Defines the explicit list of files (undefined by default)
  62475. */
  62476. files?: string[] | undefined);
  62477. /**
  62478. * Execute the current task
  62479. * @param scene defines the scene where you want your assets to be loaded
  62480. * @param onSuccess is a callback called when the task is successfully executed
  62481. * @param onError is a callback called if an error occurs
  62482. */
  62483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62484. }
  62485. /**
  62486. * Define a task used by AssetsManager to load HDR cube textures
  62487. */
  62488. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62489. /**
  62490. * Defines the name of the task
  62491. */
  62492. name: string;
  62493. /**
  62494. * Defines the location of the file to load
  62495. */
  62496. url: string;
  62497. /**
  62498. * Defines the desired size (the more it increases the longer the generation will be)
  62499. */
  62500. size: number;
  62501. /**
  62502. * Defines if mipmaps should not be generated (default is false)
  62503. */
  62504. noMipmap: boolean;
  62505. /**
  62506. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62507. */
  62508. generateHarmonics: boolean;
  62509. /**
  62510. * 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)
  62511. */
  62512. gammaSpace: boolean;
  62513. /**
  62514. * Internal Use Only
  62515. */
  62516. reserved: boolean;
  62517. /**
  62518. * Gets the loaded texture
  62519. */
  62520. texture: HDRCubeTexture;
  62521. /**
  62522. * Callback called when the task is successful
  62523. */
  62524. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62525. /**
  62526. * Callback called when the task is successful
  62527. */
  62528. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62529. /**
  62530. * Creates a new HDRCubeTextureAssetTask object
  62531. * @param name defines the name of the task
  62532. * @param url defines the location of the file to load
  62533. * @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.
  62534. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62535. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62536. * @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)
  62537. * @param reserved Internal use only
  62538. */
  62539. constructor(
  62540. /**
  62541. * Defines the name of the task
  62542. */
  62543. name: string,
  62544. /**
  62545. * Defines the location of the file to load
  62546. */
  62547. url: string,
  62548. /**
  62549. * Defines the desired size (the more it increases the longer the generation will be)
  62550. */
  62551. size: number,
  62552. /**
  62553. * Defines if mipmaps should not be generated (default is false)
  62554. */
  62555. noMipmap?: boolean,
  62556. /**
  62557. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62558. */
  62559. generateHarmonics?: boolean,
  62560. /**
  62561. * 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)
  62562. */
  62563. gammaSpace?: boolean,
  62564. /**
  62565. * Internal Use Only
  62566. */
  62567. reserved?: boolean);
  62568. /**
  62569. * Execute the current task
  62570. * @param scene defines the scene where you want your assets to be loaded
  62571. * @param onSuccess is a callback called when the task is successfully executed
  62572. * @param onError is a callback called if an error occurs
  62573. */
  62574. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62575. }
  62576. /**
  62577. * Define a task used by AssetsManager to load Equirectangular cube textures
  62578. */
  62579. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62580. /**
  62581. * Defines the name of the task
  62582. */
  62583. name: string;
  62584. /**
  62585. * Defines the location of the file to load
  62586. */
  62587. url: string;
  62588. /**
  62589. * Defines the desired size (the more it increases the longer the generation will be)
  62590. */
  62591. size: number;
  62592. /**
  62593. * Defines if mipmaps should not be generated (default is false)
  62594. */
  62595. noMipmap: boolean;
  62596. /**
  62597. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62598. * but the standard material would require them in Gamma space) (default is true)
  62599. */
  62600. gammaSpace: boolean;
  62601. /**
  62602. * Gets the loaded texture
  62603. */
  62604. texture: EquiRectangularCubeTexture;
  62605. /**
  62606. * Callback called when the task is successful
  62607. */
  62608. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62609. /**
  62610. * Callback called when the task is successful
  62611. */
  62612. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62613. /**
  62614. * Creates a new EquiRectangularCubeTextureAssetTask object
  62615. * @param name defines the name of the task
  62616. * @param url defines the location of the file to load
  62617. * @param size defines the desired size (the more it increases the longer the generation will be)
  62618. * If the size is omitted this implies you are using a preprocessed cubemap.
  62619. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62620. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62621. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62622. * (default is true)
  62623. */
  62624. constructor(
  62625. /**
  62626. * Defines the name of the task
  62627. */
  62628. name: string,
  62629. /**
  62630. * Defines the location of the file to load
  62631. */
  62632. url: string,
  62633. /**
  62634. * Defines the desired size (the more it increases the longer the generation will be)
  62635. */
  62636. size: number,
  62637. /**
  62638. * Defines if mipmaps should not be generated (default is false)
  62639. */
  62640. noMipmap?: boolean,
  62641. /**
  62642. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62643. * but the standard material would require them in Gamma space) (default is true)
  62644. */
  62645. gammaSpace?: boolean);
  62646. /**
  62647. * Execute the current task
  62648. * @param scene defines the scene where you want your assets to be loaded
  62649. * @param onSuccess is a callback called when the task is successfully executed
  62650. * @param onError is a callback called if an error occurs
  62651. */
  62652. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62653. }
  62654. /**
  62655. * This class can be used to easily import assets into a scene
  62656. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62657. */
  62658. export class AssetsManager {
  62659. private _scene;
  62660. private _isLoading;
  62661. protected _tasks: AbstractAssetTask[];
  62662. protected _waitingTasksCount: number;
  62663. protected _totalTasksCount: number;
  62664. /**
  62665. * Callback called when all tasks are processed
  62666. */
  62667. onFinish: (tasks: AbstractAssetTask[]) => void;
  62668. /**
  62669. * Callback called when a task is successful
  62670. */
  62671. onTaskSuccess: (task: AbstractAssetTask) => void;
  62672. /**
  62673. * Callback called when a task had an error
  62674. */
  62675. onTaskError: (task: AbstractAssetTask) => void;
  62676. /**
  62677. * Callback called when a task is done (whatever the result is)
  62678. */
  62679. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62680. /**
  62681. * Observable called when all tasks are processed
  62682. */
  62683. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62684. /**
  62685. * Observable called when a task had an error
  62686. */
  62687. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62688. /**
  62689. * Observable called when all tasks were executed
  62690. */
  62691. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62692. /**
  62693. * Observable called when a task is done (whatever the result is)
  62694. */
  62695. onProgressObservable: Observable<IAssetsProgressEvent>;
  62696. /**
  62697. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62699. */
  62700. useDefaultLoadingScreen: boolean;
  62701. /**
  62702. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62703. * when all assets have been downloaded.
  62704. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62705. */
  62706. autoHideLoadingUI: boolean;
  62707. /**
  62708. * Creates a new AssetsManager
  62709. * @param scene defines the scene to work on
  62710. */
  62711. constructor(scene: Scene);
  62712. /**
  62713. * Add a MeshAssetTask to the list of active tasks
  62714. * @param taskName defines the name of the new task
  62715. * @param meshesNames defines the name of meshes to load
  62716. * @param rootUrl defines the root url to use to locate files
  62717. * @param sceneFilename defines the filename of the scene file
  62718. * @returns a new MeshAssetTask object
  62719. */
  62720. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62721. /**
  62722. * Add a TextFileAssetTask to the list of active tasks
  62723. * @param taskName defines the name of the new task
  62724. * @param url defines the url of the file to load
  62725. * @returns a new TextFileAssetTask object
  62726. */
  62727. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62728. /**
  62729. * Add a BinaryFileAssetTask to the list of active tasks
  62730. * @param taskName defines the name of the new task
  62731. * @param url defines the url of the file to load
  62732. * @returns a new BinaryFileAssetTask object
  62733. */
  62734. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62735. /**
  62736. * Add a ImageAssetTask to the list of active tasks
  62737. * @param taskName defines the name of the new task
  62738. * @param url defines the url of the file to load
  62739. * @returns a new ImageAssetTask object
  62740. */
  62741. addImageTask(taskName: string, url: string): ImageAssetTask;
  62742. /**
  62743. * Add a TextureAssetTask to the list of active tasks
  62744. * @param taskName defines the name of the new task
  62745. * @param url defines the url of the file to load
  62746. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62747. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62748. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62749. * @returns a new TextureAssetTask object
  62750. */
  62751. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62752. /**
  62753. * Add a CubeTextureAssetTask to the list of active tasks
  62754. * @param taskName defines the name of the new task
  62755. * @param url defines the url of the file to load
  62756. * @param extensions defines the extension to use to load the cube map (can be null)
  62757. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62758. * @param files defines the list of files to load (can be null)
  62759. * @returns a new CubeTextureAssetTask object
  62760. */
  62761. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62762. /**
  62763. *
  62764. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62765. * @param taskName defines the name of the new task
  62766. * @param url defines the url of the file to load
  62767. * @param size defines the size you want for the cubemap (can be null)
  62768. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62769. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62770. * @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)
  62771. * @param reserved Internal use only
  62772. * @returns a new HDRCubeTextureAssetTask object
  62773. */
  62774. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62775. /**
  62776. *
  62777. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62778. * @param taskName defines the name of the new task
  62779. * @param url defines the url of the file to load
  62780. * @param size defines the size you want for the cubemap (can be null)
  62781. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62782. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62783. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62784. * @returns a new EquiRectangularCubeTextureAssetTask object
  62785. */
  62786. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62787. /**
  62788. * Remove a task from the assets manager.
  62789. * @param task the task to remove
  62790. */
  62791. removeTask(task: AbstractAssetTask): void;
  62792. private _decreaseWaitingTasksCount;
  62793. private _runTask;
  62794. /**
  62795. * Reset the AssetsManager and remove all tasks
  62796. * @return the current instance of the AssetsManager
  62797. */
  62798. reset(): AssetsManager;
  62799. /**
  62800. * Start the loading process
  62801. * @return the current instance of the AssetsManager
  62802. */
  62803. load(): AssetsManager;
  62804. /**
  62805. * Start the loading process as an async operation
  62806. * @return a promise returning the list of failed tasks
  62807. */
  62808. loadAsync(): Promise<void>;
  62809. }
  62810. }
  62811. declare module "babylonjs/Misc/deferred" {
  62812. /**
  62813. * Wrapper class for promise with external resolve and reject.
  62814. */
  62815. export class Deferred<T> {
  62816. /**
  62817. * The promise associated with this deferred object.
  62818. */
  62819. readonly promise: Promise<T>;
  62820. private _resolve;
  62821. private _reject;
  62822. /**
  62823. * The resolve method of the promise associated with this deferred object.
  62824. */
  62825. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62826. /**
  62827. * The reject method of the promise associated with this deferred object.
  62828. */
  62829. readonly reject: (reason?: any) => void;
  62830. /**
  62831. * Constructor for this deferred object.
  62832. */
  62833. constructor();
  62834. }
  62835. }
  62836. declare module "babylonjs/Misc/meshExploder" {
  62837. import { Mesh } from "babylonjs/Meshes/mesh";
  62838. /**
  62839. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62840. */
  62841. export class MeshExploder {
  62842. private _centerMesh;
  62843. private _meshes;
  62844. private _meshesOrigins;
  62845. private _toCenterVectors;
  62846. private _scaledDirection;
  62847. private _newPosition;
  62848. private _centerPosition;
  62849. /**
  62850. * Explodes meshes from a center mesh.
  62851. * @param meshes The meshes to explode.
  62852. * @param centerMesh The mesh to be center of explosion.
  62853. */
  62854. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62855. private _setCenterMesh;
  62856. /**
  62857. * Get class name
  62858. * @returns "MeshExploder"
  62859. */
  62860. getClassName(): string;
  62861. /**
  62862. * "Exploded meshes"
  62863. * @returns Array of meshes with the centerMesh at index 0.
  62864. */
  62865. getMeshes(): Array<Mesh>;
  62866. /**
  62867. * Explodes meshes giving a specific direction
  62868. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62869. */
  62870. explode(direction?: number): void;
  62871. }
  62872. }
  62873. declare module "babylonjs/Misc/filesInput" {
  62874. import { Engine } from "babylonjs/Engines/engine";
  62875. import { Scene } from "babylonjs/scene";
  62876. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  62877. /**
  62878. * Class used to help managing file picking and drag'n'drop
  62879. */
  62880. export class FilesInput {
  62881. /**
  62882. * List of files ready to be loaded
  62883. */
  62884. static readonly FilesToLoad: {
  62885. [key: string]: File;
  62886. };
  62887. /**
  62888. * Callback called when a file is processed
  62889. */
  62890. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62891. private _engine;
  62892. private _currentScene;
  62893. private _sceneLoadedCallback;
  62894. private _progressCallback;
  62895. private _additionalRenderLoopLogicCallback;
  62896. private _textureLoadingCallback;
  62897. private _startingProcessingFilesCallback;
  62898. private _onReloadCallback;
  62899. private _errorCallback;
  62900. private _elementToMonitor;
  62901. private _sceneFileToLoad;
  62902. private _filesToLoad;
  62903. /**
  62904. * Creates a new FilesInput
  62905. * @param engine defines the rendering engine
  62906. * @param scene defines the hosting scene
  62907. * @param sceneLoadedCallback callback called when scene is loaded
  62908. * @param progressCallback callback called to track progress
  62909. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62910. * @param textureLoadingCallback callback called when a texture is loading
  62911. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62912. * @param onReloadCallback callback called when a reload is requested
  62913. * @param errorCallback callback call if an error occurs
  62914. */
  62915. 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);
  62916. private _dragEnterHandler;
  62917. private _dragOverHandler;
  62918. private _dropHandler;
  62919. /**
  62920. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62921. * @param elementToMonitor defines the DOM element to track
  62922. */
  62923. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62924. /**
  62925. * Release all associated resources
  62926. */
  62927. dispose(): void;
  62928. private renderFunction;
  62929. private drag;
  62930. private drop;
  62931. private _traverseFolder;
  62932. private _processFiles;
  62933. /**
  62934. * Load files from a drop event
  62935. * @param event defines the drop event to use as source
  62936. */
  62937. loadFiles(event: any): void;
  62938. private _processReload;
  62939. /**
  62940. * Reload the current scene from the loaded files
  62941. */
  62942. reload(): void;
  62943. }
  62944. }
  62945. declare module "babylonjs/Misc/HighDynamicRange/index" {
  62946. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  62947. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  62948. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62949. }
  62950. declare module "babylonjs/Misc/sceneOptimizer" {
  62951. import { Scene, IDisposable } from "babylonjs/scene";
  62952. import { Observable } from "babylonjs/Misc/observable";
  62953. /**
  62954. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62956. */
  62957. export class SceneOptimization {
  62958. /**
  62959. * Defines the priority of this optimization (0 by default which means first in the list)
  62960. */
  62961. priority: number;
  62962. /**
  62963. * Gets a string describing the action executed by the current optimization
  62964. * @returns description string
  62965. */
  62966. getDescription(): string;
  62967. /**
  62968. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62969. * @param scene defines the current scene where to apply this optimization
  62970. * @param optimizer defines the current optimizer
  62971. * @returns true if everything that can be done was applied
  62972. */
  62973. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62974. /**
  62975. * Creates the SceneOptimization object
  62976. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62977. * @param desc defines the description associated with the optimization
  62978. */
  62979. constructor(
  62980. /**
  62981. * Defines the priority of this optimization (0 by default which means first in the list)
  62982. */
  62983. priority?: number);
  62984. }
  62985. /**
  62986. * Defines an optimization used to reduce the size of render target textures
  62987. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62988. */
  62989. export class TextureOptimization extends SceneOptimization {
  62990. /**
  62991. * Defines the priority of this optimization (0 by default which means first in the list)
  62992. */
  62993. priority: number;
  62994. /**
  62995. * 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
  62996. */
  62997. maximumSize: number;
  62998. /**
  62999. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63000. */
  63001. step: number;
  63002. /**
  63003. * Gets a string describing the action executed by the current optimization
  63004. * @returns description string
  63005. */
  63006. getDescription(): string;
  63007. /**
  63008. * Creates the TextureOptimization object
  63009. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63010. * @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
  63011. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63012. */
  63013. constructor(
  63014. /**
  63015. * Defines the priority of this optimization (0 by default which means first in the list)
  63016. */
  63017. priority?: number,
  63018. /**
  63019. * 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
  63020. */
  63021. maximumSize?: number,
  63022. /**
  63023. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63024. */
  63025. step?: number);
  63026. /**
  63027. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63028. * @param scene defines the current scene where to apply this optimization
  63029. * @param optimizer defines the current optimizer
  63030. * @returns true if everything that can be done was applied
  63031. */
  63032. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63033. }
  63034. /**
  63035. * Defines an optimization used to increase or decrease the rendering resolution
  63036. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63037. */
  63038. export class HardwareScalingOptimization extends SceneOptimization {
  63039. /**
  63040. * Defines the priority of this optimization (0 by default which means first in the list)
  63041. */
  63042. priority: number;
  63043. /**
  63044. * Defines the maximum scale to use (2 by default)
  63045. */
  63046. maximumScale: number;
  63047. /**
  63048. * Defines the step to use between two passes (0.5 by default)
  63049. */
  63050. step: number;
  63051. private _currentScale;
  63052. private _directionOffset;
  63053. /**
  63054. * Gets a string describing the action executed by the current optimization
  63055. * @return description string
  63056. */
  63057. getDescription(): string;
  63058. /**
  63059. * Creates the HardwareScalingOptimization object
  63060. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63061. * @param maximumScale defines the maximum scale to use (2 by default)
  63062. * @param step defines the step to use between two passes (0.5 by default)
  63063. */
  63064. constructor(
  63065. /**
  63066. * Defines the priority of this optimization (0 by default which means first in the list)
  63067. */
  63068. priority?: number,
  63069. /**
  63070. * Defines the maximum scale to use (2 by default)
  63071. */
  63072. maximumScale?: number,
  63073. /**
  63074. * Defines the step to use between two passes (0.5 by default)
  63075. */
  63076. step?: number);
  63077. /**
  63078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63079. * @param scene defines the current scene where to apply this optimization
  63080. * @param optimizer defines the current optimizer
  63081. * @returns true if everything that can be done was applied
  63082. */
  63083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63084. }
  63085. /**
  63086. * Defines an optimization used to remove shadows
  63087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63088. */
  63089. export class ShadowsOptimization extends SceneOptimization {
  63090. /**
  63091. * Gets a string describing the action executed by the current optimization
  63092. * @return description string
  63093. */
  63094. getDescription(): string;
  63095. /**
  63096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63097. * @param scene defines the current scene where to apply this optimization
  63098. * @param optimizer defines the current optimizer
  63099. * @returns true if everything that can be done was applied
  63100. */
  63101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63102. }
  63103. /**
  63104. * Defines an optimization used to turn post-processes off
  63105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63106. */
  63107. export class PostProcessesOptimization extends SceneOptimization {
  63108. /**
  63109. * Gets a string describing the action executed by the current optimization
  63110. * @return description string
  63111. */
  63112. getDescription(): string;
  63113. /**
  63114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63115. * @param scene defines the current scene where to apply this optimization
  63116. * @param optimizer defines the current optimizer
  63117. * @returns true if everything that can be done was applied
  63118. */
  63119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63120. }
  63121. /**
  63122. * Defines an optimization used to turn lens flares off
  63123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63124. */
  63125. export class LensFlaresOptimization extends SceneOptimization {
  63126. /**
  63127. * Gets a string describing the action executed by the current optimization
  63128. * @return description string
  63129. */
  63130. getDescription(): string;
  63131. /**
  63132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63133. * @param scene defines the current scene where to apply this optimization
  63134. * @param optimizer defines the current optimizer
  63135. * @returns true if everything that can be done was applied
  63136. */
  63137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63138. }
  63139. /**
  63140. * Defines an optimization based on user defined callback.
  63141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63142. */
  63143. export class CustomOptimization extends SceneOptimization {
  63144. /**
  63145. * Callback called to apply the custom optimization.
  63146. */
  63147. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63148. /**
  63149. * Callback called to get custom description
  63150. */
  63151. onGetDescription: () => string;
  63152. /**
  63153. * Gets a string describing the action executed by the current optimization
  63154. * @returns description string
  63155. */
  63156. getDescription(): string;
  63157. /**
  63158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63159. * @param scene defines the current scene where to apply this optimization
  63160. * @param optimizer defines the current optimizer
  63161. * @returns true if everything that can be done was applied
  63162. */
  63163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63164. }
  63165. /**
  63166. * Defines an optimization used to turn particles off
  63167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63168. */
  63169. export class ParticlesOptimization extends SceneOptimization {
  63170. /**
  63171. * Gets a string describing the action executed by the current optimization
  63172. * @return description string
  63173. */
  63174. getDescription(): string;
  63175. /**
  63176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63177. * @param scene defines the current scene where to apply this optimization
  63178. * @param optimizer defines the current optimizer
  63179. * @returns true if everything that can be done was applied
  63180. */
  63181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63182. }
  63183. /**
  63184. * Defines an optimization used to turn render targets off
  63185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63186. */
  63187. export class RenderTargetsOptimization extends SceneOptimization {
  63188. /**
  63189. * Gets a string describing the action executed by the current optimization
  63190. * @return description string
  63191. */
  63192. getDescription(): string;
  63193. /**
  63194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63195. * @param scene defines the current scene where to apply this optimization
  63196. * @param optimizer defines the current optimizer
  63197. * @returns true if everything that can be done was applied
  63198. */
  63199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63200. }
  63201. /**
  63202. * Defines an optimization used to merge meshes with compatible materials
  63203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63204. */
  63205. export class MergeMeshesOptimization extends SceneOptimization {
  63206. private static _UpdateSelectionTree;
  63207. /**
  63208. * Gets or sets a boolean which defines if optimization octree has to be updated
  63209. */
  63210. /**
  63211. * Gets or sets a boolean which defines if optimization octree has to be updated
  63212. */
  63213. static UpdateSelectionTree: boolean;
  63214. /**
  63215. * Gets a string describing the action executed by the current optimization
  63216. * @return description string
  63217. */
  63218. getDescription(): string;
  63219. private _canBeMerged;
  63220. /**
  63221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63222. * @param scene defines the current scene where to apply this optimization
  63223. * @param optimizer defines the current optimizer
  63224. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63225. * @returns true if everything that can be done was applied
  63226. */
  63227. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63228. }
  63229. /**
  63230. * Defines a list of options used by SceneOptimizer
  63231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63232. */
  63233. export class SceneOptimizerOptions {
  63234. /**
  63235. * Defines the target frame rate to reach (60 by default)
  63236. */
  63237. targetFrameRate: number;
  63238. /**
  63239. * Defines the interval between two checkes (2000ms by default)
  63240. */
  63241. trackerDuration: number;
  63242. /**
  63243. * Gets the list of optimizations to apply
  63244. */
  63245. optimizations: SceneOptimization[];
  63246. /**
  63247. * Creates a new list of options used by SceneOptimizer
  63248. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63249. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63250. */
  63251. constructor(
  63252. /**
  63253. * Defines the target frame rate to reach (60 by default)
  63254. */
  63255. targetFrameRate?: number,
  63256. /**
  63257. * Defines the interval between two checkes (2000ms by default)
  63258. */
  63259. trackerDuration?: number);
  63260. /**
  63261. * Add a new optimization
  63262. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63263. * @returns the current SceneOptimizerOptions
  63264. */
  63265. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63266. /**
  63267. * Add a new custom optimization
  63268. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63269. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63270. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63271. * @returns the current SceneOptimizerOptions
  63272. */
  63273. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63274. /**
  63275. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63276. * @param targetFrameRate defines the target frame rate (60 by default)
  63277. * @returns a SceneOptimizerOptions object
  63278. */
  63279. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63280. /**
  63281. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63282. * @param targetFrameRate defines the target frame rate (60 by default)
  63283. * @returns a SceneOptimizerOptions object
  63284. */
  63285. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63286. /**
  63287. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63288. * @param targetFrameRate defines the target frame rate (60 by default)
  63289. * @returns a SceneOptimizerOptions object
  63290. */
  63291. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63292. }
  63293. /**
  63294. * Class used to run optimizations in order to reach a target frame rate
  63295. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63296. */
  63297. export class SceneOptimizer implements IDisposable {
  63298. private _isRunning;
  63299. private _options;
  63300. private _scene;
  63301. private _currentPriorityLevel;
  63302. private _targetFrameRate;
  63303. private _trackerDuration;
  63304. private _currentFrameRate;
  63305. private _sceneDisposeObserver;
  63306. private _improvementMode;
  63307. /**
  63308. * Defines an observable called when the optimizer reaches the target frame rate
  63309. */
  63310. onSuccessObservable: Observable<SceneOptimizer>;
  63311. /**
  63312. * Defines an observable called when the optimizer enables an optimization
  63313. */
  63314. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63315. /**
  63316. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63317. */
  63318. onFailureObservable: Observable<SceneOptimizer>;
  63319. /**
  63320. * Gets a boolean indicating if the optimizer is in improvement mode
  63321. */
  63322. readonly isInImprovementMode: boolean;
  63323. /**
  63324. * Gets the current priority level (0 at start)
  63325. */
  63326. readonly currentPriorityLevel: number;
  63327. /**
  63328. * Gets the current frame rate checked by the SceneOptimizer
  63329. */
  63330. readonly currentFrameRate: number;
  63331. /**
  63332. * Gets or sets the current target frame rate (60 by default)
  63333. */
  63334. /**
  63335. * Gets or sets the current target frame rate (60 by default)
  63336. */
  63337. targetFrameRate: number;
  63338. /**
  63339. * Gets or sets the current interval between two checks (every 2000ms by default)
  63340. */
  63341. /**
  63342. * Gets or sets the current interval between two checks (every 2000ms by default)
  63343. */
  63344. trackerDuration: number;
  63345. /**
  63346. * Gets the list of active optimizations
  63347. */
  63348. readonly optimizations: SceneOptimization[];
  63349. /**
  63350. * Creates a new SceneOptimizer
  63351. * @param scene defines the scene to work on
  63352. * @param options defines the options to use with the SceneOptimizer
  63353. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63354. * @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)
  63355. */
  63356. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63357. /**
  63358. * Stops the current optimizer
  63359. */
  63360. stop(): void;
  63361. /**
  63362. * Reset the optimizer to initial step (current priority level = 0)
  63363. */
  63364. reset(): void;
  63365. /**
  63366. * Start the optimizer. By default it will try to reach a specific framerate
  63367. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63368. */
  63369. start(): void;
  63370. private _checkCurrentState;
  63371. /**
  63372. * Release all resources
  63373. */
  63374. dispose(): void;
  63375. /**
  63376. * Helper function to create a SceneOptimizer with one single line of code
  63377. * @param scene defines the scene to work on
  63378. * @param options defines the options to use with the SceneOptimizer
  63379. * @param onSuccess defines a callback to call on success
  63380. * @param onFailure defines a callback to call on failure
  63381. * @returns the new SceneOptimizer object
  63382. */
  63383. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63384. }
  63385. }
  63386. declare module "babylonjs/Misc/sceneSerializer" {
  63387. import { Scene } from "babylonjs/scene";
  63388. /**
  63389. * Class used to serialize a scene into a string
  63390. */
  63391. export class SceneSerializer {
  63392. /**
  63393. * Clear cache used by a previous serialization
  63394. */
  63395. static ClearCache(): void;
  63396. /**
  63397. * Serialize a scene into a JSON compatible object
  63398. * @param scene defines the scene to serialize
  63399. * @returns a JSON compatible object
  63400. */
  63401. static Serialize(scene: Scene): any;
  63402. /**
  63403. * Serialize a mesh into a JSON compatible object
  63404. * @param toSerialize defines the mesh to serialize
  63405. * @param withParents defines if parents must be serialized as well
  63406. * @param withChildren defines if children must be serialized as well
  63407. * @returns a JSON compatible object
  63408. */
  63409. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63410. }
  63411. }
  63412. declare module "babylonjs/Misc/textureTools" {
  63413. import { Texture } from "babylonjs/Materials/Textures/texture";
  63414. /**
  63415. * Class used to host texture specific utilities
  63416. */
  63417. export class TextureTools {
  63418. /**
  63419. * Uses the GPU to create a copy texture rescaled at a given size
  63420. * @param texture Texture to copy from
  63421. * @param width defines the desired width
  63422. * @param height defines the desired height
  63423. * @param useBilinearMode defines if bilinear mode has to be used
  63424. * @return the generated texture
  63425. */
  63426. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63427. }
  63428. }
  63429. declare module "babylonjs/Misc/videoRecorder" {
  63430. import { Nullable } from "babylonjs/types";
  63431. import { Engine } from "babylonjs/Engines/engine";
  63432. /**
  63433. * This represents the different options available for the video capture.
  63434. */
  63435. export interface VideoRecorderOptions {
  63436. /** Defines the mime type of the video. */
  63437. mimeType: string;
  63438. /** Defines the FPS the video should be recorded at. */
  63439. fps: number;
  63440. /** Defines the chunk size for the recording data. */
  63441. recordChunckSize: number;
  63442. /** The audio tracks to attach to the recording. */
  63443. audioTracks?: MediaStreamTrack[];
  63444. }
  63445. /**
  63446. * This can help with recording videos from BabylonJS.
  63447. * This is based on the available WebRTC functionalities of the browser.
  63448. *
  63449. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63450. */
  63451. export class VideoRecorder {
  63452. private static readonly _defaultOptions;
  63453. /**
  63454. * Returns whether or not the VideoRecorder is available in your browser.
  63455. * @param engine Defines the Babylon Engine.
  63456. * @returns true if supported otherwise false.
  63457. */
  63458. static IsSupported(engine: Engine): boolean;
  63459. private readonly _options;
  63460. private _canvas;
  63461. private _mediaRecorder;
  63462. private _recordedChunks;
  63463. private _fileName;
  63464. private _resolve;
  63465. private _reject;
  63466. /**
  63467. * True when a recording is already in progress.
  63468. */
  63469. readonly isRecording: boolean;
  63470. /**
  63471. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63472. * @param engine Defines the BabylonJS Engine you wish to record.
  63473. * @param options Defines options that can be used to customize the capture.
  63474. */
  63475. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63476. /**
  63477. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63478. */
  63479. stopRecording(): void;
  63480. /**
  63481. * Starts recording the canvas for a max duration specified in parameters.
  63482. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63483. * If null no automatic download will start and you can rely on the promise to get the data back.
  63484. * @param maxDuration Defines the maximum recording time in seconds.
  63485. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63486. * @return A promise callback at the end of the recording with the video data in Blob.
  63487. */
  63488. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63489. /**
  63490. * Releases internal resources used during the recording.
  63491. */
  63492. dispose(): void;
  63493. private _handleDataAvailable;
  63494. private _handleError;
  63495. private _handleStop;
  63496. }
  63497. }
  63498. declare module "babylonjs/Misc/screenshotTools" {
  63499. import { Camera } from "babylonjs/Cameras/camera";
  63500. import { Engine } from "babylonjs/Engines/engine";
  63501. /**
  63502. * Class containing a set of static utilities functions for screenshots
  63503. */
  63504. export class ScreenshotTools {
  63505. /**
  63506. * Captures a screenshot of the current rendering
  63507. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63508. * @param engine defines the rendering engine
  63509. * @param camera defines the source camera
  63510. * @param size This parameter can be set to a single number or to an object with the
  63511. * following (optional) properties: precision, width, height. If a single number is passed,
  63512. * it will be used for both width and height. If an object is passed, the screenshot size
  63513. * will be derived from the parameters. The precision property is a multiplier allowing
  63514. * rendering at a higher or lower resolution
  63515. * @param successCallback defines the callback receives a single parameter which contains the
  63516. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63517. * src parameter of an <img> to display it
  63518. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63519. * Check your browser for supported MIME types
  63520. */
  63521. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  63522. /**
  63523. * Captures a screenshot of the current rendering
  63524. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63525. * @param engine defines the rendering engine
  63526. * @param camera defines the source camera
  63527. * @param size This parameter can be set to a single number or to an object with the
  63528. * following (optional) properties: precision, width, height. If a single number is passed,
  63529. * it will be used for both width and height. If an object is passed, the screenshot size
  63530. * will be derived from the parameters. The precision property is a multiplier allowing
  63531. * rendering at a higher or lower resolution
  63532. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63533. * Check your browser for supported MIME types
  63534. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63535. * to the src parameter of an <img> to display it
  63536. */
  63537. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63538. /**
  63539. * Generates an image screenshot from the specified camera.
  63540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63541. * @param engine The engine to use for rendering
  63542. * @param camera The camera to use for rendering
  63543. * @param size This parameter can be set to a single number or to an object with the
  63544. * following (optional) properties: precision, width, height. If a single number is passed,
  63545. * it will be used for both width and height. If an object is passed, the screenshot size
  63546. * will be derived from the parameters. The precision property is a multiplier allowing
  63547. * rendering at a higher or lower resolution
  63548. * @param successCallback The callback receives a single parameter which contains the
  63549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63550. * src parameter of an <img> to display it
  63551. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63552. * Check your browser for supported MIME types
  63553. * @param samples Texture samples (default: 1)
  63554. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63555. * @param fileName A name for for the downloaded file.
  63556. */
  63557. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63558. /**
  63559. * Generates an image screenshot from the specified camera.
  63560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63561. * @param engine The engine to use for rendering
  63562. * @param camera The camera to use for rendering
  63563. * @param size This parameter can be set to a single number or to an object with the
  63564. * following (optional) properties: precision, width, height. If a single number is passed,
  63565. * it will be used for both width and height. If an object is passed, the screenshot size
  63566. * will be derived from the parameters. The precision property is a multiplier allowing
  63567. * rendering at a higher or lower resolution
  63568. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63569. * Check your browser for supported MIME types
  63570. * @param samples Texture samples (default: 1)
  63571. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63572. * @param fileName A name for for the downloaded file.
  63573. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63574. * to the src parameter of an <img> to display it
  63575. */
  63576. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63577. }
  63578. }
  63579. declare module "babylonjs/Misc/index" {
  63580. export * from "babylonjs/Misc/andOrNotEvaluator";
  63581. export * from "babylonjs/Misc/assetsManager";
  63582. export * from "babylonjs/Misc/dds";
  63583. export * from "babylonjs/Misc/decorators";
  63584. export * from "babylonjs/Misc/deferred";
  63585. export * from "babylonjs/Misc/environmentTextureTools";
  63586. export * from "babylonjs/Misc/meshExploder";
  63587. export * from "babylonjs/Misc/filesInput";
  63588. export * from "babylonjs/Misc/HighDynamicRange/index";
  63589. export * from "babylonjs/Misc/khronosTextureContainer";
  63590. export * from "babylonjs/Misc/observable";
  63591. export * from "babylonjs/Misc/performanceMonitor";
  63592. export * from "babylonjs/Misc/promise";
  63593. export * from "babylonjs/Misc/sceneOptimizer";
  63594. export * from "babylonjs/Misc/sceneSerializer";
  63595. export * from "babylonjs/Misc/smartArray";
  63596. export * from "babylonjs/Misc/stringDictionary";
  63597. export * from "babylonjs/Misc/tags";
  63598. export * from "babylonjs/Misc/textureTools";
  63599. export * from "babylonjs/Misc/tga";
  63600. export * from "babylonjs/Misc/tools";
  63601. export * from "babylonjs/Misc/videoRecorder";
  63602. export * from "babylonjs/Misc/virtualJoystick";
  63603. export * from "babylonjs/Misc/workerPool";
  63604. export * from "babylonjs/Misc/logger";
  63605. export * from "babylonjs/Misc/typeStore";
  63606. export * from "babylonjs/Misc/filesInputStore";
  63607. export * from "babylonjs/Misc/deepCopier";
  63608. export * from "babylonjs/Misc/pivotTools";
  63609. export * from "babylonjs/Misc/precisionDate";
  63610. export * from "babylonjs/Misc/screenshotTools";
  63611. export * from "babylonjs/Misc/typeStore";
  63612. export * from "babylonjs/Misc/webRequest";
  63613. export * from "babylonjs/Misc/iInspectable";
  63614. export * from "babylonjs/Misc/brdfTextureTools";
  63615. export * from "babylonjs/Misc/gradients";
  63616. export * from "babylonjs/Misc/perfCounter";
  63617. export * from "babylonjs/Misc/fileRequest";
  63618. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63619. export * from "babylonjs/Misc/retryStrategy";
  63620. export * from "babylonjs/Misc/loadFileError";
  63621. }
  63622. declare module "babylonjs/index" {
  63623. export * from "babylonjs/abstractScene";
  63624. export * from "babylonjs/Actions/index";
  63625. export * from "babylonjs/Animations/index";
  63626. export * from "babylonjs/assetContainer";
  63627. export * from "babylonjs/Audio/index";
  63628. export * from "babylonjs/Behaviors/index";
  63629. export * from "babylonjs/Bones/index";
  63630. export * from "babylonjs/Cameras/index";
  63631. export * from "babylonjs/Collisions/index";
  63632. export * from "babylonjs/Culling/index";
  63633. export * from "babylonjs/Debug/index";
  63634. export * from "babylonjs/Engines/index";
  63635. export * from "babylonjs/Events/index";
  63636. export * from "babylonjs/Gamepads/index";
  63637. export * from "babylonjs/Gizmos/index";
  63638. export * from "babylonjs/Helpers/index";
  63639. export * from "babylonjs/Instrumentation/index";
  63640. export * from "babylonjs/Layers/index";
  63641. export * from "babylonjs/LensFlares/index";
  63642. export * from "babylonjs/Lights/index";
  63643. export * from "babylonjs/Loading/index";
  63644. export * from "babylonjs/Materials/index";
  63645. export * from "babylonjs/Maths/index";
  63646. export * from "babylonjs/Meshes/index";
  63647. export * from "babylonjs/Morph/index";
  63648. export * from "babylonjs/Navigation/index";
  63649. export * from "babylonjs/node";
  63650. export * from "babylonjs/Offline/index";
  63651. export * from "babylonjs/Particles/index";
  63652. export * from "babylonjs/Physics/index";
  63653. export * from "babylonjs/PostProcesses/index";
  63654. export * from "babylonjs/Probes/index";
  63655. export * from "babylonjs/Rendering/index";
  63656. export * from "babylonjs/scene";
  63657. export * from "babylonjs/sceneComponent";
  63658. export * from "babylonjs/Sprites/index";
  63659. export * from "babylonjs/States/index";
  63660. export * from "babylonjs/Misc/index";
  63661. export * from "babylonjs/types";
  63662. }
  63663. declare module "babylonjs/Animations/pathCursor" {
  63664. import { Vector3 } from "babylonjs/Maths/math.vector";
  63665. import { Path2 } from "babylonjs/Maths/math.path";
  63666. /**
  63667. * A cursor which tracks a point on a path
  63668. */
  63669. export class PathCursor {
  63670. private path;
  63671. /**
  63672. * Stores path cursor callbacks for when an onchange event is triggered
  63673. */
  63674. private _onchange;
  63675. /**
  63676. * The value of the path cursor
  63677. */
  63678. value: number;
  63679. /**
  63680. * The animation array of the path cursor
  63681. */
  63682. animations: Animation[];
  63683. /**
  63684. * Initializes the path cursor
  63685. * @param path The path to track
  63686. */
  63687. constructor(path: Path2);
  63688. /**
  63689. * Gets the cursor point on the path
  63690. * @returns A point on the path cursor at the cursor location
  63691. */
  63692. getPoint(): Vector3;
  63693. /**
  63694. * Moves the cursor ahead by the step amount
  63695. * @param step The amount to move the cursor forward
  63696. * @returns This path cursor
  63697. */
  63698. moveAhead(step?: number): PathCursor;
  63699. /**
  63700. * Moves the cursor behind by the step amount
  63701. * @param step The amount to move the cursor back
  63702. * @returns This path cursor
  63703. */
  63704. moveBack(step?: number): PathCursor;
  63705. /**
  63706. * Moves the cursor by the step amount
  63707. * If the step amount is greater than one, an exception is thrown
  63708. * @param step The amount to move the cursor
  63709. * @returns This path cursor
  63710. */
  63711. move(step: number): PathCursor;
  63712. /**
  63713. * Ensures that the value is limited between zero and one
  63714. * @returns This path cursor
  63715. */
  63716. private ensureLimits;
  63717. /**
  63718. * Runs onchange callbacks on change (used by the animation engine)
  63719. * @returns This path cursor
  63720. */
  63721. private raiseOnChange;
  63722. /**
  63723. * Executes a function on change
  63724. * @param f A path cursor onchange callback
  63725. * @returns This path cursor
  63726. */
  63727. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63728. }
  63729. }
  63730. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63731. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63732. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63733. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63734. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63735. }
  63736. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63737. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63738. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63739. }
  63740. declare module "babylonjs/Engines/Processors/index" {
  63741. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63742. export * from "babylonjs/Engines/Processors/Expressions/index";
  63743. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63744. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63745. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63746. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63747. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63748. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63749. }
  63750. declare module "babylonjs/Legacy/legacy" {
  63751. import * as Babylon from "babylonjs/index";
  63752. export * from "babylonjs/index";
  63753. }
  63754. declare module "babylonjs/Shaders/blur.fragment" {
  63755. /** @hidden */
  63756. export var blurPixelShader: {
  63757. name: string;
  63758. shader: string;
  63759. };
  63760. }
  63761. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63762. /** @hidden */
  63763. export var pointCloudVertexDeclaration: {
  63764. name: string;
  63765. shader: string;
  63766. };
  63767. }
  63768. declare module "babylonjs" {
  63769. export * from "babylonjs/Legacy/legacy";
  63770. }
  63771. declare module BABYLON {
  63772. /** Alias type for value that can be null */
  63773. export type Nullable<T> = T | null;
  63774. /**
  63775. * Alias type for number that are floats
  63776. * @ignorenaming
  63777. */
  63778. export type float = number;
  63779. /**
  63780. * Alias type for number that are doubles.
  63781. * @ignorenaming
  63782. */
  63783. export type double = number;
  63784. /**
  63785. * Alias type for number that are integer
  63786. * @ignorenaming
  63787. */
  63788. export type int = number;
  63789. /** Alias type for number array or Float32Array */
  63790. export type FloatArray = number[] | Float32Array;
  63791. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63792. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63793. /**
  63794. * Alias for types that can be used by a Buffer or VertexBuffer.
  63795. */
  63796. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63797. /**
  63798. * Alias type for primitive types
  63799. * @ignorenaming
  63800. */
  63801. type Primitive = undefined | null | boolean | string | number | Function;
  63802. /**
  63803. * Type modifier to make all the properties of an object Readonly
  63804. */
  63805. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63806. /**
  63807. * Type modifier to make all the properties of an object Readonly recursively
  63808. */
  63809. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63810. /** @hidden */
  63811. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63812. }
  63813. /** @hidden */
  63814. /** @hidden */
  63815. type DeepImmutableObject<T> = {
  63816. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63817. };
  63818. }
  63819. declare module BABYLON {
  63820. /**
  63821. * A class serves as a medium between the observable and its observers
  63822. */
  63823. export class EventState {
  63824. /**
  63825. * Create a new EventState
  63826. * @param mask defines the mask associated with this state
  63827. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63828. * @param target defines the original target of the state
  63829. * @param currentTarget defines the current target of the state
  63830. */
  63831. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63832. /**
  63833. * Initialize the current event state
  63834. * @param mask defines the mask associated with this state
  63835. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63836. * @param target defines the original target of the state
  63837. * @param currentTarget defines the current target of the state
  63838. * @returns the current event state
  63839. */
  63840. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63841. /**
  63842. * An Observer can set this property to true to prevent subsequent observers of being notified
  63843. */
  63844. skipNextObservers: boolean;
  63845. /**
  63846. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63847. */
  63848. mask: number;
  63849. /**
  63850. * The object that originally notified the event
  63851. */
  63852. target?: any;
  63853. /**
  63854. * The current object in the bubbling phase
  63855. */
  63856. currentTarget?: any;
  63857. /**
  63858. * This will be populated with the return value of the last function that was executed.
  63859. * If it is the first function in the callback chain it will be the event data.
  63860. */
  63861. lastReturnValue?: any;
  63862. }
  63863. /**
  63864. * Represent an Observer registered to a given Observable object.
  63865. */
  63866. export class Observer<T> {
  63867. /**
  63868. * Defines the callback to call when the observer is notified
  63869. */
  63870. callback: (eventData: T, eventState: EventState) => void;
  63871. /**
  63872. * Defines the mask of the observer (used to filter notifications)
  63873. */
  63874. mask: number;
  63875. /**
  63876. * Defines the current scope used to restore the JS context
  63877. */
  63878. scope: any;
  63879. /** @hidden */
  63880. _willBeUnregistered: boolean;
  63881. /**
  63882. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63883. */
  63884. unregisterOnNextCall: boolean;
  63885. /**
  63886. * Creates a new observer
  63887. * @param callback defines the callback to call when the observer is notified
  63888. * @param mask defines the mask of the observer (used to filter notifications)
  63889. * @param scope defines the current scope used to restore the JS context
  63890. */
  63891. constructor(
  63892. /**
  63893. * Defines the callback to call when the observer is notified
  63894. */
  63895. callback: (eventData: T, eventState: EventState) => void,
  63896. /**
  63897. * Defines the mask of the observer (used to filter notifications)
  63898. */
  63899. mask: number,
  63900. /**
  63901. * Defines the current scope used to restore the JS context
  63902. */
  63903. scope?: any);
  63904. }
  63905. /**
  63906. * Represent a list of observers registered to multiple Observables object.
  63907. */
  63908. export class MultiObserver<T> {
  63909. private _observers;
  63910. private _observables;
  63911. /**
  63912. * Release associated resources
  63913. */
  63914. dispose(): void;
  63915. /**
  63916. * Raise a callback when one of the observable will notify
  63917. * @param observables defines a list of observables to watch
  63918. * @param callback defines the callback to call on notification
  63919. * @param mask defines the mask used to filter notifications
  63920. * @param scope defines the current scope used to restore the JS context
  63921. * @returns the new MultiObserver
  63922. */
  63923. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63924. }
  63925. /**
  63926. * The Observable class is a simple implementation of the Observable pattern.
  63927. *
  63928. * 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.
  63929. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63930. * 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).
  63931. * 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.
  63932. */
  63933. export class Observable<T> {
  63934. private _observers;
  63935. private _eventState;
  63936. private _onObserverAdded;
  63937. /**
  63938. * Gets the list of observers
  63939. */
  63940. readonly observers: Array<Observer<T>>;
  63941. /**
  63942. * Creates a new observable
  63943. * @param onObserverAdded defines a callback to call when a new observer is added
  63944. */
  63945. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63946. /**
  63947. * Create a new Observer with the specified callback
  63948. * @param callback the callback that will be executed for that Observer
  63949. * @param mask the mask used to filter observers
  63950. * @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.
  63951. * @param scope optional scope for the callback to be called from
  63952. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63953. * @returns the new observer created for the callback
  63954. */
  63955. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63956. /**
  63957. * Create a new Observer with the specified callback and unregisters after the next notification
  63958. * @param callback the callback that will be executed for that Observer
  63959. * @returns the new observer created for the callback
  63960. */
  63961. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63962. /**
  63963. * Remove an Observer from the Observable object
  63964. * @param observer the instance of the Observer to remove
  63965. * @returns false if it doesn't belong to this Observable
  63966. */
  63967. remove(observer: Nullable<Observer<T>>): boolean;
  63968. /**
  63969. * Remove a callback from the Observable object
  63970. * @param callback the callback to remove
  63971. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63972. * @returns false if it doesn't belong to this Observable
  63973. */
  63974. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63975. private _deferUnregister;
  63976. private _remove;
  63977. /**
  63978. * Moves the observable to the top of the observer list making it get called first when notified
  63979. * @param observer the observer to move
  63980. */
  63981. makeObserverTopPriority(observer: Observer<T>): void;
  63982. /**
  63983. * Moves the observable to the bottom of the observer list making it get called last when notified
  63984. * @param observer the observer to move
  63985. */
  63986. makeObserverBottomPriority(observer: Observer<T>): void;
  63987. /**
  63988. * Notify all Observers by calling their respective callback with the given data
  63989. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63990. * @param eventData defines the data to send to all observers
  63991. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63992. * @param target defines the original target of the state
  63993. * @param currentTarget defines the current target of the state
  63994. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63995. */
  63996. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63997. /**
  63998. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63999. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  64000. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  64001. * and it is crucial that all callbacks will be executed.
  64002. * The order of the callbacks is kept, callbacks are not executed parallel.
  64003. *
  64004. * @param eventData The data to be sent to each callback
  64005. * @param mask is used to filter observers defaults to -1
  64006. * @param target defines the callback target (see EventState)
  64007. * @param currentTarget defines he current object in the bubbling phase
  64008. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  64009. */
  64010. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  64011. /**
  64012. * Notify a specific observer
  64013. * @param observer defines the observer to notify
  64014. * @param eventData defines the data to be sent to each callback
  64015. * @param mask is used to filter observers defaults to -1
  64016. */
  64017. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64018. /**
  64019. * Gets a boolean indicating if the observable has at least one observer
  64020. * @returns true is the Observable has at least one Observer registered
  64021. */
  64022. hasObservers(): boolean;
  64023. /**
  64024. * Clear the list of observers
  64025. */
  64026. clear(): void;
  64027. /**
  64028. * Clone the current observable
  64029. * @returns a new observable
  64030. */
  64031. clone(): Observable<T>;
  64032. /**
  64033. * Does this observable handles observer registered with a given mask
  64034. * @param mask defines the mask to be tested
  64035. * @return whether or not one observer registered with the given mask is handeled
  64036. **/
  64037. hasSpecificMask(mask?: number): boolean;
  64038. }
  64039. }
  64040. declare module BABYLON {
  64041. /**
  64042. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64043. * Babylon.js
  64044. */
  64045. export class DomManagement {
  64046. /**
  64047. * Checks if the window object exists
  64048. * @returns true if the window object exists
  64049. */
  64050. static IsWindowObjectExist(): boolean;
  64051. /**
  64052. * Extracts text content from a DOM element hierarchy
  64053. * @param element defines the root element
  64054. * @returns a string
  64055. */
  64056. static GetDOMTextContent(element: HTMLElement): string;
  64057. }
  64058. }
  64059. declare module BABYLON {
  64060. /**
  64061. * Logger used througouht the application to allow configuration of
  64062. * the log level required for the messages.
  64063. */
  64064. export class Logger {
  64065. /**
  64066. * No log
  64067. */
  64068. static readonly NoneLogLevel: number;
  64069. /**
  64070. * Only message logs
  64071. */
  64072. static readonly MessageLogLevel: number;
  64073. /**
  64074. * Only warning logs
  64075. */
  64076. static readonly WarningLogLevel: number;
  64077. /**
  64078. * Only error logs
  64079. */
  64080. static readonly ErrorLogLevel: number;
  64081. /**
  64082. * All logs
  64083. */
  64084. static readonly AllLogLevel: number;
  64085. private static _LogCache;
  64086. /**
  64087. * Gets a value indicating the number of loading errors
  64088. * @ignorenaming
  64089. */
  64090. static errorsCount: number;
  64091. /**
  64092. * Callback called when a new log is added
  64093. */
  64094. static OnNewCacheEntry: (entry: string) => void;
  64095. private static _AddLogEntry;
  64096. private static _FormatMessage;
  64097. private static _LogDisabled;
  64098. private static _LogEnabled;
  64099. private static _WarnDisabled;
  64100. private static _WarnEnabled;
  64101. private static _ErrorDisabled;
  64102. private static _ErrorEnabled;
  64103. /**
  64104. * Log a message to the console
  64105. */
  64106. static Log: (message: string) => void;
  64107. /**
  64108. * Write a warning message to the console
  64109. */
  64110. static Warn: (message: string) => void;
  64111. /**
  64112. * Write an error message to the console
  64113. */
  64114. static Error: (message: string) => void;
  64115. /**
  64116. * Gets current log cache (list of logs)
  64117. */
  64118. static readonly LogCache: string;
  64119. /**
  64120. * Clears the log cache
  64121. */
  64122. static ClearLogCache(): void;
  64123. /**
  64124. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64125. */
  64126. static LogLevels: number;
  64127. }
  64128. }
  64129. declare module BABYLON {
  64130. /** @hidden */
  64131. export class _TypeStore {
  64132. /** @hidden */
  64133. static RegisteredTypes: {
  64134. [key: string]: Object;
  64135. };
  64136. /** @hidden */
  64137. static GetClass(fqdn: string): any;
  64138. }
  64139. }
  64140. declare module BABYLON {
  64141. /**
  64142. * Class containing a set of static utilities functions for deep copy.
  64143. */
  64144. export class DeepCopier {
  64145. /**
  64146. * Tries to copy an object by duplicating every property
  64147. * @param source defines the source object
  64148. * @param destination defines the target object
  64149. * @param doNotCopyList defines a list of properties to avoid
  64150. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64151. */
  64152. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64153. }
  64154. }
  64155. declare module BABYLON {
  64156. /**
  64157. * Class containing a set of static utilities functions for precision date
  64158. */
  64159. export class PrecisionDate {
  64160. /**
  64161. * Gets either window.performance.now() if supported or Date.now() else
  64162. */
  64163. static readonly Now: number;
  64164. }
  64165. }
  64166. declare module BABYLON {
  64167. /** @hidden */
  64168. export class _DevTools {
  64169. static WarnImport(name: string): string;
  64170. }
  64171. }
  64172. declare module BABYLON {
  64173. /**
  64174. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64175. */
  64176. export class WebRequest {
  64177. private _xhr;
  64178. /**
  64179. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64180. * i.e. when loading files, where the server/service expects an Authorization header
  64181. */
  64182. static CustomRequestHeaders: {
  64183. [key: string]: string;
  64184. };
  64185. /**
  64186. * Add callback functions in this array to update all the requests before they get sent to the network
  64187. */
  64188. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64189. private _injectCustomRequestHeaders;
  64190. /**
  64191. * Gets or sets a function to be called when loading progress changes
  64192. */
  64193. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64194. /**
  64195. * Returns client's state
  64196. */
  64197. readonly readyState: number;
  64198. /**
  64199. * Returns client's status
  64200. */
  64201. readonly status: number;
  64202. /**
  64203. * Returns client's status as a text
  64204. */
  64205. readonly statusText: string;
  64206. /**
  64207. * Returns client's response
  64208. */
  64209. readonly response: any;
  64210. /**
  64211. * Returns client's response url
  64212. */
  64213. readonly responseURL: string;
  64214. /**
  64215. * Returns client's response as text
  64216. */
  64217. readonly responseText: string;
  64218. /**
  64219. * Gets or sets the expected response type
  64220. */
  64221. responseType: XMLHttpRequestResponseType;
  64222. /** @hidden */
  64223. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64224. /** @hidden */
  64225. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64226. /**
  64227. * Cancels any network activity
  64228. */
  64229. abort(): void;
  64230. /**
  64231. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64232. * @param body defines an optional request body
  64233. */
  64234. send(body?: Document | BodyInit | null): void;
  64235. /**
  64236. * Sets the request method, request URL
  64237. * @param method defines the method to use (GET, POST, etc..)
  64238. * @param url defines the url to connect with
  64239. */
  64240. open(method: string, url: string): void;
  64241. }
  64242. }
  64243. declare module BABYLON {
  64244. /**
  64245. * File request interface
  64246. */
  64247. export interface IFileRequest {
  64248. /**
  64249. * Raised when the request is complete (success or error).
  64250. */
  64251. onCompleteObservable: Observable<IFileRequest>;
  64252. /**
  64253. * Aborts the request for a file.
  64254. */
  64255. abort: () => void;
  64256. }
  64257. }
  64258. declare module BABYLON {
  64259. /**
  64260. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64261. */
  64262. export class PerformanceMonitor {
  64263. private _enabled;
  64264. private _rollingFrameTime;
  64265. private _lastFrameTimeMs;
  64266. /**
  64267. * constructor
  64268. * @param frameSampleSize The number of samples required to saturate the sliding window
  64269. */
  64270. constructor(frameSampleSize?: number);
  64271. /**
  64272. * Samples current frame
  64273. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64274. */
  64275. sampleFrame(timeMs?: number): void;
  64276. /**
  64277. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64278. */
  64279. readonly averageFrameTime: number;
  64280. /**
  64281. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64282. */
  64283. readonly averageFrameTimeVariance: number;
  64284. /**
  64285. * Returns the frame time of the most recent frame
  64286. */
  64287. readonly instantaneousFrameTime: number;
  64288. /**
  64289. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64290. */
  64291. readonly averageFPS: number;
  64292. /**
  64293. * Returns the average framerate in frames per second using the most recent frame time
  64294. */
  64295. readonly instantaneousFPS: number;
  64296. /**
  64297. * Returns true if enough samples have been taken to completely fill the sliding window
  64298. */
  64299. readonly isSaturated: boolean;
  64300. /**
  64301. * Enables contributions to the sliding window sample set
  64302. */
  64303. enable(): void;
  64304. /**
  64305. * Disables contributions to the sliding window sample set
  64306. * Samples will not be interpolated over the disabled period
  64307. */
  64308. disable(): void;
  64309. /**
  64310. * Returns true if sampling is enabled
  64311. */
  64312. readonly isEnabled: boolean;
  64313. /**
  64314. * Resets performance monitor
  64315. */
  64316. reset(): void;
  64317. }
  64318. /**
  64319. * RollingAverage
  64320. *
  64321. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64322. */
  64323. export class RollingAverage {
  64324. /**
  64325. * Current average
  64326. */
  64327. average: number;
  64328. /**
  64329. * Current variance
  64330. */
  64331. variance: number;
  64332. protected _samples: Array<number>;
  64333. protected _sampleCount: number;
  64334. protected _pos: number;
  64335. protected _m2: number;
  64336. /**
  64337. * constructor
  64338. * @param length The number of samples required to saturate the sliding window
  64339. */
  64340. constructor(length: number);
  64341. /**
  64342. * Adds a sample to the sample set
  64343. * @param v The sample value
  64344. */
  64345. add(v: number): void;
  64346. /**
  64347. * Returns previously added values or null if outside of history or outside the sliding window domain
  64348. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64349. * @return Value previously recorded with add() or null if outside of range
  64350. */
  64351. history(i: number): number;
  64352. /**
  64353. * Returns true if enough samples have been taken to completely fill the sliding window
  64354. * @return true if sample-set saturated
  64355. */
  64356. isSaturated(): boolean;
  64357. /**
  64358. * Resets the rolling average (equivalent to 0 samples taken so far)
  64359. */
  64360. reset(): void;
  64361. /**
  64362. * Wraps a value around the sample range boundaries
  64363. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64364. * @return Wrapped position in sample range
  64365. */
  64366. protected _wrapPosition(i: number): number;
  64367. }
  64368. }
  64369. declare module BABYLON {
  64370. /**
  64371. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64372. * The underlying implementation relies on an associative array to ensure the best performances.
  64373. * The value can be anything including 'null' but except 'undefined'
  64374. */
  64375. export class StringDictionary<T> {
  64376. /**
  64377. * This will clear this dictionary and copy the content from the 'source' one.
  64378. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64379. * @param source the dictionary to take the content from and copy to this dictionary
  64380. */
  64381. copyFrom(source: StringDictionary<T>): void;
  64382. /**
  64383. * Get a value based from its key
  64384. * @param key the given key to get the matching value from
  64385. * @return the value if found, otherwise undefined is returned
  64386. */
  64387. get(key: string): T | undefined;
  64388. /**
  64389. * Get a value from its key or add it if it doesn't exist.
  64390. * This method will ensure you that a given key/data will be present in the dictionary.
  64391. * @param key the given key to get the matching value from
  64392. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64393. * The factory will only be invoked if there's no data for the given key.
  64394. * @return the value corresponding to the key.
  64395. */
  64396. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64397. /**
  64398. * Get a value from its key if present in the dictionary otherwise add it
  64399. * @param key the key to get the value from
  64400. * @param val if there's no such key/value pair in the dictionary add it with this value
  64401. * @return the value corresponding to the key
  64402. */
  64403. getOrAdd(key: string, val: T): T;
  64404. /**
  64405. * Check if there's a given key in the dictionary
  64406. * @param key the key to check for
  64407. * @return true if the key is present, false otherwise
  64408. */
  64409. contains(key: string): boolean;
  64410. /**
  64411. * Add a new key and its corresponding value
  64412. * @param key the key to add
  64413. * @param value the value corresponding to the key
  64414. * @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
  64415. */
  64416. add(key: string, value: T): boolean;
  64417. /**
  64418. * Update a specific value associated to a key
  64419. * @param key defines the key to use
  64420. * @param value defines the value to store
  64421. * @returns true if the value was updated (or false if the key was not found)
  64422. */
  64423. set(key: string, value: T): boolean;
  64424. /**
  64425. * Get the element of the given key and remove it from the dictionary
  64426. * @param key defines the key to search
  64427. * @returns the value associated with the key or null if not found
  64428. */
  64429. getAndRemove(key: string): Nullable<T>;
  64430. /**
  64431. * Remove a key/value from the dictionary.
  64432. * @param key the key to remove
  64433. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64434. */
  64435. remove(key: string): boolean;
  64436. /**
  64437. * Clear the whole content of the dictionary
  64438. */
  64439. clear(): void;
  64440. /**
  64441. * Gets the current count
  64442. */
  64443. readonly count: number;
  64444. /**
  64445. * Execute a callback on each key/val of the dictionary.
  64446. * Note that you can remove any element in this dictionary in the callback implementation
  64447. * @param callback the callback to execute on a given key/value pair
  64448. */
  64449. forEach(callback: (key: string, val: T) => void): void;
  64450. /**
  64451. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64452. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64453. * Note that you can remove any element in this dictionary in the callback implementation
  64454. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64455. * @returns the first item
  64456. */
  64457. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64458. private _count;
  64459. private _data;
  64460. }
  64461. }
  64462. declare module BABYLON {
  64463. /**
  64464. * Class used to store gfx data (like WebGLBuffer)
  64465. */
  64466. export class DataBuffer {
  64467. /**
  64468. * Gets or sets the number of objects referencing this buffer
  64469. */
  64470. references: number;
  64471. /** Gets or sets the size of the underlying buffer */
  64472. capacity: number;
  64473. /**
  64474. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64475. */
  64476. is32Bits: boolean;
  64477. /**
  64478. * Gets the underlying buffer
  64479. */
  64480. readonly underlyingResource: any;
  64481. }
  64482. }
  64483. declare module BABYLON {
  64484. /**
  64485. * Class used to store data that will be store in GPU memory
  64486. */
  64487. export class Buffer {
  64488. private _engine;
  64489. private _buffer;
  64490. /** @hidden */
  64491. _data: Nullable<DataArray>;
  64492. private _updatable;
  64493. private _instanced;
  64494. /**
  64495. * Gets the byte stride.
  64496. */
  64497. readonly byteStride: number;
  64498. /**
  64499. * Constructor
  64500. * @param engine the engine
  64501. * @param data the data to use for this buffer
  64502. * @param updatable whether the data is updatable
  64503. * @param stride the stride (optional)
  64504. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64505. * @param instanced whether the buffer is instanced (optional)
  64506. * @param useBytes set to true if the stride in in bytes (optional)
  64507. */
  64508. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64509. /**
  64510. * Create a new VertexBuffer based on the current buffer
  64511. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64512. * @param offset defines offset in the buffer (0 by default)
  64513. * @param size defines the size in floats of attributes (position is 3 for instance)
  64514. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64515. * @param instanced defines if the vertex buffer contains indexed data
  64516. * @param useBytes defines if the offset and stride are in bytes
  64517. * @returns the new vertex buffer
  64518. */
  64519. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64520. /**
  64521. * Gets a boolean indicating if the Buffer is updatable?
  64522. * @returns true if the buffer is updatable
  64523. */
  64524. isUpdatable(): boolean;
  64525. /**
  64526. * Gets current buffer's data
  64527. * @returns a DataArray or null
  64528. */
  64529. getData(): Nullable<DataArray>;
  64530. /**
  64531. * Gets underlying native buffer
  64532. * @returns underlying native buffer
  64533. */
  64534. getBuffer(): Nullable<DataBuffer>;
  64535. /**
  64536. * Gets the stride in float32 units (i.e. byte stride / 4).
  64537. * May not be an integer if the byte stride is not divisible by 4.
  64538. * DEPRECATED. Use byteStride instead.
  64539. * @returns the stride in float32 units
  64540. */
  64541. getStrideSize(): number;
  64542. /**
  64543. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64544. * @param data defines the data to store
  64545. */
  64546. create(data?: Nullable<DataArray>): void;
  64547. /** @hidden */
  64548. _rebuild(): void;
  64549. /**
  64550. * Update current buffer data
  64551. * @param data defines the data to store
  64552. */
  64553. update(data: DataArray): void;
  64554. /**
  64555. * Updates the data directly.
  64556. * @param data the new data
  64557. * @param offset the new offset
  64558. * @param vertexCount the vertex count (optional)
  64559. * @param useBytes set to true if the offset is in bytes
  64560. */
  64561. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64562. /**
  64563. * Release all resources
  64564. */
  64565. dispose(): void;
  64566. }
  64567. /**
  64568. * Specialized buffer used to store vertex data
  64569. */
  64570. export class VertexBuffer {
  64571. /** @hidden */
  64572. _buffer: Buffer;
  64573. private _kind;
  64574. private _size;
  64575. private _ownsBuffer;
  64576. private _instanced;
  64577. private _instanceDivisor;
  64578. /**
  64579. * The byte type.
  64580. */
  64581. static readonly BYTE: number;
  64582. /**
  64583. * The unsigned byte type.
  64584. */
  64585. static readonly UNSIGNED_BYTE: number;
  64586. /**
  64587. * The short type.
  64588. */
  64589. static readonly SHORT: number;
  64590. /**
  64591. * The unsigned short type.
  64592. */
  64593. static readonly UNSIGNED_SHORT: number;
  64594. /**
  64595. * The integer type.
  64596. */
  64597. static readonly INT: number;
  64598. /**
  64599. * The unsigned integer type.
  64600. */
  64601. static readonly UNSIGNED_INT: number;
  64602. /**
  64603. * The float type.
  64604. */
  64605. static readonly FLOAT: number;
  64606. /**
  64607. * Gets or sets the instance divisor when in instanced mode
  64608. */
  64609. instanceDivisor: number;
  64610. /**
  64611. * Gets the byte stride.
  64612. */
  64613. readonly byteStride: number;
  64614. /**
  64615. * Gets the byte offset.
  64616. */
  64617. readonly byteOffset: number;
  64618. /**
  64619. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64620. */
  64621. readonly normalized: boolean;
  64622. /**
  64623. * Gets the data type of each component in the array.
  64624. */
  64625. readonly type: number;
  64626. /**
  64627. * Constructor
  64628. * @param engine the engine
  64629. * @param data the data to use for this vertex buffer
  64630. * @param kind the vertex buffer kind
  64631. * @param updatable whether the data is updatable
  64632. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64633. * @param stride the stride (optional)
  64634. * @param instanced whether the buffer is instanced (optional)
  64635. * @param offset the offset of the data (optional)
  64636. * @param size the number of components (optional)
  64637. * @param type the type of the component (optional)
  64638. * @param normalized whether the data contains normalized data (optional)
  64639. * @param useBytes set to true if stride and offset are in bytes (optional)
  64640. */
  64641. 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);
  64642. /** @hidden */
  64643. _rebuild(): void;
  64644. /**
  64645. * Returns the kind of the VertexBuffer (string)
  64646. * @returns a string
  64647. */
  64648. getKind(): string;
  64649. /**
  64650. * Gets a boolean indicating if the VertexBuffer is updatable?
  64651. * @returns true if the buffer is updatable
  64652. */
  64653. isUpdatable(): boolean;
  64654. /**
  64655. * Gets current buffer's data
  64656. * @returns a DataArray or null
  64657. */
  64658. getData(): Nullable<DataArray>;
  64659. /**
  64660. * Gets underlying native buffer
  64661. * @returns underlying native buffer
  64662. */
  64663. getBuffer(): Nullable<DataBuffer>;
  64664. /**
  64665. * Gets the stride in float32 units (i.e. byte stride / 4).
  64666. * May not be an integer if the byte stride is not divisible by 4.
  64667. * DEPRECATED. Use byteStride instead.
  64668. * @returns the stride in float32 units
  64669. */
  64670. getStrideSize(): number;
  64671. /**
  64672. * Returns the offset as a multiple of the type byte length.
  64673. * DEPRECATED. Use byteOffset instead.
  64674. * @returns the offset in bytes
  64675. */
  64676. getOffset(): number;
  64677. /**
  64678. * Returns the number of components per vertex attribute (integer)
  64679. * @returns the size in float
  64680. */
  64681. getSize(): number;
  64682. /**
  64683. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64684. * @returns true if this buffer is instanced
  64685. */
  64686. getIsInstanced(): boolean;
  64687. /**
  64688. * Returns the instancing divisor, zero for non-instanced (integer).
  64689. * @returns a number
  64690. */
  64691. getInstanceDivisor(): number;
  64692. /**
  64693. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64694. * @param data defines the data to store
  64695. */
  64696. create(data?: DataArray): void;
  64697. /**
  64698. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64699. * This function will create a new buffer if the current one is not updatable
  64700. * @param data defines the data to store
  64701. */
  64702. update(data: DataArray): void;
  64703. /**
  64704. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64705. * Returns the directly updated WebGLBuffer.
  64706. * @param data the new data
  64707. * @param offset the new offset
  64708. * @param useBytes set to true if the offset is in bytes
  64709. */
  64710. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64711. /**
  64712. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64713. */
  64714. dispose(): void;
  64715. /**
  64716. * Enumerates each value of this vertex buffer as numbers.
  64717. * @param count the number of values to enumerate
  64718. * @param callback the callback function called for each value
  64719. */
  64720. forEach(count: number, callback: (value: number, index: number) => void): void;
  64721. /**
  64722. * Positions
  64723. */
  64724. static readonly PositionKind: string;
  64725. /**
  64726. * Normals
  64727. */
  64728. static readonly NormalKind: string;
  64729. /**
  64730. * Tangents
  64731. */
  64732. static readonly TangentKind: string;
  64733. /**
  64734. * Texture coordinates
  64735. */
  64736. static readonly UVKind: string;
  64737. /**
  64738. * Texture coordinates 2
  64739. */
  64740. static readonly UV2Kind: string;
  64741. /**
  64742. * Texture coordinates 3
  64743. */
  64744. static readonly UV3Kind: string;
  64745. /**
  64746. * Texture coordinates 4
  64747. */
  64748. static readonly UV4Kind: string;
  64749. /**
  64750. * Texture coordinates 5
  64751. */
  64752. static readonly UV5Kind: string;
  64753. /**
  64754. * Texture coordinates 6
  64755. */
  64756. static readonly UV6Kind: string;
  64757. /**
  64758. * Colors
  64759. */
  64760. static readonly ColorKind: string;
  64761. /**
  64762. * Matrix indices (for bones)
  64763. */
  64764. static readonly MatricesIndicesKind: string;
  64765. /**
  64766. * Matrix weights (for bones)
  64767. */
  64768. static readonly MatricesWeightsKind: string;
  64769. /**
  64770. * Additional matrix indices (for bones)
  64771. */
  64772. static readonly MatricesIndicesExtraKind: string;
  64773. /**
  64774. * Additional matrix weights (for bones)
  64775. */
  64776. static readonly MatricesWeightsExtraKind: string;
  64777. /**
  64778. * Deduces the stride given a kind.
  64779. * @param kind The kind string to deduce
  64780. * @returns The deduced stride
  64781. */
  64782. static DeduceStride(kind: string): number;
  64783. /**
  64784. * Gets the byte length of the given type.
  64785. * @param type the type
  64786. * @returns the number of bytes
  64787. */
  64788. static GetTypeByteLength(type: number): number;
  64789. /**
  64790. * Enumerates each value of the given parameters as numbers.
  64791. * @param data the data to enumerate
  64792. * @param byteOffset the byte offset of the data
  64793. * @param byteStride the byte stride of the data
  64794. * @param componentCount the number of components per element
  64795. * @param componentType the type of the component
  64796. * @param count the number of values to enumerate
  64797. * @param normalized whether the data is normalized
  64798. * @param callback the callback function called for each value
  64799. */
  64800. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64801. private static _GetFloatValue;
  64802. }
  64803. }
  64804. declare module BABYLON {
  64805. /**
  64806. * Scalar computation library
  64807. */
  64808. export class Scalar {
  64809. /**
  64810. * Two pi constants convenient for computation.
  64811. */
  64812. static TwoPi: number;
  64813. /**
  64814. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64815. * @param a number
  64816. * @param b number
  64817. * @param epsilon (default = 1.401298E-45)
  64818. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64819. */
  64820. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64821. /**
  64822. * Returns a string : the upper case translation of the number i to hexadecimal.
  64823. * @param i number
  64824. * @returns the upper case translation of the number i to hexadecimal.
  64825. */
  64826. static ToHex(i: number): string;
  64827. /**
  64828. * Returns -1 if value is negative and +1 is value is positive.
  64829. * @param value the value
  64830. * @returns the value itself if it's equal to zero.
  64831. */
  64832. static Sign(value: number): number;
  64833. /**
  64834. * Returns the value itself if it's between min and max.
  64835. * Returns min if the value is lower than min.
  64836. * Returns max if the value is greater than max.
  64837. * @param value the value to clmap
  64838. * @param min the min value to clamp to (default: 0)
  64839. * @param max the max value to clamp to (default: 1)
  64840. * @returns the clamped value
  64841. */
  64842. static Clamp(value: number, min?: number, max?: number): number;
  64843. /**
  64844. * the log2 of value.
  64845. * @param value the value to compute log2 of
  64846. * @returns the log2 of value.
  64847. */
  64848. static Log2(value: number): number;
  64849. /**
  64850. * Loops the value, so that it is never larger than length and never smaller than 0.
  64851. *
  64852. * This is similar to the modulo operator but it works with floating point numbers.
  64853. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  64854. * With t = 5 and length = 2.5, the result would be 0.0.
  64855. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  64856. * @param value the value
  64857. * @param length the length
  64858. * @returns the looped value
  64859. */
  64860. static Repeat(value: number, length: number): number;
  64861. /**
  64862. * Normalize the value between 0.0 and 1.0 using min and max values
  64863. * @param value value to normalize
  64864. * @param min max to normalize between
  64865. * @param max min to normalize between
  64866. * @returns the normalized value
  64867. */
  64868. static Normalize(value: number, min: number, max: number): number;
  64869. /**
  64870. * Denormalize the value from 0.0 and 1.0 using min and max values
  64871. * @param normalized value to denormalize
  64872. * @param min max to denormalize between
  64873. * @param max min to denormalize between
  64874. * @returns the denormalized value
  64875. */
  64876. static Denormalize(normalized: number, min: number, max: number): number;
  64877. /**
  64878. * Calculates the shortest difference between two given angles given in degrees.
  64879. * @param current current angle in degrees
  64880. * @param target target angle in degrees
  64881. * @returns the delta
  64882. */
  64883. static DeltaAngle(current: number, target: number): number;
  64884. /**
  64885. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  64886. * @param tx value
  64887. * @param length length
  64888. * @returns The returned value will move back and forth between 0 and length
  64889. */
  64890. static PingPong(tx: number, length: number): number;
  64891. /**
  64892. * Interpolates between min and max with smoothing at the limits.
  64893. *
  64894. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  64895. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  64896. * @param from from
  64897. * @param to to
  64898. * @param tx value
  64899. * @returns the smooth stepped value
  64900. */
  64901. static SmoothStep(from: number, to: number, tx: number): number;
  64902. /**
  64903. * Moves a value current towards target.
  64904. *
  64905. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  64906. * Negative values of maxDelta pushes the value away from target.
  64907. * @param current current value
  64908. * @param target target value
  64909. * @param maxDelta max distance to move
  64910. * @returns resulting value
  64911. */
  64912. static MoveTowards(current: number, target: number, maxDelta: number): number;
  64913. /**
  64914. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64915. *
  64916. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  64917. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  64918. * @param current current value
  64919. * @param target target value
  64920. * @param maxDelta max distance to move
  64921. * @returns resulting angle
  64922. */
  64923. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  64924. /**
  64925. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  64926. * @param start start value
  64927. * @param end target value
  64928. * @param amount amount to lerp between
  64929. * @returns the lerped value
  64930. */
  64931. static Lerp(start: number, end: number, amount: number): number;
  64932. /**
  64933. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64934. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  64935. * @param start start value
  64936. * @param end target value
  64937. * @param amount amount to lerp between
  64938. * @returns the lerped value
  64939. */
  64940. static LerpAngle(start: number, end: number, amount: number): number;
  64941. /**
  64942. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  64943. * @param a start value
  64944. * @param b target value
  64945. * @param value value between a and b
  64946. * @returns the inverseLerp value
  64947. */
  64948. static InverseLerp(a: number, b: number, value: number): number;
  64949. /**
  64950. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  64951. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  64952. * @param value1 spline value
  64953. * @param tangent1 spline value
  64954. * @param value2 spline value
  64955. * @param tangent2 spline value
  64956. * @param amount input value
  64957. * @returns hermite result
  64958. */
  64959. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  64960. /**
  64961. * Returns a random float number between and min and max values
  64962. * @param min min value of random
  64963. * @param max max value of random
  64964. * @returns random value
  64965. */
  64966. static RandomRange(min: number, max: number): number;
  64967. /**
  64968. * This function returns percentage of a number in a given range.
  64969. *
  64970. * RangeToPercent(40,20,60) will return 0.5 (50%)
  64971. * RangeToPercent(34,0,100) will return 0.34 (34%)
  64972. * @param number to convert to percentage
  64973. * @param min min range
  64974. * @param max max range
  64975. * @returns the percentage
  64976. */
  64977. static RangeToPercent(number: number, min: number, max: number): number;
  64978. /**
  64979. * This function returns number that corresponds to the percentage in a given range.
  64980. *
  64981. * PercentToRange(0.34,0,100) will return 34.
  64982. * @param percent to convert to number
  64983. * @param min min range
  64984. * @param max max range
  64985. * @returns the number
  64986. */
  64987. static PercentToRange(percent: number, min: number, max: number): number;
  64988. /**
  64989. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  64990. * @param angle The angle to normalize in radian.
  64991. * @return The converted angle.
  64992. */
  64993. static NormalizeRadians(angle: number): number;
  64994. }
  64995. }
  64996. declare module BABYLON {
  64997. /**
  64998. * Constant used to convert a value to gamma space
  64999. * @ignorenaming
  65000. */
  65001. export const ToGammaSpace: number;
  65002. /**
  65003. * Constant used to convert a value to linear space
  65004. * @ignorenaming
  65005. */
  65006. export const ToLinearSpace = 2.2;
  65007. /**
  65008. * Constant used to define the minimal number value in Babylon.js
  65009. * @ignorenaming
  65010. */
  65011. let Epsilon: number;
  65012. }
  65013. declare module BABYLON {
  65014. /**
  65015. * Class used to represent a viewport on screen
  65016. */
  65017. export class Viewport {
  65018. /** viewport left coordinate */
  65019. x: number;
  65020. /** viewport top coordinate */
  65021. y: number;
  65022. /**viewport width */
  65023. width: number;
  65024. /** viewport height */
  65025. height: number;
  65026. /**
  65027. * Creates a Viewport object located at (x, y) and sized (width, height)
  65028. * @param x defines viewport left coordinate
  65029. * @param y defines viewport top coordinate
  65030. * @param width defines the viewport width
  65031. * @param height defines the viewport height
  65032. */
  65033. constructor(
  65034. /** viewport left coordinate */
  65035. x: number,
  65036. /** viewport top coordinate */
  65037. y: number,
  65038. /**viewport width */
  65039. width: number,
  65040. /** viewport height */
  65041. height: number);
  65042. /**
  65043. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65044. * @param renderWidth defines the rendering width
  65045. * @param renderHeight defines the rendering height
  65046. * @returns a new Viewport
  65047. */
  65048. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65049. /**
  65050. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65051. * @param renderWidth defines the rendering width
  65052. * @param renderHeight defines the rendering height
  65053. * @param ref defines the target viewport
  65054. * @returns the current viewport
  65055. */
  65056. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65057. /**
  65058. * Returns a new Viewport copied from the current one
  65059. * @returns a new Viewport
  65060. */
  65061. clone(): Viewport;
  65062. }
  65063. }
  65064. declare module BABYLON {
  65065. /**
  65066. * Class containing a set of static utilities functions for arrays.
  65067. */
  65068. export class ArrayTools {
  65069. /**
  65070. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65071. * @param size the number of element to construct and put in the array
  65072. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65073. * @returns a new array filled with new objects
  65074. */
  65075. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65076. }
  65077. }
  65078. declare module BABYLON {
  65079. /**
  65080. * @hidden
  65081. */
  65082. export interface IColor4Like {
  65083. r: float;
  65084. g: float;
  65085. b: float;
  65086. a: float;
  65087. }
  65088. /**
  65089. * @hidden
  65090. */
  65091. export interface IColor3Like {
  65092. r: float;
  65093. g: float;
  65094. b: float;
  65095. }
  65096. /**
  65097. * @hidden
  65098. */
  65099. export interface IVector4Like {
  65100. x: float;
  65101. y: float;
  65102. z: float;
  65103. w: float;
  65104. }
  65105. /**
  65106. * @hidden
  65107. */
  65108. export interface IVector3Like {
  65109. x: float;
  65110. y: float;
  65111. z: float;
  65112. }
  65113. /**
  65114. * @hidden
  65115. */
  65116. export interface IVector2Like {
  65117. x: float;
  65118. y: float;
  65119. }
  65120. /**
  65121. * @hidden
  65122. */
  65123. export interface IMatrixLike {
  65124. toArray(): DeepImmutable<Float32Array>;
  65125. updateFlag: int;
  65126. }
  65127. /**
  65128. * @hidden
  65129. */
  65130. export interface IViewportLike {
  65131. x: float;
  65132. y: float;
  65133. width: float;
  65134. height: float;
  65135. }
  65136. /**
  65137. * @hidden
  65138. */
  65139. export interface IPlaneLike {
  65140. normal: IVector3Like;
  65141. d: float;
  65142. normalize(): void;
  65143. }
  65144. }
  65145. declare module BABYLON {
  65146. /**
  65147. * Class representing a vector containing 2 coordinates
  65148. */
  65149. export class Vector2 {
  65150. /** defines the first coordinate */
  65151. x: number;
  65152. /** defines the second coordinate */
  65153. y: number;
  65154. /**
  65155. * Creates a new Vector2 from the given x and y coordinates
  65156. * @param x defines the first coordinate
  65157. * @param y defines the second coordinate
  65158. */
  65159. constructor(
  65160. /** defines the first coordinate */
  65161. x?: number,
  65162. /** defines the second coordinate */
  65163. y?: number);
  65164. /**
  65165. * Gets a string with the Vector2 coordinates
  65166. * @returns a string with the Vector2 coordinates
  65167. */
  65168. toString(): string;
  65169. /**
  65170. * Gets class name
  65171. * @returns the string "Vector2"
  65172. */
  65173. getClassName(): string;
  65174. /**
  65175. * Gets current vector hash code
  65176. * @returns the Vector2 hash code as a number
  65177. */
  65178. getHashCode(): number;
  65179. /**
  65180. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65181. * @param array defines the source array
  65182. * @param index defines the offset in source array
  65183. * @returns the current Vector2
  65184. */
  65185. toArray(array: FloatArray, index?: number): Vector2;
  65186. /**
  65187. * Copy the current vector to an array
  65188. * @returns a new array with 2 elements: the Vector2 coordinates.
  65189. */
  65190. asArray(): number[];
  65191. /**
  65192. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65193. * @param source defines the source Vector2
  65194. * @returns the current updated Vector2
  65195. */
  65196. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65197. /**
  65198. * Sets the Vector2 coordinates with the given floats
  65199. * @param x defines the first coordinate
  65200. * @param y defines the second coordinate
  65201. * @returns the current updated Vector2
  65202. */
  65203. copyFromFloats(x: number, y: number): Vector2;
  65204. /**
  65205. * Sets the Vector2 coordinates with the given floats
  65206. * @param x defines the first coordinate
  65207. * @param y defines the second coordinate
  65208. * @returns the current updated Vector2
  65209. */
  65210. set(x: number, y: number): Vector2;
  65211. /**
  65212. * Add another vector with the current one
  65213. * @param otherVector defines the other vector
  65214. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65215. */
  65216. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65217. /**
  65218. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65219. * @param otherVector defines the other vector
  65220. * @param result defines the target vector
  65221. * @returns the unmodified current Vector2
  65222. */
  65223. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65224. /**
  65225. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65226. * @param otherVector defines the other vector
  65227. * @returns the current updated Vector2
  65228. */
  65229. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65230. /**
  65231. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65232. * @param otherVector defines the other vector
  65233. * @returns a new Vector2
  65234. */
  65235. addVector3(otherVector: Vector3): Vector2;
  65236. /**
  65237. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65238. * @param otherVector defines the other vector
  65239. * @returns a new Vector2
  65240. */
  65241. subtract(otherVector: Vector2): Vector2;
  65242. /**
  65243. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65244. * @param otherVector defines the other vector
  65245. * @param result defines the target vector
  65246. * @returns the unmodified current Vector2
  65247. */
  65248. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65249. /**
  65250. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65251. * @param otherVector defines the other vector
  65252. * @returns the current updated Vector2
  65253. */
  65254. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65255. /**
  65256. * Multiplies in place the current Vector2 coordinates by the given ones
  65257. * @param otherVector defines the other vector
  65258. * @returns the current updated Vector2
  65259. */
  65260. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65261. /**
  65262. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65263. * @param otherVector defines the other vector
  65264. * @returns a new Vector2
  65265. */
  65266. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65267. /**
  65268. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65269. * @param otherVector defines the other vector
  65270. * @param result defines the target vector
  65271. * @returns the unmodified current Vector2
  65272. */
  65273. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65274. /**
  65275. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65276. * @param x defines the first coordinate
  65277. * @param y defines the second coordinate
  65278. * @returns a new Vector2
  65279. */
  65280. multiplyByFloats(x: number, y: number): Vector2;
  65281. /**
  65282. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65283. * @param otherVector defines the other vector
  65284. * @returns a new Vector2
  65285. */
  65286. divide(otherVector: Vector2): Vector2;
  65287. /**
  65288. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65289. * @param otherVector defines the other vector
  65290. * @param result defines the target vector
  65291. * @returns the unmodified current Vector2
  65292. */
  65293. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65294. /**
  65295. * Divides the current Vector2 coordinates by the given ones
  65296. * @param otherVector defines the other vector
  65297. * @returns the current updated Vector2
  65298. */
  65299. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65300. /**
  65301. * Gets a new Vector2 with current Vector2 negated coordinates
  65302. * @returns a new Vector2
  65303. */
  65304. negate(): Vector2;
  65305. /**
  65306. * Multiply the Vector2 coordinates by scale
  65307. * @param scale defines the scaling factor
  65308. * @returns the current updated Vector2
  65309. */
  65310. scaleInPlace(scale: number): Vector2;
  65311. /**
  65312. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65313. * @param scale defines the scaling factor
  65314. * @returns a new Vector2
  65315. */
  65316. scale(scale: number): Vector2;
  65317. /**
  65318. * Scale the current Vector2 values by a factor to a given Vector2
  65319. * @param scale defines the scale factor
  65320. * @param result defines the Vector2 object where to store the result
  65321. * @returns the unmodified current Vector2
  65322. */
  65323. scaleToRef(scale: number, result: Vector2): Vector2;
  65324. /**
  65325. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65326. * @param scale defines the scale factor
  65327. * @param result defines the Vector2 object where to store the result
  65328. * @returns the unmodified current Vector2
  65329. */
  65330. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65331. /**
  65332. * Gets a boolean if two vectors are equals
  65333. * @param otherVector defines the other vector
  65334. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65335. */
  65336. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65337. /**
  65338. * Gets a boolean if two vectors are equals (using an epsilon value)
  65339. * @param otherVector defines the other vector
  65340. * @param epsilon defines the minimal distance to consider equality
  65341. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65342. */
  65343. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65344. /**
  65345. * Gets a new Vector2 from current Vector2 floored values
  65346. * @returns a new Vector2
  65347. */
  65348. floor(): Vector2;
  65349. /**
  65350. * Gets a new Vector2 from current Vector2 floored values
  65351. * @returns a new Vector2
  65352. */
  65353. fract(): Vector2;
  65354. /**
  65355. * Gets the length of the vector
  65356. * @returns the vector length (float)
  65357. */
  65358. length(): number;
  65359. /**
  65360. * Gets the vector squared length
  65361. * @returns the vector squared length (float)
  65362. */
  65363. lengthSquared(): number;
  65364. /**
  65365. * Normalize the vector
  65366. * @returns the current updated Vector2
  65367. */
  65368. normalize(): Vector2;
  65369. /**
  65370. * Gets a new Vector2 copied from the Vector2
  65371. * @returns a new Vector2
  65372. */
  65373. clone(): Vector2;
  65374. /**
  65375. * Gets a new Vector2(0, 0)
  65376. * @returns a new Vector2
  65377. */
  65378. static Zero(): Vector2;
  65379. /**
  65380. * Gets a new Vector2(1, 1)
  65381. * @returns a new Vector2
  65382. */
  65383. static One(): Vector2;
  65384. /**
  65385. * Gets a new Vector2 set from the given index element of the given array
  65386. * @param array defines the data source
  65387. * @param offset defines the offset in the data source
  65388. * @returns a new Vector2
  65389. */
  65390. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65391. /**
  65392. * Sets "result" from the given index element of the given array
  65393. * @param array defines the data source
  65394. * @param offset defines the offset in the data source
  65395. * @param result defines the target vector
  65396. */
  65397. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65398. /**
  65399. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65400. * @param value1 defines 1st point of control
  65401. * @param value2 defines 2nd point of control
  65402. * @param value3 defines 3rd point of control
  65403. * @param value4 defines 4th point of control
  65404. * @param amount defines the interpolation factor
  65405. * @returns a new Vector2
  65406. */
  65407. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65408. /**
  65409. * 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".
  65410. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65411. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65412. * @param value defines the value to clamp
  65413. * @param min defines the lower limit
  65414. * @param max defines the upper limit
  65415. * @returns a new Vector2
  65416. */
  65417. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65418. /**
  65419. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65420. * @param value1 defines the 1st control point
  65421. * @param tangent1 defines the outgoing tangent
  65422. * @param value2 defines the 2nd control point
  65423. * @param tangent2 defines the incoming tangent
  65424. * @param amount defines the interpolation factor
  65425. * @returns a new Vector2
  65426. */
  65427. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65428. /**
  65429. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65430. * @param start defines the start vector
  65431. * @param end defines the end vector
  65432. * @param amount defines the interpolation factor
  65433. * @returns a new Vector2
  65434. */
  65435. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65436. /**
  65437. * Gets the dot product of the vector "left" and the vector "right"
  65438. * @param left defines first vector
  65439. * @param right defines second vector
  65440. * @returns the dot product (float)
  65441. */
  65442. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65443. /**
  65444. * Returns a new Vector2 equal to the normalized given vector
  65445. * @param vector defines the vector to normalize
  65446. * @returns a new Vector2
  65447. */
  65448. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65449. /**
  65450. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65451. * @param left defines 1st vector
  65452. * @param right defines 2nd vector
  65453. * @returns a new Vector2
  65454. */
  65455. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65456. /**
  65457. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65458. * @param left defines 1st vector
  65459. * @param right defines 2nd vector
  65460. * @returns a new Vector2
  65461. */
  65462. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65463. /**
  65464. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65465. * @param vector defines the vector to transform
  65466. * @param transformation defines the matrix to apply
  65467. * @returns a new Vector2
  65468. */
  65469. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65470. /**
  65471. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65472. * @param vector defines the vector to transform
  65473. * @param transformation defines the matrix to apply
  65474. * @param result defines the target vector
  65475. */
  65476. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65477. /**
  65478. * Determines if a given vector is included in a triangle
  65479. * @param p defines the vector to test
  65480. * @param p0 defines 1st triangle point
  65481. * @param p1 defines 2nd triangle point
  65482. * @param p2 defines 3rd triangle point
  65483. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65484. */
  65485. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65486. /**
  65487. * Gets the distance between the vectors "value1" and "value2"
  65488. * @param value1 defines first vector
  65489. * @param value2 defines second vector
  65490. * @returns the distance between vectors
  65491. */
  65492. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65493. /**
  65494. * Returns the squared distance between the vectors "value1" and "value2"
  65495. * @param value1 defines first vector
  65496. * @param value2 defines second vector
  65497. * @returns the squared distance between vectors
  65498. */
  65499. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65500. /**
  65501. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65502. * @param value1 defines first vector
  65503. * @param value2 defines second vector
  65504. * @returns a new Vector2
  65505. */
  65506. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65507. /**
  65508. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65509. * @param p defines the middle point
  65510. * @param segA defines one point of the segment
  65511. * @param segB defines the other point of the segment
  65512. * @returns the shortest distance
  65513. */
  65514. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65515. }
  65516. /**
  65517. * Classed used to store (x,y,z) vector representation
  65518. * A Vector3 is the main object used in 3D geometry
  65519. * It can represent etiher the coordinates of a point the space, either a direction
  65520. * Reminder: js uses a left handed forward facing system
  65521. */
  65522. export class Vector3 {
  65523. /**
  65524. * Defines the first coordinates (on X axis)
  65525. */
  65526. x: number;
  65527. /**
  65528. * Defines the second coordinates (on Y axis)
  65529. */
  65530. y: number;
  65531. /**
  65532. * Defines the third coordinates (on Z axis)
  65533. */
  65534. z: number;
  65535. private static _UpReadOnly;
  65536. private static _ZeroReadOnly;
  65537. /**
  65538. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65539. * @param x defines the first coordinates (on X axis)
  65540. * @param y defines the second coordinates (on Y axis)
  65541. * @param z defines the third coordinates (on Z axis)
  65542. */
  65543. constructor(
  65544. /**
  65545. * Defines the first coordinates (on X axis)
  65546. */
  65547. x?: number,
  65548. /**
  65549. * Defines the second coordinates (on Y axis)
  65550. */
  65551. y?: number,
  65552. /**
  65553. * Defines the third coordinates (on Z axis)
  65554. */
  65555. z?: number);
  65556. /**
  65557. * Creates a string representation of the Vector3
  65558. * @returns a string with the Vector3 coordinates.
  65559. */
  65560. toString(): string;
  65561. /**
  65562. * Gets the class name
  65563. * @returns the string "Vector3"
  65564. */
  65565. getClassName(): string;
  65566. /**
  65567. * Creates the Vector3 hash code
  65568. * @returns a number which tends to be unique between Vector3 instances
  65569. */
  65570. getHashCode(): number;
  65571. /**
  65572. * Creates an array containing three elements : the coordinates of the Vector3
  65573. * @returns a new array of numbers
  65574. */
  65575. asArray(): number[];
  65576. /**
  65577. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65578. * @param array defines the destination array
  65579. * @param index defines the offset in the destination array
  65580. * @returns the current Vector3
  65581. */
  65582. toArray(array: FloatArray, index?: number): Vector3;
  65583. /**
  65584. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65585. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65586. */
  65587. toQuaternion(): Quaternion;
  65588. /**
  65589. * Adds the given vector to the current Vector3
  65590. * @param otherVector defines the second operand
  65591. * @returns the current updated Vector3
  65592. */
  65593. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65594. /**
  65595. * Adds the given coordinates to the current Vector3
  65596. * @param x defines the x coordinate of the operand
  65597. * @param y defines the y coordinate of the operand
  65598. * @param z defines the z coordinate of the operand
  65599. * @returns the current updated Vector3
  65600. */
  65601. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65602. /**
  65603. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65604. * @param otherVector defines the second operand
  65605. * @returns the resulting Vector3
  65606. */
  65607. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65608. /**
  65609. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65610. * @param otherVector defines the second operand
  65611. * @param result defines the Vector3 object where to store the result
  65612. * @returns the current Vector3
  65613. */
  65614. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65615. /**
  65616. * Subtract the given vector from the current Vector3
  65617. * @param otherVector defines the second operand
  65618. * @returns the current updated Vector3
  65619. */
  65620. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65621. /**
  65622. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65623. * @param otherVector defines the second operand
  65624. * @returns the resulting Vector3
  65625. */
  65626. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65627. /**
  65628. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65629. * @param otherVector defines the second operand
  65630. * @param result defines the Vector3 object where to store the result
  65631. * @returns the current Vector3
  65632. */
  65633. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65634. /**
  65635. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65636. * @param x defines the x coordinate of the operand
  65637. * @param y defines the y coordinate of the operand
  65638. * @param z defines the z coordinate of the operand
  65639. * @returns the resulting Vector3
  65640. */
  65641. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65642. /**
  65643. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65644. * @param x defines the x coordinate of the operand
  65645. * @param y defines the y coordinate of the operand
  65646. * @param z defines the z coordinate of the operand
  65647. * @param result defines the Vector3 object where to store the result
  65648. * @returns the current Vector3
  65649. */
  65650. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65651. /**
  65652. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65653. * @returns a new Vector3
  65654. */
  65655. negate(): Vector3;
  65656. /**
  65657. * Multiplies the Vector3 coordinates by the float "scale"
  65658. * @param scale defines the multiplier factor
  65659. * @returns the current updated Vector3
  65660. */
  65661. scaleInPlace(scale: number): Vector3;
  65662. /**
  65663. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65664. * @param scale defines the multiplier factor
  65665. * @returns a new Vector3
  65666. */
  65667. scale(scale: number): Vector3;
  65668. /**
  65669. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65670. * @param scale defines the multiplier factor
  65671. * @param result defines the Vector3 object where to store the result
  65672. * @returns the current Vector3
  65673. */
  65674. scaleToRef(scale: number, result: Vector3): Vector3;
  65675. /**
  65676. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65677. * @param scale defines the scale factor
  65678. * @param result defines the Vector3 object where to store the result
  65679. * @returns the unmodified current Vector3
  65680. */
  65681. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65682. /**
  65683. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65684. * @param otherVector defines the second operand
  65685. * @returns true if both vectors are equals
  65686. */
  65687. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65688. /**
  65689. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65690. * @param otherVector defines the second operand
  65691. * @param epsilon defines the minimal distance to define values as equals
  65692. * @returns true if both vectors are distant less than epsilon
  65693. */
  65694. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65695. /**
  65696. * Returns true if the current Vector3 coordinates equals the given floats
  65697. * @param x defines the x coordinate of the operand
  65698. * @param y defines the y coordinate of the operand
  65699. * @param z defines the z coordinate of the operand
  65700. * @returns true if both vectors are equals
  65701. */
  65702. equalsToFloats(x: number, y: number, z: number): boolean;
  65703. /**
  65704. * Multiplies the current Vector3 coordinates by the given ones
  65705. * @param otherVector defines the second operand
  65706. * @returns the current updated Vector3
  65707. */
  65708. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65709. /**
  65710. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65711. * @param otherVector defines the second operand
  65712. * @returns the new Vector3
  65713. */
  65714. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65715. /**
  65716. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65717. * @param otherVector defines the second operand
  65718. * @param result defines the Vector3 object where to store the result
  65719. * @returns the current Vector3
  65720. */
  65721. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65722. /**
  65723. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65724. * @param x defines the x coordinate of the operand
  65725. * @param y defines the y coordinate of the operand
  65726. * @param z defines the z coordinate of the operand
  65727. * @returns the new Vector3
  65728. */
  65729. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65730. /**
  65731. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65732. * @param otherVector defines the second operand
  65733. * @returns the new Vector3
  65734. */
  65735. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65736. /**
  65737. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65738. * @param otherVector defines the second operand
  65739. * @param result defines the Vector3 object where to store the result
  65740. * @returns the current Vector3
  65741. */
  65742. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65743. /**
  65744. * Divides the current Vector3 coordinates by the given ones.
  65745. * @param otherVector defines the second operand
  65746. * @returns the current updated Vector3
  65747. */
  65748. divideInPlace(otherVector: Vector3): Vector3;
  65749. /**
  65750. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65751. * @param other defines the second operand
  65752. * @returns the current updated Vector3
  65753. */
  65754. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65755. /**
  65756. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65757. * @param other defines the second operand
  65758. * @returns the current updated Vector3
  65759. */
  65760. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65761. /**
  65762. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65763. * @param x defines the x coordinate of the operand
  65764. * @param y defines the y coordinate of the operand
  65765. * @param z defines the z coordinate of the operand
  65766. * @returns the current updated Vector3
  65767. */
  65768. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65769. /**
  65770. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  65771. * @param x defines the x coordinate of the operand
  65772. * @param y defines the y coordinate of the operand
  65773. * @param z defines the z coordinate of the operand
  65774. * @returns the current updated Vector3
  65775. */
  65776. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65777. /**
  65778. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65779. * Check if is non uniform within a certain amount of decimal places to account for this
  65780. * @param epsilon the amount the values can differ
  65781. * @returns if the the vector is non uniform to a certain number of decimal places
  65782. */
  65783. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65784. /**
  65785. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65786. */
  65787. readonly isNonUniform: boolean;
  65788. /**
  65789. * Gets a new Vector3 from current Vector3 floored values
  65790. * @returns a new Vector3
  65791. */
  65792. floor(): Vector3;
  65793. /**
  65794. * Gets a new Vector3 from current Vector3 floored values
  65795. * @returns a new Vector3
  65796. */
  65797. fract(): Vector3;
  65798. /**
  65799. * Gets the length of the Vector3
  65800. * @returns the length of the Vector3
  65801. */
  65802. length(): number;
  65803. /**
  65804. * Gets the squared length of the Vector3
  65805. * @returns squared length of the Vector3
  65806. */
  65807. lengthSquared(): number;
  65808. /**
  65809. * Normalize the current Vector3.
  65810. * Please note that this is an in place operation.
  65811. * @returns the current updated Vector3
  65812. */
  65813. normalize(): Vector3;
  65814. /**
  65815. * Reorders the x y z properties of the vector in place
  65816. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65817. * @returns the current updated vector
  65818. */
  65819. reorderInPlace(order: string): this;
  65820. /**
  65821. * Rotates the vector around 0,0,0 by a quaternion
  65822. * @param quaternion the rotation quaternion
  65823. * @param result vector to store the result
  65824. * @returns the resulting vector
  65825. */
  65826. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65827. /**
  65828. * Rotates a vector around a given point
  65829. * @param quaternion the rotation quaternion
  65830. * @param point the point to rotate around
  65831. * @param result vector to store the result
  65832. * @returns the resulting vector
  65833. */
  65834. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65835. /**
  65836. * Normalize the current Vector3 with the given input length.
  65837. * Please note that this is an in place operation.
  65838. * @param len the length of the vector
  65839. * @returns the current updated Vector3
  65840. */
  65841. normalizeFromLength(len: number): Vector3;
  65842. /**
  65843. * Normalize the current Vector3 to a new vector
  65844. * @returns the new Vector3
  65845. */
  65846. normalizeToNew(): Vector3;
  65847. /**
  65848. * Normalize the current Vector3 to the reference
  65849. * @param reference define the Vector3 to update
  65850. * @returns the updated Vector3
  65851. */
  65852. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  65853. /**
  65854. * Creates a new Vector3 copied from the current Vector3
  65855. * @returns the new Vector3
  65856. */
  65857. clone(): Vector3;
  65858. /**
  65859. * Copies the given vector coordinates to the current Vector3 ones
  65860. * @param source defines the source Vector3
  65861. * @returns the current updated Vector3
  65862. */
  65863. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  65864. /**
  65865. * Copies the given floats to the current Vector3 coordinates
  65866. * @param x defines the x coordinate of the operand
  65867. * @param y defines the y coordinate of the operand
  65868. * @param z defines the z coordinate of the operand
  65869. * @returns the current updated Vector3
  65870. */
  65871. copyFromFloats(x: number, y: number, z: number): Vector3;
  65872. /**
  65873. * Copies the given floats to the current Vector3 coordinates
  65874. * @param x defines the x coordinate of the operand
  65875. * @param y defines the y coordinate of the operand
  65876. * @param z defines the z coordinate of the operand
  65877. * @returns the current updated Vector3
  65878. */
  65879. set(x: number, y: number, z: number): Vector3;
  65880. /**
  65881. * Copies the given float to the current Vector3 coordinates
  65882. * @param v defines the x, y and z coordinates of the operand
  65883. * @returns the current updated Vector3
  65884. */
  65885. setAll(v: number): Vector3;
  65886. /**
  65887. * Get the clip factor between two vectors
  65888. * @param vector0 defines the first operand
  65889. * @param vector1 defines the second operand
  65890. * @param axis defines the axis to use
  65891. * @param size defines the size along the axis
  65892. * @returns the clip factor
  65893. */
  65894. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  65895. /**
  65896. * Get angle between two vectors
  65897. * @param vector0 angle between vector0 and vector1
  65898. * @param vector1 angle between vector0 and vector1
  65899. * @param normal direction of the normal
  65900. * @return the angle between vector0 and vector1
  65901. */
  65902. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  65903. /**
  65904. * Returns a new Vector3 set from the index "offset" of the given array
  65905. * @param array defines the source array
  65906. * @param offset defines the offset in the source array
  65907. * @returns the new Vector3
  65908. */
  65909. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  65910. /**
  65911. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  65912. * This function is deprecated. Use FromArray instead
  65913. * @param array defines the source array
  65914. * @param offset defines the offset in the source array
  65915. * @returns the new Vector3
  65916. */
  65917. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  65918. /**
  65919. * Sets the given vector "result" with the element values from the index "offset" of the given array
  65920. * @param array defines the source array
  65921. * @param offset defines the offset in the source array
  65922. * @param result defines the Vector3 where to store the result
  65923. */
  65924. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  65925. /**
  65926. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  65927. * This function is deprecated. Use FromArrayToRef instead.
  65928. * @param array defines the source array
  65929. * @param offset defines the offset in the source array
  65930. * @param result defines the Vector3 where to store the result
  65931. */
  65932. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  65933. /**
  65934. * Sets the given vector "result" with the given floats.
  65935. * @param x defines the x coordinate of the source
  65936. * @param y defines the y coordinate of the source
  65937. * @param z defines the z coordinate of the source
  65938. * @param result defines the Vector3 where to store the result
  65939. */
  65940. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  65941. /**
  65942. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  65943. * @returns a new empty Vector3
  65944. */
  65945. static Zero(): Vector3;
  65946. /**
  65947. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  65948. * @returns a new unit Vector3
  65949. */
  65950. static One(): Vector3;
  65951. /**
  65952. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  65953. * @returns a new up Vector3
  65954. */
  65955. static Up(): Vector3;
  65956. /**
  65957. * Gets a up Vector3 that must not be updated
  65958. */
  65959. static readonly UpReadOnly: DeepImmutable<Vector3>;
  65960. /**
  65961. * Gets a zero Vector3 that must not be updated
  65962. */
  65963. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  65964. /**
  65965. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  65966. * @returns a new down Vector3
  65967. */
  65968. static Down(): Vector3;
  65969. /**
  65970. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  65971. * @returns a new forward Vector3
  65972. */
  65973. static Forward(): Vector3;
  65974. /**
  65975. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  65976. * @returns a new forward Vector3
  65977. */
  65978. static Backward(): Vector3;
  65979. /**
  65980. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  65981. * @returns a new right Vector3
  65982. */
  65983. static Right(): Vector3;
  65984. /**
  65985. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  65986. * @returns a new left Vector3
  65987. */
  65988. static Left(): Vector3;
  65989. /**
  65990. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  65991. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65992. * @param vector defines the Vector3 to transform
  65993. * @param transformation defines the transformation matrix
  65994. * @returns the transformed Vector3
  65995. */
  65996. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65997. /**
  65998. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  65999. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  66000. * @param vector defines the Vector3 to transform
  66001. * @param transformation defines the transformation matrix
  66002. * @param result defines the Vector3 where to store the result
  66003. */
  66004. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66005. /**
  66006. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  66007. * This method computes tranformed coordinates only, not transformed direction vectors
  66008. * @param x define the x coordinate of the source vector
  66009. * @param y define the y coordinate of the source vector
  66010. * @param z define the z coordinate of the source vector
  66011. * @param transformation defines the transformation matrix
  66012. * @param result defines the Vector3 where to store the result
  66013. */
  66014. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66015. /**
  66016. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  66017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66018. * @param vector defines the Vector3 to transform
  66019. * @param transformation defines the transformation matrix
  66020. * @returns the new Vector3
  66021. */
  66022. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66023. /**
  66024. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66025. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66026. * @param vector defines the Vector3 to transform
  66027. * @param transformation defines the transformation matrix
  66028. * @param result defines the Vector3 where to store the result
  66029. */
  66030. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66031. /**
  66032. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66034. * @param x define the x coordinate of the source vector
  66035. * @param y define the y coordinate of the source vector
  66036. * @param z define the z coordinate of the source vector
  66037. * @param transformation defines the transformation matrix
  66038. * @param result defines the Vector3 where to store the result
  66039. */
  66040. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66041. /**
  66042. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66043. * @param value1 defines the first control point
  66044. * @param value2 defines the second control point
  66045. * @param value3 defines the third control point
  66046. * @param value4 defines the fourth control point
  66047. * @param amount defines the amount on the spline to use
  66048. * @returns the new Vector3
  66049. */
  66050. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66051. /**
  66052. * 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"
  66053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66055. * @param value defines the current value
  66056. * @param min defines the lower range value
  66057. * @param max defines the upper range value
  66058. * @returns the new Vector3
  66059. */
  66060. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66061. /**
  66062. * 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"
  66063. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66064. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66065. * @param value defines the current value
  66066. * @param min defines the lower range value
  66067. * @param max defines the upper range value
  66068. * @param result defines the Vector3 where to store the result
  66069. */
  66070. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66071. /**
  66072. * Checks if a given vector is inside a specific range
  66073. * @param v defines the vector to test
  66074. * @param min defines the minimum range
  66075. * @param max defines the maximum range
  66076. */
  66077. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66078. /**
  66079. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66080. * @param value1 defines the first control point
  66081. * @param tangent1 defines the first tangent vector
  66082. * @param value2 defines the second control point
  66083. * @param tangent2 defines the second tangent vector
  66084. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66085. * @returns the new Vector3
  66086. */
  66087. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66088. /**
  66089. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66090. * @param start defines the start value
  66091. * @param end defines the end value
  66092. * @param amount max defines amount between both (between 0 and 1)
  66093. * @returns the new Vector3
  66094. */
  66095. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66096. /**
  66097. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66098. * @param start defines the start value
  66099. * @param end defines the end value
  66100. * @param amount max defines amount between both (between 0 and 1)
  66101. * @param result defines the Vector3 where to store the result
  66102. */
  66103. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66104. /**
  66105. * Returns the dot product (float) between the vectors "left" and "right"
  66106. * @param left defines the left operand
  66107. * @param right defines the right operand
  66108. * @returns the dot product
  66109. */
  66110. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66111. /**
  66112. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66113. * The cross product is then orthogonal to both "left" and "right"
  66114. * @param left defines the left operand
  66115. * @param right defines the right operand
  66116. * @returns the cross product
  66117. */
  66118. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66119. /**
  66120. * Sets the given vector "result" with the cross product of "left" and "right"
  66121. * The cross product is then orthogonal to both "left" and "right"
  66122. * @param left defines the left operand
  66123. * @param right defines the right operand
  66124. * @param result defines the Vector3 where to store the result
  66125. */
  66126. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66127. /**
  66128. * Returns a new Vector3 as the normalization of the given vector
  66129. * @param vector defines the Vector3 to normalize
  66130. * @returns the new Vector3
  66131. */
  66132. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66133. /**
  66134. * Sets the given vector "result" with the normalization of the given first vector
  66135. * @param vector defines the Vector3 to normalize
  66136. * @param result defines the Vector3 where to store the result
  66137. */
  66138. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66139. /**
  66140. * Project a Vector3 onto screen space
  66141. * @param vector defines the Vector3 to project
  66142. * @param world defines the world matrix to use
  66143. * @param transform defines the transform (view x projection) matrix to use
  66144. * @param viewport defines the screen viewport to use
  66145. * @returns the new Vector3
  66146. */
  66147. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66148. /** @hidden */
  66149. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66150. /**
  66151. * Unproject from screen space to object space
  66152. * @param source defines the screen space Vector3 to use
  66153. * @param viewportWidth defines the current width of the viewport
  66154. * @param viewportHeight defines the current height of the viewport
  66155. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66156. * @param transform defines the transform (view x projection) matrix to use
  66157. * @returns the new Vector3
  66158. */
  66159. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66160. /**
  66161. * Unproject from screen space to object space
  66162. * @param source defines the screen space Vector3 to use
  66163. * @param viewportWidth defines the current width of the viewport
  66164. * @param viewportHeight defines the current height of the viewport
  66165. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66166. * @param view defines the view matrix to use
  66167. * @param projection defines the projection matrix to use
  66168. * @returns the new Vector3
  66169. */
  66170. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66171. /**
  66172. * Unproject from screen space to object space
  66173. * @param source defines the screen space Vector3 to use
  66174. * @param viewportWidth defines the current width of the viewport
  66175. * @param viewportHeight defines the current height of the viewport
  66176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66177. * @param view defines the view matrix to use
  66178. * @param projection defines the projection matrix to use
  66179. * @param result defines the Vector3 where to store the result
  66180. */
  66181. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66182. /**
  66183. * Unproject from screen space to object space
  66184. * @param sourceX defines the screen space x coordinate to use
  66185. * @param sourceY defines the screen space y coordinate to use
  66186. * @param sourceZ defines the screen space z coordinate to use
  66187. * @param viewportWidth defines the current width of the viewport
  66188. * @param viewportHeight defines the current height of the viewport
  66189. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66190. * @param view defines the view matrix to use
  66191. * @param projection defines the projection matrix to use
  66192. * @param result defines the Vector3 where to store the result
  66193. */
  66194. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66195. /**
  66196. * Gets the minimal coordinate values between two Vector3
  66197. * @param left defines the first operand
  66198. * @param right defines the second operand
  66199. * @returns the new Vector3
  66200. */
  66201. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66202. /**
  66203. * Gets the maximal coordinate values between two Vector3
  66204. * @param left defines the first operand
  66205. * @param right defines the second operand
  66206. * @returns the new Vector3
  66207. */
  66208. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66209. /**
  66210. * Returns the distance between the vectors "value1" and "value2"
  66211. * @param value1 defines the first operand
  66212. * @param value2 defines the second operand
  66213. * @returns the distance
  66214. */
  66215. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66216. /**
  66217. * Returns the squared distance between the vectors "value1" and "value2"
  66218. * @param value1 defines the first operand
  66219. * @param value2 defines the second operand
  66220. * @returns the squared distance
  66221. */
  66222. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66223. /**
  66224. * Returns a new Vector3 located at the center between "value1" and "value2"
  66225. * @param value1 defines the first operand
  66226. * @param value2 defines the second operand
  66227. * @returns the new Vector3
  66228. */
  66229. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66230. /**
  66231. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66232. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66233. * to something in order to rotate it from its local system to the given target system
  66234. * Note: axis1, axis2 and axis3 are normalized during this operation
  66235. * @param axis1 defines the first axis
  66236. * @param axis2 defines the second axis
  66237. * @param axis3 defines the third axis
  66238. * @returns a new Vector3
  66239. */
  66240. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66241. /**
  66242. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66243. * @param axis1 defines the first axis
  66244. * @param axis2 defines the second axis
  66245. * @param axis3 defines the third axis
  66246. * @param ref defines the Vector3 where to store the result
  66247. */
  66248. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66249. }
  66250. /**
  66251. * Vector4 class created for EulerAngle class conversion to Quaternion
  66252. */
  66253. export class Vector4 {
  66254. /** x value of the vector */
  66255. x: number;
  66256. /** y value of the vector */
  66257. y: number;
  66258. /** z value of the vector */
  66259. z: number;
  66260. /** w value of the vector */
  66261. w: number;
  66262. /**
  66263. * Creates a Vector4 object from the given floats.
  66264. * @param x x value of the vector
  66265. * @param y y value of the vector
  66266. * @param z z value of the vector
  66267. * @param w w value of the vector
  66268. */
  66269. constructor(
  66270. /** x value of the vector */
  66271. x: number,
  66272. /** y value of the vector */
  66273. y: number,
  66274. /** z value of the vector */
  66275. z: number,
  66276. /** w value of the vector */
  66277. w: number);
  66278. /**
  66279. * Returns the string with the Vector4 coordinates.
  66280. * @returns a string containing all the vector values
  66281. */
  66282. toString(): string;
  66283. /**
  66284. * Returns the string "Vector4".
  66285. * @returns "Vector4"
  66286. */
  66287. getClassName(): string;
  66288. /**
  66289. * Returns the Vector4 hash code.
  66290. * @returns a unique hash code
  66291. */
  66292. getHashCode(): number;
  66293. /**
  66294. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66295. * @returns the resulting array
  66296. */
  66297. asArray(): number[];
  66298. /**
  66299. * Populates the given array from the given index with the Vector4 coordinates.
  66300. * @param array array to populate
  66301. * @param index index of the array to start at (default: 0)
  66302. * @returns the Vector4.
  66303. */
  66304. toArray(array: FloatArray, index?: number): Vector4;
  66305. /**
  66306. * Adds the given vector to the current Vector4.
  66307. * @param otherVector the vector to add
  66308. * @returns the updated Vector4.
  66309. */
  66310. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66311. /**
  66312. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66313. * @param otherVector the vector to add
  66314. * @returns the resulting vector
  66315. */
  66316. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66317. /**
  66318. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66319. * @param otherVector the vector to add
  66320. * @param result the vector to store the result
  66321. * @returns the current Vector4.
  66322. */
  66323. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66324. /**
  66325. * Subtract in place the given vector from the current Vector4.
  66326. * @param otherVector the vector to subtract
  66327. * @returns the updated Vector4.
  66328. */
  66329. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66330. /**
  66331. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66332. * @param otherVector the vector to add
  66333. * @returns the new vector with the result
  66334. */
  66335. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66336. /**
  66337. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66338. * @param otherVector the vector to subtract
  66339. * @param result the vector to store the result
  66340. * @returns the current Vector4.
  66341. */
  66342. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66343. /**
  66344. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66345. */
  66346. /**
  66347. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66348. * @param x value to subtract
  66349. * @param y value to subtract
  66350. * @param z value to subtract
  66351. * @param w value to subtract
  66352. * @returns new vector containing the result
  66353. */
  66354. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66355. /**
  66356. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66357. * @param x value to subtract
  66358. * @param y value to subtract
  66359. * @param z value to subtract
  66360. * @param w value to subtract
  66361. * @param result the vector to store the result in
  66362. * @returns the current Vector4.
  66363. */
  66364. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66365. /**
  66366. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66367. * @returns a new vector with the negated values
  66368. */
  66369. negate(): Vector4;
  66370. /**
  66371. * Multiplies the current Vector4 coordinates by scale (float).
  66372. * @param scale the number to scale with
  66373. * @returns the updated Vector4.
  66374. */
  66375. scaleInPlace(scale: number): Vector4;
  66376. /**
  66377. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66378. * @param scale the number to scale with
  66379. * @returns a new vector with the result
  66380. */
  66381. scale(scale: number): Vector4;
  66382. /**
  66383. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66384. * @param scale the number to scale with
  66385. * @param result a vector to store the result in
  66386. * @returns the current Vector4.
  66387. */
  66388. scaleToRef(scale: number, result: Vector4): Vector4;
  66389. /**
  66390. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66391. * @param scale defines the scale factor
  66392. * @param result defines the Vector4 object where to store the result
  66393. * @returns the unmodified current Vector4
  66394. */
  66395. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66396. /**
  66397. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66398. * @param otherVector the vector to compare against
  66399. * @returns true if they are equal
  66400. */
  66401. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66402. /**
  66403. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66404. * @param otherVector vector to compare against
  66405. * @param epsilon (Default: very small number)
  66406. * @returns true if they are equal
  66407. */
  66408. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66409. /**
  66410. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66411. * @param x x value to compare against
  66412. * @param y y value to compare against
  66413. * @param z z value to compare against
  66414. * @param w w value to compare against
  66415. * @returns true if equal
  66416. */
  66417. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66418. /**
  66419. * Multiplies in place the current Vector4 by the given one.
  66420. * @param otherVector vector to multiple with
  66421. * @returns the updated Vector4.
  66422. */
  66423. multiplyInPlace(otherVector: Vector4): Vector4;
  66424. /**
  66425. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66426. * @param otherVector vector to multiple with
  66427. * @returns resulting new vector
  66428. */
  66429. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66430. /**
  66431. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66432. * @param otherVector vector to multiple with
  66433. * @param result vector to store the result
  66434. * @returns the current Vector4.
  66435. */
  66436. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66437. /**
  66438. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66439. * @param x x value multiply with
  66440. * @param y y value multiply with
  66441. * @param z z value multiply with
  66442. * @param w w value multiply with
  66443. * @returns resulting new vector
  66444. */
  66445. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66446. /**
  66447. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66448. * @param otherVector vector to devide with
  66449. * @returns resulting new vector
  66450. */
  66451. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66452. /**
  66453. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66454. * @param otherVector vector to devide with
  66455. * @param result vector to store the result
  66456. * @returns the current Vector4.
  66457. */
  66458. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66459. /**
  66460. * Divides the current Vector3 coordinates by the given ones.
  66461. * @param otherVector vector to devide with
  66462. * @returns the updated Vector3.
  66463. */
  66464. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66465. /**
  66466. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66467. * @param other defines the second operand
  66468. * @returns the current updated Vector4
  66469. */
  66470. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66471. /**
  66472. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66473. * @param other defines the second operand
  66474. * @returns the current updated Vector4
  66475. */
  66476. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66477. /**
  66478. * Gets a new Vector4 from current Vector4 floored values
  66479. * @returns a new Vector4
  66480. */
  66481. floor(): Vector4;
  66482. /**
  66483. * Gets a new Vector4 from current Vector3 floored values
  66484. * @returns a new Vector4
  66485. */
  66486. fract(): Vector4;
  66487. /**
  66488. * Returns the Vector4 length (float).
  66489. * @returns the length
  66490. */
  66491. length(): number;
  66492. /**
  66493. * Returns the Vector4 squared length (float).
  66494. * @returns the length squared
  66495. */
  66496. lengthSquared(): number;
  66497. /**
  66498. * Normalizes in place the Vector4.
  66499. * @returns the updated Vector4.
  66500. */
  66501. normalize(): Vector4;
  66502. /**
  66503. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66504. * @returns this converted to a new vector3
  66505. */
  66506. toVector3(): Vector3;
  66507. /**
  66508. * Returns a new Vector4 copied from the current one.
  66509. * @returns the new cloned vector
  66510. */
  66511. clone(): Vector4;
  66512. /**
  66513. * Updates the current Vector4 with the given one coordinates.
  66514. * @param source the source vector to copy from
  66515. * @returns the updated Vector4.
  66516. */
  66517. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66518. /**
  66519. * Updates the current Vector4 coordinates with the given floats.
  66520. * @param x float to copy from
  66521. * @param y float to copy from
  66522. * @param z float to copy from
  66523. * @param w float to copy from
  66524. * @returns the updated Vector4.
  66525. */
  66526. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66527. /**
  66528. * Updates the current Vector4 coordinates with the given floats.
  66529. * @param x float to set from
  66530. * @param y float to set from
  66531. * @param z float to set from
  66532. * @param w float to set from
  66533. * @returns the updated Vector4.
  66534. */
  66535. set(x: number, y: number, z: number, w: number): Vector4;
  66536. /**
  66537. * Copies the given float to the current Vector3 coordinates
  66538. * @param v defines the x, y, z and w coordinates of the operand
  66539. * @returns the current updated Vector3
  66540. */
  66541. setAll(v: number): Vector4;
  66542. /**
  66543. * Returns a new Vector4 set from the starting index of the given array.
  66544. * @param array the array to pull values from
  66545. * @param offset the offset into the array to start at
  66546. * @returns the new vector
  66547. */
  66548. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66549. /**
  66550. * Updates the given vector "result" from the starting index of the given array.
  66551. * @param array the array to pull values from
  66552. * @param offset the offset into the array to start at
  66553. * @param result the vector to store the result in
  66554. */
  66555. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66556. /**
  66557. * Updates the given vector "result" from the starting index of the given Float32Array.
  66558. * @param array the array to pull values from
  66559. * @param offset the offset into the array to start at
  66560. * @param result the vector to store the result in
  66561. */
  66562. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66563. /**
  66564. * Updates the given vector "result" coordinates from the given floats.
  66565. * @param x float to set from
  66566. * @param y float to set from
  66567. * @param z float to set from
  66568. * @param w float to set from
  66569. * @param result the vector to the floats in
  66570. */
  66571. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66572. /**
  66573. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66574. * @returns the new vector
  66575. */
  66576. static Zero(): Vector4;
  66577. /**
  66578. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66579. * @returns the new vector
  66580. */
  66581. static One(): Vector4;
  66582. /**
  66583. * Returns a new normalized Vector4 from the given one.
  66584. * @param vector the vector to normalize
  66585. * @returns the vector
  66586. */
  66587. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66588. /**
  66589. * Updates the given vector "result" from the normalization of the given one.
  66590. * @param vector the vector to normalize
  66591. * @param result the vector to store the result in
  66592. */
  66593. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66594. /**
  66595. * Returns a vector with the minimum values from the left and right vectors
  66596. * @param left left vector to minimize
  66597. * @param right right vector to minimize
  66598. * @returns a new vector with the minimum of the left and right vector values
  66599. */
  66600. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66601. /**
  66602. * Returns a vector with the maximum values from the left and right vectors
  66603. * @param left left vector to maximize
  66604. * @param right right vector to maximize
  66605. * @returns a new vector with the maximum of the left and right vector values
  66606. */
  66607. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66608. /**
  66609. * Returns the distance (float) between the vectors "value1" and "value2".
  66610. * @param value1 value to calulate the distance between
  66611. * @param value2 value to calulate the distance between
  66612. * @return the distance between the two vectors
  66613. */
  66614. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66615. /**
  66616. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66617. * @param value1 value to calulate the distance between
  66618. * @param value2 value to calulate the distance between
  66619. * @return the distance between the two vectors squared
  66620. */
  66621. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66622. /**
  66623. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66624. * @param value1 value to calulate the center between
  66625. * @param value2 value to calulate the center between
  66626. * @return the center between the two vectors
  66627. */
  66628. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66629. /**
  66630. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66631. * This methods computes transformed normalized direction vectors only.
  66632. * @param vector the vector to transform
  66633. * @param transformation the transformation matrix to apply
  66634. * @returns the new vector
  66635. */
  66636. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66637. /**
  66638. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66639. * This methods computes transformed normalized direction vectors only.
  66640. * @param vector the vector to transform
  66641. * @param transformation the transformation matrix to apply
  66642. * @param result the vector to store the result in
  66643. */
  66644. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66645. /**
  66646. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66647. * This methods computes transformed normalized direction vectors only.
  66648. * @param x value to transform
  66649. * @param y value to transform
  66650. * @param z value to transform
  66651. * @param w value to transform
  66652. * @param transformation the transformation matrix to apply
  66653. * @param result the vector to store the results in
  66654. */
  66655. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66656. /**
  66657. * Creates a new Vector4 from a Vector3
  66658. * @param source defines the source data
  66659. * @param w defines the 4th component (default is 0)
  66660. * @returns a new Vector4
  66661. */
  66662. static FromVector3(source: Vector3, w?: number): Vector4;
  66663. }
  66664. /**
  66665. * Class used to store quaternion data
  66666. * @see https://en.wikipedia.org/wiki/Quaternion
  66667. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66668. */
  66669. export class Quaternion {
  66670. /** defines the first component (0 by default) */
  66671. x: number;
  66672. /** defines the second component (0 by default) */
  66673. y: number;
  66674. /** defines the third component (0 by default) */
  66675. z: number;
  66676. /** defines the fourth component (1.0 by default) */
  66677. w: number;
  66678. /**
  66679. * Creates a new Quaternion from the given floats
  66680. * @param x defines the first component (0 by default)
  66681. * @param y defines the second component (0 by default)
  66682. * @param z defines the third component (0 by default)
  66683. * @param w defines the fourth component (1.0 by default)
  66684. */
  66685. constructor(
  66686. /** defines the first component (0 by default) */
  66687. x?: number,
  66688. /** defines the second component (0 by default) */
  66689. y?: number,
  66690. /** defines the third component (0 by default) */
  66691. z?: number,
  66692. /** defines the fourth component (1.0 by default) */
  66693. w?: number);
  66694. /**
  66695. * Gets a string representation for the current quaternion
  66696. * @returns a string with the Quaternion coordinates
  66697. */
  66698. toString(): string;
  66699. /**
  66700. * Gets the class name of the quaternion
  66701. * @returns the string "Quaternion"
  66702. */
  66703. getClassName(): string;
  66704. /**
  66705. * Gets a hash code for this quaternion
  66706. * @returns the quaternion hash code
  66707. */
  66708. getHashCode(): number;
  66709. /**
  66710. * Copy the quaternion to an array
  66711. * @returns a new array populated with 4 elements from the quaternion coordinates
  66712. */
  66713. asArray(): number[];
  66714. /**
  66715. * Check if two quaternions are equals
  66716. * @param otherQuaternion defines the second operand
  66717. * @return true if the current quaternion and the given one coordinates are strictly equals
  66718. */
  66719. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66720. /**
  66721. * Clone the current quaternion
  66722. * @returns a new quaternion copied from the current one
  66723. */
  66724. clone(): Quaternion;
  66725. /**
  66726. * Copy a quaternion to the current one
  66727. * @param other defines the other quaternion
  66728. * @returns the updated current quaternion
  66729. */
  66730. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66731. /**
  66732. * Updates the current quaternion with the given float coordinates
  66733. * @param x defines the x coordinate
  66734. * @param y defines the y coordinate
  66735. * @param z defines the z coordinate
  66736. * @param w defines the w coordinate
  66737. * @returns the updated current quaternion
  66738. */
  66739. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66740. /**
  66741. * Updates the current quaternion from the given float coordinates
  66742. * @param x defines the x coordinate
  66743. * @param y defines the y coordinate
  66744. * @param z defines the z coordinate
  66745. * @param w defines the w coordinate
  66746. * @returns the updated current quaternion
  66747. */
  66748. set(x: number, y: number, z: number, w: number): Quaternion;
  66749. /**
  66750. * Adds two quaternions
  66751. * @param other defines the second operand
  66752. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66753. */
  66754. add(other: DeepImmutable<Quaternion>): Quaternion;
  66755. /**
  66756. * Add a quaternion to the current one
  66757. * @param other defines the quaternion to add
  66758. * @returns the current quaternion
  66759. */
  66760. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66761. /**
  66762. * Subtract two quaternions
  66763. * @param other defines the second operand
  66764. * @returns a new quaternion as the subtraction result of the given one from the current one
  66765. */
  66766. subtract(other: Quaternion): Quaternion;
  66767. /**
  66768. * Multiplies the current quaternion by a scale factor
  66769. * @param value defines the scale factor
  66770. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66771. */
  66772. scale(value: number): Quaternion;
  66773. /**
  66774. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66775. * @param scale defines the scale factor
  66776. * @param result defines the Quaternion object where to store the result
  66777. * @returns the unmodified current quaternion
  66778. */
  66779. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66780. /**
  66781. * Multiplies in place the current quaternion by a scale factor
  66782. * @param value defines the scale factor
  66783. * @returns the current modified quaternion
  66784. */
  66785. scaleInPlace(value: number): Quaternion;
  66786. /**
  66787. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66788. * @param scale defines the scale factor
  66789. * @param result defines the Quaternion object where to store the result
  66790. * @returns the unmodified current quaternion
  66791. */
  66792. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66793. /**
  66794. * Multiplies two quaternions
  66795. * @param q1 defines the second operand
  66796. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66797. */
  66798. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66799. /**
  66800. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66801. * @param q1 defines the second operand
  66802. * @param result defines the target quaternion
  66803. * @returns the current quaternion
  66804. */
  66805. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66806. /**
  66807. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66808. * @param q1 defines the second operand
  66809. * @returns the currentupdated quaternion
  66810. */
  66811. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66812. /**
  66813. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66814. * @param ref defines the target quaternion
  66815. * @returns the current quaternion
  66816. */
  66817. conjugateToRef(ref: Quaternion): Quaternion;
  66818. /**
  66819. * Conjugates in place (1-q) the current quaternion
  66820. * @returns the current updated quaternion
  66821. */
  66822. conjugateInPlace(): Quaternion;
  66823. /**
  66824. * Conjugates in place (1-q) the current quaternion
  66825. * @returns a new quaternion
  66826. */
  66827. conjugate(): Quaternion;
  66828. /**
  66829. * Gets length of current quaternion
  66830. * @returns the quaternion length (float)
  66831. */
  66832. length(): number;
  66833. /**
  66834. * Normalize in place the current quaternion
  66835. * @returns the current updated quaternion
  66836. */
  66837. normalize(): Quaternion;
  66838. /**
  66839. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66840. * @param order is a reserved parameter and is ignore for now
  66841. * @returns a new Vector3 containing the Euler angles
  66842. */
  66843. toEulerAngles(order?: string): Vector3;
  66844. /**
  66845. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  66846. * @param result defines the vector which will be filled with the Euler angles
  66847. * @param order is a reserved parameter and is ignore for now
  66848. * @returns the current unchanged quaternion
  66849. */
  66850. toEulerAnglesToRef(result: Vector3): Quaternion;
  66851. /**
  66852. * Updates the given rotation matrix with the current quaternion values
  66853. * @param result defines the target matrix
  66854. * @returns the current unchanged quaternion
  66855. */
  66856. toRotationMatrix(result: Matrix): Quaternion;
  66857. /**
  66858. * Updates the current quaternion from the given rotation matrix values
  66859. * @param matrix defines the source matrix
  66860. * @returns the current updated quaternion
  66861. */
  66862. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66863. /**
  66864. * Creates a new quaternion from a rotation matrix
  66865. * @param matrix defines the source matrix
  66866. * @returns a new quaternion created from the given rotation matrix values
  66867. */
  66868. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66869. /**
  66870. * Updates the given quaternion with the given rotation matrix values
  66871. * @param matrix defines the source matrix
  66872. * @param result defines the target quaternion
  66873. */
  66874. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  66875. /**
  66876. * Returns the dot product (float) between the quaternions "left" and "right"
  66877. * @param left defines the left operand
  66878. * @param right defines the right operand
  66879. * @returns the dot product
  66880. */
  66881. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  66882. /**
  66883. * Checks if the two quaternions are close to each other
  66884. * @param quat0 defines the first quaternion to check
  66885. * @param quat1 defines the second quaternion to check
  66886. * @returns true if the two quaternions are close to each other
  66887. */
  66888. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  66889. /**
  66890. * Creates an empty quaternion
  66891. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  66892. */
  66893. static Zero(): Quaternion;
  66894. /**
  66895. * Inverse a given quaternion
  66896. * @param q defines the source quaternion
  66897. * @returns a new quaternion as the inverted current quaternion
  66898. */
  66899. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  66900. /**
  66901. * Inverse a given quaternion
  66902. * @param q defines the source quaternion
  66903. * @param result the quaternion the result will be stored in
  66904. * @returns the result quaternion
  66905. */
  66906. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  66907. /**
  66908. * Creates an identity quaternion
  66909. * @returns the identity quaternion
  66910. */
  66911. static Identity(): Quaternion;
  66912. /**
  66913. * Gets a boolean indicating if the given quaternion is identity
  66914. * @param quaternion defines the quaternion to check
  66915. * @returns true if the quaternion is identity
  66916. */
  66917. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  66918. /**
  66919. * Creates a quaternion from a rotation around an axis
  66920. * @param axis defines the axis to use
  66921. * @param angle defines the angle to use
  66922. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  66923. */
  66924. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  66925. /**
  66926. * Creates a rotation around an axis and stores it into the given quaternion
  66927. * @param axis defines the axis to use
  66928. * @param angle defines the angle to use
  66929. * @param result defines the target quaternion
  66930. * @returns the target quaternion
  66931. */
  66932. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  66933. /**
  66934. * Creates a new quaternion from data stored into an array
  66935. * @param array defines the data source
  66936. * @param offset defines the offset in the source array where the data starts
  66937. * @returns a new quaternion
  66938. */
  66939. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  66940. /**
  66941. * Create a quaternion from Euler rotation angles
  66942. * @param x Pitch
  66943. * @param y Yaw
  66944. * @param z Roll
  66945. * @returns the new Quaternion
  66946. */
  66947. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  66948. /**
  66949. * Updates a quaternion from Euler rotation angles
  66950. * @param x Pitch
  66951. * @param y Yaw
  66952. * @param z Roll
  66953. * @param result the quaternion to store the result
  66954. * @returns the updated quaternion
  66955. */
  66956. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  66957. /**
  66958. * Create a quaternion from Euler rotation vector
  66959. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66960. * @returns the new Quaternion
  66961. */
  66962. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  66963. /**
  66964. * Updates a quaternion from Euler rotation vector
  66965. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66966. * @param result the quaternion to store the result
  66967. * @returns the updated quaternion
  66968. */
  66969. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  66970. /**
  66971. * Creates a new quaternion from the given Euler float angles (y, x, z)
  66972. * @param yaw defines the rotation around Y axis
  66973. * @param pitch defines the rotation around X axis
  66974. * @param roll defines the rotation around Z axis
  66975. * @returns the new quaternion
  66976. */
  66977. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  66978. /**
  66979. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  66980. * @param yaw defines the rotation around Y axis
  66981. * @param pitch defines the rotation around X axis
  66982. * @param roll defines the rotation around Z axis
  66983. * @param result defines the target quaternion
  66984. */
  66985. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  66986. /**
  66987. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  66988. * @param alpha defines the rotation around first axis
  66989. * @param beta defines the rotation around second axis
  66990. * @param gamma defines the rotation around third axis
  66991. * @returns the new quaternion
  66992. */
  66993. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  66994. /**
  66995. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  66996. * @param alpha defines the rotation around first axis
  66997. * @param beta defines the rotation around second axis
  66998. * @param gamma defines the rotation around third axis
  66999. * @param result defines the target quaternion
  67000. */
  67001. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  67002. /**
  67003. * 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)
  67004. * @param axis1 defines the first axis
  67005. * @param axis2 defines the second axis
  67006. * @param axis3 defines the third axis
  67007. * @returns the new quaternion
  67008. */
  67009. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  67010. /**
  67011. * 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
  67012. * @param axis1 defines the first axis
  67013. * @param axis2 defines the second axis
  67014. * @param axis3 defines the third axis
  67015. * @param ref defines the target quaternion
  67016. */
  67017. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67018. /**
  67019. * Interpolates between two quaternions
  67020. * @param left defines first quaternion
  67021. * @param right defines second quaternion
  67022. * @param amount defines the gradient to use
  67023. * @returns the new interpolated quaternion
  67024. */
  67025. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67026. /**
  67027. * Interpolates between two quaternions and stores it into a target quaternion
  67028. * @param left defines first quaternion
  67029. * @param right defines second quaternion
  67030. * @param amount defines the gradient to use
  67031. * @param result defines the target quaternion
  67032. */
  67033. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67034. /**
  67035. * Interpolate between two quaternions using Hermite interpolation
  67036. * @param value1 defines first quaternion
  67037. * @param tangent1 defines the incoming tangent
  67038. * @param value2 defines second quaternion
  67039. * @param tangent2 defines the outgoing tangent
  67040. * @param amount defines the target quaternion
  67041. * @returns the new interpolated quaternion
  67042. */
  67043. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67044. }
  67045. /**
  67046. * Class used to store matrix data (4x4)
  67047. */
  67048. export class Matrix {
  67049. private static _updateFlagSeed;
  67050. private static _identityReadOnly;
  67051. private _isIdentity;
  67052. private _isIdentityDirty;
  67053. private _isIdentity3x2;
  67054. private _isIdentity3x2Dirty;
  67055. /**
  67056. * Gets the update flag of the matrix which is an unique number for the matrix.
  67057. * It will be incremented every time the matrix data change.
  67058. * You can use it to speed the comparison between two versions of the same matrix.
  67059. */
  67060. updateFlag: number;
  67061. private readonly _m;
  67062. /**
  67063. * Gets the internal data of the matrix
  67064. */
  67065. readonly m: DeepImmutable<Float32Array>;
  67066. /** @hidden */
  67067. _markAsUpdated(): void;
  67068. /** @hidden */
  67069. private _updateIdentityStatus;
  67070. /**
  67071. * Creates an empty matrix (filled with zeros)
  67072. */
  67073. constructor();
  67074. /**
  67075. * Check if the current matrix is identity
  67076. * @returns true is the matrix is the identity matrix
  67077. */
  67078. isIdentity(): boolean;
  67079. /**
  67080. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67081. * @returns true is the matrix is the identity matrix
  67082. */
  67083. isIdentityAs3x2(): boolean;
  67084. /**
  67085. * Gets the determinant of the matrix
  67086. * @returns the matrix determinant
  67087. */
  67088. determinant(): number;
  67089. /**
  67090. * Returns the matrix as a Float32Array
  67091. * @returns the matrix underlying array
  67092. */
  67093. toArray(): DeepImmutable<Float32Array>;
  67094. /**
  67095. * Returns the matrix as a Float32Array
  67096. * @returns the matrix underlying array.
  67097. */
  67098. asArray(): DeepImmutable<Float32Array>;
  67099. /**
  67100. * Inverts the current matrix in place
  67101. * @returns the current inverted matrix
  67102. */
  67103. invert(): Matrix;
  67104. /**
  67105. * Sets all the matrix elements to zero
  67106. * @returns the current matrix
  67107. */
  67108. reset(): Matrix;
  67109. /**
  67110. * Adds the current matrix with a second one
  67111. * @param other defines the matrix to add
  67112. * @returns a new matrix as the addition of the current matrix and the given one
  67113. */
  67114. add(other: DeepImmutable<Matrix>): Matrix;
  67115. /**
  67116. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67117. * @param other defines the matrix to add
  67118. * @param result defines the target matrix
  67119. * @returns the current matrix
  67120. */
  67121. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67122. /**
  67123. * Adds in place the given matrix to the current matrix
  67124. * @param other defines the second operand
  67125. * @returns the current updated matrix
  67126. */
  67127. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67128. /**
  67129. * Sets the given matrix to the current inverted Matrix
  67130. * @param other defines the target matrix
  67131. * @returns the unmodified current matrix
  67132. */
  67133. invertToRef(other: Matrix): Matrix;
  67134. /**
  67135. * add a value at the specified position in the current Matrix
  67136. * @param index the index of the value within the matrix. between 0 and 15.
  67137. * @param value the value to be added
  67138. * @returns the current updated matrix
  67139. */
  67140. addAtIndex(index: number, value: number): Matrix;
  67141. /**
  67142. * mutiply the specified position in the current Matrix by a value
  67143. * @param index the index of the value within the matrix. between 0 and 15.
  67144. * @param value the value to be added
  67145. * @returns the current updated matrix
  67146. */
  67147. multiplyAtIndex(index: number, value: number): Matrix;
  67148. /**
  67149. * Inserts the translation vector (using 3 floats) in the current matrix
  67150. * @param x defines the 1st component of the translation
  67151. * @param y defines the 2nd component of the translation
  67152. * @param z defines the 3rd component of the translation
  67153. * @returns the current updated matrix
  67154. */
  67155. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67156. /**
  67157. * Adds the translation vector (using 3 floats) in the current matrix
  67158. * @param x defines the 1st component of the translation
  67159. * @param y defines the 2nd component of the translation
  67160. * @param z defines the 3rd component of the translation
  67161. * @returns the current updated matrix
  67162. */
  67163. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67164. /**
  67165. * Inserts the translation vector in the current matrix
  67166. * @param vector3 defines the translation to insert
  67167. * @returns the current updated matrix
  67168. */
  67169. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67170. /**
  67171. * Gets the translation value of the current matrix
  67172. * @returns a new Vector3 as the extracted translation from the matrix
  67173. */
  67174. getTranslation(): Vector3;
  67175. /**
  67176. * Fill a Vector3 with the extracted translation from the matrix
  67177. * @param result defines the Vector3 where to store the translation
  67178. * @returns the current matrix
  67179. */
  67180. getTranslationToRef(result: Vector3): Matrix;
  67181. /**
  67182. * Remove rotation and scaling part from the matrix
  67183. * @returns the updated matrix
  67184. */
  67185. removeRotationAndScaling(): Matrix;
  67186. /**
  67187. * Multiply two matrices
  67188. * @param other defines the second operand
  67189. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67190. */
  67191. multiply(other: DeepImmutable<Matrix>): Matrix;
  67192. /**
  67193. * Copy the current matrix from the given one
  67194. * @param other defines the source matrix
  67195. * @returns the current updated matrix
  67196. */
  67197. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67198. /**
  67199. * Populates the given array from the starting index with the current matrix values
  67200. * @param array defines the target array
  67201. * @param offset defines the offset in the target array where to start storing values
  67202. * @returns the current matrix
  67203. */
  67204. copyToArray(array: Float32Array, offset?: number): Matrix;
  67205. /**
  67206. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67207. * @param other defines the second operand
  67208. * @param result defines the matrix where to store the multiplication
  67209. * @returns the current matrix
  67210. */
  67211. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67212. /**
  67213. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67214. * @param other defines the second operand
  67215. * @param result defines the array where to store the multiplication
  67216. * @param offset defines the offset in the target array where to start storing values
  67217. * @returns the current matrix
  67218. */
  67219. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67220. /**
  67221. * Check equality between this matrix and a second one
  67222. * @param value defines the second matrix to compare
  67223. * @returns true is the current matrix and the given one values are strictly equal
  67224. */
  67225. equals(value: DeepImmutable<Matrix>): boolean;
  67226. /**
  67227. * Clone the current matrix
  67228. * @returns a new matrix from the current matrix
  67229. */
  67230. clone(): Matrix;
  67231. /**
  67232. * Returns the name of the current matrix class
  67233. * @returns the string "Matrix"
  67234. */
  67235. getClassName(): string;
  67236. /**
  67237. * Gets the hash code of the current matrix
  67238. * @returns the hash code
  67239. */
  67240. getHashCode(): number;
  67241. /**
  67242. * Decomposes the current Matrix into a translation, rotation and scaling components
  67243. * @param scale defines the scale vector3 given as a reference to update
  67244. * @param rotation defines the rotation quaternion given as a reference to update
  67245. * @param translation defines the translation vector3 given as a reference to update
  67246. * @returns true if operation was successful
  67247. */
  67248. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67249. /**
  67250. * Gets specific row of the matrix
  67251. * @param index defines the number of the row to get
  67252. * @returns the index-th row of the current matrix as a new Vector4
  67253. */
  67254. getRow(index: number): Nullable<Vector4>;
  67255. /**
  67256. * Sets the index-th row of the current matrix to the vector4 values
  67257. * @param index defines the number of the row to set
  67258. * @param row defines the target vector4
  67259. * @returns the updated current matrix
  67260. */
  67261. setRow(index: number, row: Vector4): Matrix;
  67262. /**
  67263. * Compute the transpose of the matrix
  67264. * @returns the new transposed matrix
  67265. */
  67266. transpose(): Matrix;
  67267. /**
  67268. * Compute the transpose of the matrix and store it in a given matrix
  67269. * @param result defines the target matrix
  67270. * @returns the current matrix
  67271. */
  67272. transposeToRef(result: Matrix): Matrix;
  67273. /**
  67274. * Sets the index-th row of the current matrix with the given 4 x float values
  67275. * @param index defines the row index
  67276. * @param x defines the x component to set
  67277. * @param y defines the y component to set
  67278. * @param z defines the z component to set
  67279. * @param w defines the w component to set
  67280. * @returns the updated current matrix
  67281. */
  67282. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67283. /**
  67284. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67285. * @param scale defines the scale factor
  67286. * @returns a new matrix
  67287. */
  67288. scale(scale: number): Matrix;
  67289. /**
  67290. * Scale the current matrix values by a factor to a given result matrix
  67291. * @param scale defines the scale factor
  67292. * @param result defines the matrix to store the result
  67293. * @returns the current matrix
  67294. */
  67295. scaleToRef(scale: number, result: Matrix): Matrix;
  67296. /**
  67297. * Scale the current matrix values by a factor and add the result to a given matrix
  67298. * @param scale defines the scale factor
  67299. * @param result defines the Matrix to store the result
  67300. * @returns the current matrix
  67301. */
  67302. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67303. /**
  67304. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67305. * @param ref matrix to store the result
  67306. */
  67307. toNormalMatrix(ref: Matrix): void;
  67308. /**
  67309. * Gets only rotation part of the current matrix
  67310. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67311. */
  67312. getRotationMatrix(): Matrix;
  67313. /**
  67314. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67315. * @param result defines the target matrix to store data to
  67316. * @returns the current matrix
  67317. */
  67318. getRotationMatrixToRef(result: Matrix): Matrix;
  67319. /**
  67320. * Toggles model matrix from being right handed to left handed in place and vice versa
  67321. */
  67322. toggleModelMatrixHandInPlace(): void;
  67323. /**
  67324. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67325. */
  67326. toggleProjectionMatrixHandInPlace(): void;
  67327. /**
  67328. * Creates a matrix from an array
  67329. * @param array defines the source array
  67330. * @param offset defines an offset in the source array
  67331. * @returns a new Matrix set from the starting index of the given array
  67332. */
  67333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67334. /**
  67335. * Copy the content of an array into a given matrix
  67336. * @param array defines the source array
  67337. * @param offset defines an offset in the source array
  67338. * @param result defines the target matrix
  67339. */
  67340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67341. /**
  67342. * Stores an array into a matrix after having multiplied each component by a given factor
  67343. * @param array defines the source array
  67344. * @param offset defines the offset in the source array
  67345. * @param scale defines the scaling factor
  67346. * @param result defines the target matrix
  67347. */
  67348. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67349. /**
  67350. * Gets an identity matrix that must not be updated
  67351. */
  67352. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67353. /**
  67354. * Stores a list of values (16) inside a given matrix
  67355. * @param initialM11 defines 1st value of 1st row
  67356. * @param initialM12 defines 2nd value of 1st row
  67357. * @param initialM13 defines 3rd value of 1st row
  67358. * @param initialM14 defines 4th value of 1st row
  67359. * @param initialM21 defines 1st value of 2nd row
  67360. * @param initialM22 defines 2nd value of 2nd row
  67361. * @param initialM23 defines 3rd value of 2nd row
  67362. * @param initialM24 defines 4th value of 2nd row
  67363. * @param initialM31 defines 1st value of 3rd row
  67364. * @param initialM32 defines 2nd value of 3rd row
  67365. * @param initialM33 defines 3rd value of 3rd row
  67366. * @param initialM34 defines 4th value of 3rd row
  67367. * @param initialM41 defines 1st value of 4th row
  67368. * @param initialM42 defines 2nd value of 4th row
  67369. * @param initialM43 defines 3rd value of 4th row
  67370. * @param initialM44 defines 4th value of 4th row
  67371. * @param result defines the target matrix
  67372. */
  67373. 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;
  67374. /**
  67375. * Creates new matrix from a list of values (16)
  67376. * @param initialM11 defines 1st value of 1st row
  67377. * @param initialM12 defines 2nd value of 1st row
  67378. * @param initialM13 defines 3rd value of 1st row
  67379. * @param initialM14 defines 4th value of 1st row
  67380. * @param initialM21 defines 1st value of 2nd row
  67381. * @param initialM22 defines 2nd value of 2nd row
  67382. * @param initialM23 defines 3rd value of 2nd row
  67383. * @param initialM24 defines 4th value of 2nd row
  67384. * @param initialM31 defines 1st value of 3rd row
  67385. * @param initialM32 defines 2nd value of 3rd row
  67386. * @param initialM33 defines 3rd value of 3rd row
  67387. * @param initialM34 defines 4th value of 3rd row
  67388. * @param initialM41 defines 1st value of 4th row
  67389. * @param initialM42 defines 2nd value of 4th row
  67390. * @param initialM43 defines 3rd value of 4th row
  67391. * @param initialM44 defines 4th value of 4th row
  67392. * @returns the new matrix
  67393. */
  67394. 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;
  67395. /**
  67396. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67397. * @param scale defines the scale vector3
  67398. * @param rotation defines the rotation quaternion
  67399. * @param translation defines the translation vector3
  67400. * @returns a new matrix
  67401. */
  67402. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67403. /**
  67404. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67405. * @param scale defines the scale vector3
  67406. * @param rotation defines the rotation quaternion
  67407. * @param translation defines the translation vector3
  67408. * @param result defines the target matrix
  67409. */
  67410. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67411. /**
  67412. * Creates a new identity matrix
  67413. * @returns a new identity matrix
  67414. */
  67415. static Identity(): Matrix;
  67416. /**
  67417. * Creates a new identity matrix and stores the result in a given matrix
  67418. * @param result defines the target matrix
  67419. */
  67420. static IdentityToRef(result: Matrix): void;
  67421. /**
  67422. * Creates a new zero matrix
  67423. * @returns a new zero matrix
  67424. */
  67425. static Zero(): Matrix;
  67426. /**
  67427. * Creates a new rotation matrix for "angle" radians around the X axis
  67428. * @param angle defines the angle (in radians) to use
  67429. * @return the new matrix
  67430. */
  67431. static RotationX(angle: number): Matrix;
  67432. /**
  67433. * Creates a new matrix as the invert of a given matrix
  67434. * @param source defines the source matrix
  67435. * @returns the new matrix
  67436. */
  67437. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67438. /**
  67439. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67440. * @param angle defines the angle (in radians) to use
  67441. * @param result defines the target matrix
  67442. */
  67443. static RotationXToRef(angle: number, result: Matrix): void;
  67444. /**
  67445. * Creates a new rotation matrix for "angle" radians around the Y axis
  67446. * @param angle defines the angle (in radians) to use
  67447. * @return the new matrix
  67448. */
  67449. static RotationY(angle: number): Matrix;
  67450. /**
  67451. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67452. * @param angle defines the angle (in radians) to use
  67453. * @param result defines the target matrix
  67454. */
  67455. static RotationYToRef(angle: number, result: Matrix): void;
  67456. /**
  67457. * Creates a new rotation matrix for "angle" radians around the Z axis
  67458. * @param angle defines the angle (in radians) to use
  67459. * @return the new matrix
  67460. */
  67461. static RotationZ(angle: number): Matrix;
  67462. /**
  67463. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67464. * @param angle defines the angle (in radians) to use
  67465. * @param result defines the target matrix
  67466. */
  67467. static RotationZToRef(angle: number, result: Matrix): void;
  67468. /**
  67469. * Creates a new rotation matrix for "angle" radians around the given axis
  67470. * @param axis defines the axis to use
  67471. * @param angle defines the angle (in radians) to use
  67472. * @return the new matrix
  67473. */
  67474. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67475. /**
  67476. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67477. * @param axis defines the axis to use
  67478. * @param angle defines the angle (in radians) to use
  67479. * @param result defines the target matrix
  67480. */
  67481. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67482. /**
  67483. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67484. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67485. * @param from defines the vector to align
  67486. * @param to defines the vector to align to
  67487. * @param result defines the target matrix
  67488. */
  67489. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67490. /**
  67491. * Creates a rotation matrix
  67492. * @param yaw defines the yaw angle in radians (Y axis)
  67493. * @param pitch defines the pitch angle in radians (X axis)
  67494. * @param roll defines the roll angle in radians (X axis)
  67495. * @returns the new rotation matrix
  67496. */
  67497. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67498. /**
  67499. * Creates a rotation matrix and stores it in a given matrix
  67500. * @param yaw defines the yaw angle in radians (Y axis)
  67501. * @param pitch defines the pitch angle in radians (X axis)
  67502. * @param roll defines the roll angle in radians (X axis)
  67503. * @param result defines the target matrix
  67504. */
  67505. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67506. /**
  67507. * Creates a scaling matrix
  67508. * @param x defines the scale factor on X axis
  67509. * @param y defines the scale factor on Y axis
  67510. * @param z defines the scale factor on Z axis
  67511. * @returns the new matrix
  67512. */
  67513. static Scaling(x: number, y: number, z: number): Matrix;
  67514. /**
  67515. * Creates a scaling matrix and stores it in a given matrix
  67516. * @param x defines the scale factor on X axis
  67517. * @param y defines the scale factor on Y axis
  67518. * @param z defines the scale factor on Z axis
  67519. * @param result defines the target matrix
  67520. */
  67521. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67522. /**
  67523. * Creates a translation matrix
  67524. * @param x defines the translation on X axis
  67525. * @param y defines the translation on Y axis
  67526. * @param z defines the translationon Z axis
  67527. * @returns the new matrix
  67528. */
  67529. static Translation(x: number, y: number, z: number): Matrix;
  67530. /**
  67531. * Creates a translation matrix and stores it in a given matrix
  67532. * @param x defines the translation on X axis
  67533. * @param y defines the translation on Y axis
  67534. * @param z defines the translationon Z axis
  67535. * @param result defines the target matrix
  67536. */
  67537. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67538. /**
  67539. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67540. * @param startValue defines the start value
  67541. * @param endValue defines the end value
  67542. * @param gradient defines the gradient factor
  67543. * @returns the new matrix
  67544. */
  67545. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67546. /**
  67547. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67548. * @param startValue defines the start value
  67549. * @param endValue defines the end value
  67550. * @param gradient defines the gradient factor
  67551. * @param result defines the Matrix object where to store data
  67552. */
  67553. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67554. /**
  67555. * Builds a new matrix whose values are computed by:
  67556. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67557. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67558. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67559. * @param startValue defines the first matrix
  67560. * @param endValue defines the second matrix
  67561. * @param gradient defines the gradient between the two matrices
  67562. * @returns the new matrix
  67563. */
  67564. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67565. /**
  67566. * Update a matrix to values which are computed by:
  67567. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67568. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67569. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67570. * @param startValue defines the first matrix
  67571. * @param endValue defines the second matrix
  67572. * @param gradient defines the gradient between the two matrices
  67573. * @param result defines the target matrix
  67574. */
  67575. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67576. /**
  67577. * 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"
  67578. * This function works in left handed mode
  67579. * @param eye defines the final position of the entity
  67580. * @param target defines where the entity should look at
  67581. * @param up defines the up vector for the entity
  67582. * @returns the new matrix
  67583. */
  67584. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67585. /**
  67586. * 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".
  67587. * This function works in left handed mode
  67588. * @param eye defines the final position of the entity
  67589. * @param target defines where the entity should look at
  67590. * @param up defines the up vector for the entity
  67591. * @param result defines the target matrix
  67592. */
  67593. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67594. /**
  67595. * 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"
  67596. * This function works in right handed mode
  67597. * @param eye defines the final position of the entity
  67598. * @param target defines where the entity should look at
  67599. * @param up defines the up vector for the entity
  67600. * @returns the new matrix
  67601. */
  67602. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67603. /**
  67604. * 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".
  67605. * This function works in right handed mode
  67606. * @param eye defines the final position of the entity
  67607. * @param target defines where the entity should look at
  67608. * @param up defines the up vector for the entity
  67609. * @param result defines the target matrix
  67610. */
  67611. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67612. /**
  67613. * Create a left-handed orthographic projection matrix
  67614. * @param width defines the viewport width
  67615. * @param height defines the viewport height
  67616. * @param znear defines the near clip plane
  67617. * @param zfar defines the far clip plane
  67618. * @returns a new matrix as a left-handed orthographic projection matrix
  67619. */
  67620. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67621. /**
  67622. * Store a left-handed orthographic projection to a given matrix
  67623. * @param width defines the viewport width
  67624. * @param height defines the viewport height
  67625. * @param znear defines the near clip plane
  67626. * @param zfar defines the far clip plane
  67627. * @param result defines the target matrix
  67628. */
  67629. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67630. /**
  67631. * Create a left-handed orthographic projection matrix
  67632. * @param left defines the viewport left coordinate
  67633. * @param right defines the viewport right coordinate
  67634. * @param bottom defines the viewport bottom coordinate
  67635. * @param top defines the viewport top coordinate
  67636. * @param znear defines the near clip plane
  67637. * @param zfar defines the far clip plane
  67638. * @returns a new matrix as a left-handed orthographic projection matrix
  67639. */
  67640. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67641. /**
  67642. * Stores a left-handed orthographic projection into a given matrix
  67643. * @param left defines the viewport left coordinate
  67644. * @param right defines the viewport right coordinate
  67645. * @param bottom defines the viewport bottom coordinate
  67646. * @param top defines the viewport top coordinate
  67647. * @param znear defines the near clip plane
  67648. * @param zfar defines the far clip plane
  67649. * @param result defines the target matrix
  67650. */
  67651. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67652. /**
  67653. * Creates a right-handed orthographic projection matrix
  67654. * @param left defines the viewport left coordinate
  67655. * @param right defines the viewport right coordinate
  67656. * @param bottom defines the viewport bottom coordinate
  67657. * @param top defines the viewport top coordinate
  67658. * @param znear defines the near clip plane
  67659. * @param zfar defines the far clip plane
  67660. * @returns a new matrix as a right-handed orthographic projection matrix
  67661. */
  67662. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67663. /**
  67664. * Stores a right-handed orthographic projection into a given matrix
  67665. * @param left defines the viewport left coordinate
  67666. * @param right defines the viewport right coordinate
  67667. * @param bottom defines the viewport bottom coordinate
  67668. * @param top defines the viewport top coordinate
  67669. * @param znear defines the near clip plane
  67670. * @param zfar defines the far clip plane
  67671. * @param result defines the target matrix
  67672. */
  67673. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67674. /**
  67675. * Creates a left-handed perspective projection matrix
  67676. * @param width defines the viewport width
  67677. * @param height defines the viewport height
  67678. * @param znear defines the near clip plane
  67679. * @param zfar defines the far clip plane
  67680. * @returns a new matrix as a left-handed perspective projection matrix
  67681. */
  67682. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67683. /**
  67684. * Creates a left-handed perspective projection matrix
  67685. * @param fov defines the horizontal field of view
  67686. * @param aspect defines the aspect ratio
  67687. * @param znear defines the near clip plane
  67688. * @param zfar defines the far clip plane
  67689. * @returns a new matrix as a left-handed perspective projection matrix
  67690. */
  67691. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67692. /**
  67693. * Stores a left-handed perspective projection into a given matrix
  67694. * @param fov defines the horizontal field of view
  67695. * @param aspect defines the aspect ratio
  67696. * @param znear defines the near clip plane
  67697. * @param zfar defines the far clip plane
  67698. * @param result defines the target matrix
  67699. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67700. */
  67701. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67702. /**
  67703. * Creates a right-handed perspective projection matrix
  67704. * @param fov defines the horizontal field of view
  67705. * @param aspect defines the aspect ratio
  67706. * @param znear defines the near clip plane
  67707. * @param zfar defines the far clip plane
  67708. * @returns a new matrix as a right-handed perspective projection matrix
  67709. */
  67710. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67711. /**
  67712. * Stores a right-handed perspective projection into a given matrix
  67713. * @param fov defines the horizontal field of view
  67714. * @param aspect defines the aspect ratio
  67715. * @param znear defines the near clip plane
  67716. * @param zfar defines the far clip plane
  67717. * @param result defines the target matrix
  67718. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67719. */
  67720. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67721. /**
  67722. * Stores a perspective projection for WebVR info a given matrix
  67723. * @param fov defines the field of view
  67724. * @param znear defines the near clip plane
  67725. * @param zfar defines the far clip plane
  67726. * @param result defines the target matrix
  67727. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67728. */
  67729. static PerspectiveFovWebVRToRef(fov: {
  67730. upDegrees: number;
  67731. downDegrees: number;
  67732. leftDegrees: number;
  67733. rightDegrees: number;
  67734. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67735. /**
  67736. * Computes a complete transformation matrix
  67737. * @param viewport defines the viewport to use
  67738. * @param world defines the world matrix
  67739. * @param view defines the view matrix
  67740. * @param projection defines the projection matrix
  67741. * @param zmin defines the near clip plane
  67742. * @param zmax defines the far clip plane
  67743. * @returns the transformation matrix
  67744. */
  67745. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67746. /**
  67747. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67748. * @param matrix defines the matrix to use
  67749. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67750. */
  67751. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67752. /**
  67753. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67754. * @param matrix defines the matrix to use
  67755. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67756. */
  67757. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67758. /**
  67759. * Compute the transpose of a given matrix
  67760. * @param matrix defines the matrix to transpose
  67761. * @returns the new matrix
  67762. */
  67763. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67764. /**
  67765. * Compute the transpose of a matrix and store it in a target matrix
  67766. * @param matrix defines the matrix to transpose
  67767. * @param result defines the target matrix
  67768. */
  67769. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67770. /**
  67771. * Computes a reflection matrix from a plane
  67772. * @param plane defines the reflection plane
  67773. * @returns a new matrix
  67774. */
  67775. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67776. /**
  67777. * Computes a reflection matrix from a plane
  67778. * @param plane defines the reflection plane
  67779. * @param result defines the target matrix
  67780. */
  67781. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67782. /**
  67783. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67784. * @param xaxis defines the value of the 1st axis
  67785. * @param yaxis defines the value of the 2nd axis
  67786. * @param zaxis defines the value of the 3rd axis
  67787. * @param result defines the target matrix
  67788. */
  67789. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67790. /**
  67791. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67792. * @param quat defines the quaternion to use
  67793. * @param result defines the target matrix
  67794. */
  67795. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67796. }
  67797. /**
  67798. * @hidden
  67799. */
  67800. export class TmpVectors {
  67801. static Vector2: Vector2[];
  67802. static Vector3: Vector3[];
  67803. static Vector4: Vector4[];
  67804. static Quaternion: Quaternion[];
  67805. static Matrix: Matrix[];
  67806. }
  67807. }
  67808. declare module BABYLON {
  67809. /** Defines the cross module used constants to avoid circular dependncies */
  67810. export class Constants {
  67811. /** Defines that alpha blending is disabled */
  67812. static readonly ALPHA_DISABLE: number;
  67813. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67814. static readonly ALPHA_ADD: number;
  67815. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67816. static readonly ALPHA_COMBINE: number;
  67817. /** Defines that alpha blending to DEST - SRC * DEST */
  67818. static readonly ALPHA_SUBTRACT: number;
  67819. /** Defines that alpha blending to SRC * DEST */
  67820. static readonly ALPHA_MULTIPLY: number;
  67821. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67822. static readonly ALPHA_MAXIMIZED: number;
  67823. /** Defines that alpha blending to SRC + DEST */
  67824. static readonly ALPHA_ONEONE: number;
  67825. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67826. static readonly ALPHA_PREMULTIPLIED: number;
  67827. /**
  67828. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67829. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67830. */
  67831. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67832. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67833. static readonly ALPHA_INTERPOLATE: number;
  67834. /**
  67835. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67836. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67837. */
  67838. static readonly ALPHA_SCREENMODE: number;
  67839. /** Defines that the ressource is not delayed*/
  67840. static readonly DELAYLOADSTATE_NONE: number;
  67841. /** Defines that the ressource was successfully delay loaded */
  67842. static readonly DELAYLOADSTATE_LOADED: number;
  67843. /** Defines that the ressource is currently delay loading */
  67844. static readonly DELAYLOADSTATE_LOADING: number;
  67845. /** Defines that the ressource is delayed and has not started loading */
  67846. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67847. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67848. static readonly NEVER: number;
  67849. /** 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 */
  67850. static readonly ALWAYS: number;
  67851. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67852. static readonly LESS: number;
  67853. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67854. static readonly EQUAL: number;
  67855. /** 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 */
  67856. static readonly LEQUAL: number;
  67857. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67858. static readonly GREATER: number;
  67859. /** 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 */
  67860. static readonly GEQUAL: number;
  67861. /** 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 */
  67862. static readonly NOTEQUAL: number;
  67863. /** Passed to stencilOperation to specify that stencil value must be kept */
  67864. static readonly KEEP: number;
  67865. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67866. static readonly REPLACE: number;
  67867. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67868. static readonly INCR: number;
  67869. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67870. static readonly DECR: number;
  67871. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67872. static readonly INVERT: number;
  67873. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67874. static readonly INCR_WRAP: number;
  67875. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67876. static readonly DECR_WRAP: number;
  67877. /** Texture is not repeating outside of 0..1 UVs */
  67878. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67879. /** Texture is repeating outside of 0..1 UVs */
  67880. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67881. /** Texture is repeating and mirrored */
  67882. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67883. /** ALPHA */
  67884. static readonly TEXTUREFORMAT_ALPHA: number;
  67885. /** LUMINANCE */
  67886. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67887. /** LUMINANCE_ALPHA */
  67888. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67889. /** RGB */
  67890. static readonly TEXTUREFORMAT_RGB: number;
  67891. /** RGBA */
  67892. static readonly TEXTUREFORMAT_RGBA: number;
  67893. /** RED */
  67894. static readonly TEXTUREFORMAT_RED: number;
  67895. /** RED (2nd reference) */
  67896. static readonly TEXTUREFORMAT_R: number;
  67897. /** RG */
  67898. static readonly TEXTUREFORMAT_RG: number;
  67899. /** RED_INTEGER */
  67900. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67901. /** RED_INTEGER (2nd reference) */
  67902. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67903. /** RG_INTEGER */
  67904. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67905. /** RGB_INTEGER */
  67906. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67907. /** RGBA_INTEGER */
  67908. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67909. /** UNSIGNED_BYTE */
  67910. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67911. /** UNSIGNED_BYTE (2nd reference) */
  67912. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67913. /** FLOAT */
  67914. static readonly TEXTURETYPE_FLOAT: number;
  67915. /** HALF_FLOAT */
  67916. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67917. /** BYTE */
  67918. static readonly TEXTURETYPE_BYTE: number;
  67919. /** SHORT */
  67920. static readonly TEXTURETYPE_SHORT: number;
  67921. /** UNSIGNED_SHORT */
  67922. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67923. /** INT */
  67924. static readonly TEXTURETYPE_INT: number;
  67925. /** UNSIGNED_INT */
  67926. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67927. /** UNSIGNED_SHORT_4_4_4_4 */
  67928. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67929. /** UNSIGNED_SHORT_5_5_5_1 */
  67930. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67931. /** UNSIGNED_SHORT_5_6_5 */
  67932. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67933. /** UNSIGNED_INT_2_10_10_10_REV */
  67934. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67935. /** UNSIGNED_INT_24_8 */
  67936. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67937. /** UNSIGNED_INT_10F_11F_11F_REV */
  67938. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67939. /** UNSIGNED_INT_5_9_9_9_REV */
  67940. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67941. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67942. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67943. /** nearest is mag = nearest and min = nearest and mip = linear */
  67944. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67945. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67946. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67947. /** Trilinear is mag = linear and min = linear and mip = linear */
  67948. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67949. /** nearest is mag = nearest and min = nearest and mip = linear */
  67950. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67951. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67952. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67953. /** Trilinear is mag = linear and min = linear and mip = linear */
  67954. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67955. /** mag = nearest and min = nearest and mip = nearest */
  67956. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67957. /** mag = nearest and min = linear and mip = nearest */
  67958. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67959. /** mag = nearest and min = linear and mip = linear */
  67960. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67961. /** mag = nearest and min = linear and mip = none */
  67962. static readonly TEXTURE_NEAREST_LINEAR: number;
  67963. /** mag = nearest and min = nearest and mip = none */
  67964. static readonly TEXTURE_NEAREST_NEAREST: number;
  67965. /** mag = linear and min = nearest and mip = nearest */
  67966. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67967. /** mag = linear and min = nearest and mip = linear */
  67968. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67969. /** mag = linear and min = linear and mip = none */
  67970. static readonly TEXTURE_LINEAR_LINEAR: number;
  67971. /** mag = linear and min = nearest and mip = none */
  67972. static readonly TEXTURE_LINEAR_NEAREST: number;
  67973. /** Explicit coordinates mode */
  67974. static readonly TEXTURE_EXPLICIT_MODE: number;
  67975. /** Spherical coordinates mode */
  67976. static readonly TEXTURE_SPHERICAL_MODE: number;
  67977. /** Planar coordinates mode */
  67978. static readonly TEXTURE_PLANAR_MODE: number;
  67979. /** Cubic coordinates mode */
  67980. static readonly TEXTURE_CUBIC_MODE: number;
  67981. /** Projection coordinates mode */
  67982. static readonly TEXTURE_PROJECTION_MODE: number;
  67983. /** Skybox coordinates mode */
  67984. static readonly TEXTURE_SKYBOX_MODE: number;
  67985. /** Inverse Cubic coordinates mode */
  67986. static readonly TEXTURE_INVCUBIC_MODE: number;
  67987. /** Equirectangular coordinates mode */
  67988. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67989. /** Equirectangular Fixed coordinates mode */
  67990. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67991. /** Equirectangular Fixed Mirrored coordinates mode */
  67992. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67993. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67994. static readonly SCALEMODE_FLOOR: number;
  67995. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67996. static readonly SCALEMODE_NEAREST: number;
  67997. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67998. static readonly SCALEMODE_CEILING: number;
  67999. /**
  68000. * The dirty texture flag value
  68001. */
  68002. static readonly MATERIAL_TextureDirtyFlag: number;
  68003. /**
  68004. * The dirty light flag value
  68005. */
  68006. static readonly MATERIAL_LightDirtyFlag: number;
  68007. /**
  68008. * The dirty fresnel flag value
  68009. */
  68010. static readonly MATERIAL_FresnelDirtyFlag: number;
  68011. /**
  68012. * The dirty attribute flag value
  68013. */
  68014. static readonly MATERIAL_AttributesDirtyFlag: number;
  68015. /**
  68016. * The dirty misc flag value
  68017. */
  68018. static readonly MATERIAL_MiscDirtyFlag: number;
  68019. /**
  68020. * The all dirty flag value
  68021. */
  68022. static readonly MATERIAL_AllDirtyFlag: number;
  68023. /**
  68024. * Returns the triangle fill mode
  68025. */
  68026. static readonly MATERIAL_TriangleFillMode: number;
  68027. /**
  68028. * Returns the wireframe mode
  68029. */
  68030. static readonly MATERIAL_WireFrameFillMode: number;
  68031. /**
  68032. * Returns the point fill mode
  68033. */
  68034. static readonly MATERIAL_PointFillMode: number;
  68035. /**
  68036. * Returns the point list draw mode
  68037. */
  68038. static readonly MATERIAL_PointListDrawMode: number;
  68039. /**
  68040. * Returns the line list draw mode
  68041. */
  68042. static readonly MATERIAL_LineListDrawMode: number;
  68043. /**
  68044. * Returns the line loop draw mode
  68045. */
  68046. static readonly MATERIAL_LineLoopDrawMode: number;
  68047. /**
  68048. * Returns the line strip draw mode
  68049. */
  68050. static readonly MATERIAL_LineStripDrawMode: number;
  68051. /**
  68052. * Returns the triangle strip draw mode
  68053. */
  68054. static readonly MATERIAL_TriangleStripDrawMode: number;
  68055. /**
  68056. * Returns the triangle fan draw mode
  68057. */
  68058. static readonly MATERIAL_TriangleFanDrawMode: number;
  68059. /**
  68060. * Stores the clock-wise side orientation
  68061. */
  68062. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68063. /**
  68064. * Stores the counter clock-wise side orientation
  68065. */
  68066. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68067. /**
  68068. * Nothing
  68069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68070. */
  68071. static readonly ACTION_NothingTrigger: number;
  68072. /**
  68073. * On pick
  68074. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68075. */
  68076. static readonly ACTION_OnPickTrigger: number;
  68077. /**
  68078. * On left pick
  68079. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68080. */
  68081. static readonly ACTION_OnLeftPickTrigger: number;
  68082. /**
  68083. * On right pick
  68084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68085. */
  68086. static readonly ACTION_OnRightPickTrigger: number;
  68087. /**
  68088. * On center pick
  68089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68090. */
  68091. static readonly ACTION_OnCenterPickTrigger: number;
  68092. /**
  68093. * On pick down
  68094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68095. */
  68096. static readonly ACTION_OnPickDownTrigger: number;
  68097. /**
  68098. * On double pick
  68099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68100. */
  68101. static readonly ACTION_OnDoublePickTrigger: number;
  68102. /**
  68103. * On pick up
  68104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68105. */
  68106. static readonly ACTION_OnPickUpTrigger: number;
  68107. /**
  68108. * On pick out.
  68109. * This trigger will only be raised if you also declared a OnPickDown
  68110. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68111. */
  68112. static readonly ACTION_OnPickOutTrigger: number;
  68113. /**
  68114. * On long press
  68115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68116. */
  68117. static readonly ACTION_OnLongPressTrigger: number;
  68118. /**
  68119. * On pointer over
  68120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68121. */
  68122. static readonly ACTION_OnPointerOverTrigger: number;
  68123. /**
  68124. * On pointer out
  68125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68126. */
  68127. static readonly ACTION_OnPointerOutTrigger: number;
  68128. /**
  68129. * On every frame
  68130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68131. */
  68132. static readonly ACTION_OnEveryFrameTrigger: number;
  68133. /**
  68134. * On intersection enter
  68135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68136. */
  68137. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68138. /**
  68139. * On intersection exit
  68140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68141. */
  68142. static readonly ACTION_OnIntersectionExitTrigger: number;
  68143. /**
  68144. * On key down
  68145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68146. */
  68147. static readonly ACTION_OnKeyDownTrigger: number;
  68148. /**
  68149. * On key up
  68150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68151. */
  68152. static readonly ACTION_OnKeyUpTrigger: number;
  68153. /**
  68154. * Billboard mode will only apply to Y axis
  68155. */
  68156. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68157. /**
  68158. * Billboard mode will apply to all axes
  68159. */
  68160. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68161. /**
  68162. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68163. */
  68164. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68165. /**
  68166. * Gets or sets base Assets URL
  68167. */
  68168. static PARTICLES_BaseAssetsUrl: string;
  68169. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68170. * Test order :
  68171. * Is the bounding sphere outside the frustum ?
  68172. * If not, are the bounding box vertices outside the frustum ?
  68173. * It not, then the cullable object is in the frustum.
  68174. */
  68175. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68176. /** Culling strategy : Bounding Sphere Only.
  68177. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68178. * It's also less accurate than the standard because some not visible objects can still be selected.
  68179. * Test : is the bounding sphere outside the frustum ?
  68180. * If not, then the cullable object is in the frustum.
  68181. */
  68182. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68183. /** Culling strategy : Optimistic Inclusion.
  68184. * This in an inclusion test first, then the standard exclusion test.
  68185. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68186. * 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.
  68187. * Anyway, it's as accurate as the standard strategy.
  68188. * Test :
  68189. * Is the cullable object bounding sphere center in the frustum ?
  68190. * If not, apply the default culling strategy.
  68191. */
  68192. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68193. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68194. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68195. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68196. * 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.
  68197. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68198. * Test :
  68199. * Is the cullable object bounding sphere center in the frustum ?
  68200. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68201. */
  68202. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68203. /**
  68204. * No logging while loading
  68205. */
  68206. static readonly SCENELOADER_NO_LOGGING: number;
  68207. /**
  68208. * Minimal logging while loading
  68209. */
  68210. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68211. /**
  68212. * Summary logging while loading
  68213. */
  68214. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68215. /**
  68216. * Detailled logging while loading
  68217. */
  68218. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68219. }
  68220. }
  68221. declare module BABYLON {
  68222. /**
  68223. * Class used to store and describe the pipeline context associated with an effect
  68224. */
  68225. export interface IPipelineContext {
  68226. /**
  68227. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68228. */
  68229. isAsync: boolean;
  68230. /**
  68231. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68232. */
  68233. isReady: boolean;
  68234. /** @hidden */
  68235. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68236. }
  68237. }
  68238. declare module BABYLON {
  68239. /** @hidden */
  68240. export interface IShaderProcessor {
  68241. attributeProcessor?: (attribute: string) => string;
  68242. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68243. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68244. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68245. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68246. lineProcessor?: (line: string, isFragment: boolean) => string;
  68247. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68248. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68249. }
  68250. }
  68251. declare module BABYLON {
  68252. /** @hidden */
  68253. export interface ProcessingOptions {
  68254. defines: string[];
  68255. indexParameters: any;
  68256. isFragment: boolean;
  68257. shouldUseHighPrecisionShader: boolean;
  68258. supportsUniformBuffers: boolean;
  68259. shadersRepository: string;
  68260. includesShadersStore: {
  68261. [key: string]: string;
  68262. };
  68263. processor?: IShaderProcessor;
  68264. version: string;
  68265. platformName: string;
  68266. lookForClosingBracketForUniformBuffer?: boolean;
  68267. }
  68268. }
  68269. declare module BABYLON {
  68270. /**
  68271. * Helper to manipulate strings
  68272. */
  68273. export class StringTools {
  68274. /**
  68275. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68276. * @param str Source string
  68277. * @param suffix Suffix to search for in the source string
  68278. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68279. */
  68280. static EndsWith(str: string, suffix: string): boolean;
  68281. /**
  68282. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68283. * @param str Source string
  68284. * @param suffix Suffix to search for in the source string
  68285. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68286. */
  68287. static StartsWith(str: string, suffix: string): boolean;
  68288. }
  68289. }
  68290. declare module BABYLON {
  68291. /** @hidden */
  68292. export class ShaderCodeNode {
  68293. line: string;
  68294. children: ShaderCodeNode[];
  68295. additionalDefineKey?: string;
  68296. additionalDefineValue?: string;
  68297. isValid(preprocessors: {
  68298. [key: string]: string;
  68299. }): boolean;
  68300. process(preprocessors: {
  68301. [key: string]: string;
  68302. }, options: ProcessingOptions): string;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export class ShaderCodeCursor {
  68308. private _lines;
  68309. lineIndex: number;
  68310. readonly currentLine: string;
  68311. readonly canRead: boolean;
  68312. lines: string[];
  68313. }
  68314. }
  68315. declare module BABYLON {
  68316. /** @hidden */
  68317. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68318. process(preprocessors: {
  68319. [key: string]: string;
  68320. }, options: ProcessingOptions): string;
  68321. }
  68322. }
  68323. declare module BABYLON {
  68324. /** @hidden */
  68325. export class ShaderDefineExpression {
  68326. isTrue(preprocessors: {
  68327. [key: string]: string;
  68328. }): boolean;
  68329. }
  68330. }
  68331. declare module BABYLON {
  68332. /** @hidden */
  68333. export class ShaderCodeTestNode extends ShaderCodeNode {
  68334. testExpression: ShaderDefineExpression;
  68335. isValid(preprocessors: {
  68336. [key: string]: string;
  68337. }): boolean;
  68338. }
  68339. }
  68340. declare module BABYLON {
  68341. /** @hidden */
  68342. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68343. define: string;
  68344. not: boolean;
  68345. constructor(define: string, not?: boolean);
  68346. isTrue(preprocessors: {
  68347. [key: string]: string;
  68348. }): boolean;
  68349. }
  68350. }
  68351. declare module BABYLON {
  68352. /** @hidden */
  68353. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68354. leftOperand: ShaderDefineExpression;
  68355. rightOperand: ShaderDefineExpression;
  68356. isTrue(preprocessors: {
  68357. [key: string]: string;
  68358. }): boolean;
  68359. }
  68360. }
  68361. declare module BABYLON {
  68362. /** @hidden */
  68363. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68364. leftOperand: ShaderDefineExpression;
  68365. rightOperand: ShaderDefineExpression;
  68366. isTrue(preprocessors: {
  68367. [key: string]: string;
  68368. }): boolean;
  68369. }
  68370. }
  68371. declare module BABYLON {
  68372. /** @hidden */
  68373. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68374. define: string;
  68375. operand: string;
  68376. testValue: string;
  68377. constructor(define: string, operand: string, testValue: string);
  68378. isTrue(preprocessors: {
  68379. [key: string]: string;
  68380. }): boolean;
  68381. }
  68382. }
  68383. declare module BABYLON {
  68384. /**
  68385. * @ignore
  68386. * Application error to support additional information when loading a file
  68387. */
  68388. export class LoadFileError extends Error {
  68389. /** defines the optional web request */
  68390. request?: WebRequest | undefined;
  68391. private static _setPrototypeOf;
  68392. /**
  68393. * Creates a new LoadFileError
  68394. * @param message defines the message of the error
  68395. * @param request defines the optional web request
  68396. */
  68397. constructor(message: string,
  68398. /** defines the optional web request */
  68399. request?: WebRequest | undefined);
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. /**
  68404. * Class used to enable access to offline support
  68405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68406. */
  68407. export interface IOfflineProvider {
  68408. /**
  68409. * Gets a boolean indicating if scene must be saved in the database
  68410. */
  68411. enableSceneOffline: boolean;
  68412. /**
  68413. * Gets a boolean indicating if textures must be saved in the database
  68414. */
  68415. enableTexturesOffline: boolean;
  68416. /**
  68417. * Open the offline support and make it available
  68418. * @param successCallback defines the callback to call on success
  68419. * @param errorCallback defines the callback to call on error
  68420. */
  68421. open(successCallback: () => void, errorCallback: () => void): void;
  68422. /**
  68423. * Loads an image from the offline support
  68424. * @param url defines the url to load from
  68425. * @param image defines the target DOM image
  68426. */
  68427. loadImage(url: string, image: HTMLImageElement): void;
  68428. /**
  68429. * Loads a file from offline support
  68430. * @param url defines the URL to load from
  68431. * @param sceneLoaded defines a callback to call on success
  68432. * @param progressCallBack defines a callback to call when progress changed
  68433. * @param errorCallback defines a callback to call on error
  68434. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68435. */
  68436. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68437. }
  68438. }
  68439. declare module BABYLON {
  68440. /**
  68441. * Class used to help managing file picking and drag'n'drop
  68442. * File Storage
  68443. */
  68444. export class FilesInputStore {
  68445. /**
  68446. * List of files ready to be loaded
  68447. */
  68448. static FilesToLoad: {
  68449. [key: string]: File;
  68450. };
  68451. }
  68452. }
  68453. declare module BABYLON {
  68454. /**
  68455. * Class used to define a retry strategy when error happens while loading assets
  68456. */
  68457. export class RetryStrategy {
  68458. /**
  68459. * Function used to defines an exponential back off strategy
  68460. * @param maxRetries defines the maximum number of retries (3 by default)
  68461. * @param baseInterval defines the interval between retries
  68462. * @returns the strategy function to use
  68463. */
  68464. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68465. }
  68466. }
  68467. declare module BABYLON {
  68468. /**
  68469. * @hidden
  68470. */
  68471. export class FileTools {
  68472. /**
  68473. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68474. */
  68475. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68476. /**
  68477. * Gets or sets the base URL to use to load assets
  68478. */
  68479. static BaseUrl: string;
  68480. /**
  68481. * Default behaviour for cors in the application.
  68482. * It can be a string if the expected behavior is identical in the entire app.
  68483. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68484. */
  68485. static CorsBehavior: string | ((url: string | string[]) => string);
  68486. /**
  68487. * Gets or sets a function used to pre-process url before using them to load assets
  68488. */
  68489. static PreprocessUrl: (url: string) => string;
  68490. /**
  68491. * Removes unwanted characters from an url
  68492. * @param url defines the url to clean
  68493. * @returns the cleaned url
  68494. */
  68495. private static _CleanUrl;
  68496. /**
  68497. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68498. * @param url define the url we are trying
  68499. * @param element define the dom element where to configure the cors policy
  68500. */
  68501. static SetCorsBehavior(url: string | string[], element: {
  68502. crossOrigin: string | null;
  68503. }): void;
  68504. /**
  68505. * Loads an image as an HTMLImageElement.
  68506. * @param input url string, ArrayBuffer, or Blob to load
  68507. * @param onLoad callback called when the image successfully loads
  68508. * @param onError callback called when the image fails to load
  68509. * @param offlineProvider offline provider for caching
  68510. * @returns the HTMLImageElement of the loaded image
  68511. */
  68512. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68513. /**
  68514. * Loads a file
  68515. * @param fileToLoad defines the file to load
  68516. * @param callback defines the callback to call when data is loaded
  68517. * @param progressCallBack defines the callback to call during loading process
  68518. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68519. * @returns a file request object
  68520. */
  68521. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68522. /**
  68523. * Loads a file
  68524. * @param url url string, ArrayBuffer, or Blob to load
  68525. * @param onSuccess callback called when the file successfully loads
  68526. * @param onProgress callback called while file is loading (if the server supports this mode)
  68527. * @param offlineProvider defines the offline provider for caching
  68528. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68529. * @param onError callback called when the file fails to load
  68530. * @returns a file request object
  68531. */
  68532. 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;
  68533. /**
  68534. * Checks if the loaded document was accessed via `file:`-Protocol.
  68535. * @returns boolean
  68536. */
  68537. static IsFileURL(): boolean;
  68538. }
  68539. }
  68540. declare module BABYLON {
  68541. /** @hidden */
  68542. export class ShaderProcessor {
  68543. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68544. private static _ProcessPrecision;
  68545. private static _ExtractOperation;
  68546. private static _BuildSubExpression;
  68547. private static _BuildExpression;
  68548. private static _MoveCursorWithinIf;
  68549. private static _MoveCursor;
  68550. private static _EvaluatePreProcessors;
  68551. private static _PreparePreProcessors;
  68552. private static _ProcessShaderConversion;
  68553. private static _ProcessIncludes;
  68554. }
  68555. }
  68556. declare module BABYLON {
  68557. /**
  68558. * Class used to hold a RBG color
  68559. */
  68560. export class Color3 {
  68561. /**
  68562. * Defines the red component (between 0 and 1, default is 0)
  68563. */
  68564. r: number;
  68565. /**
  68566. * Defines the green component (between 0 and 1, default is 0)
  68567. */
  68568. g: number;
  68569. /**
  68570. * Defines the blue component (between 0 and 1, default is 0)
  68571. */
  68572. b: number;
  68573. /**
  68574. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68575. * @param r defines the red component (between 0 and 1, default is 0)
  68576. * @param g defines the green component (between 0 and 1, default is 0)
  68577. * @param b defines the blue component (between 0 and 1, default is 0)
  68578. */
  68579. constructor(
  68580. /**
  68581. * Defines the red component (between 0 and 1, default is 0)
  68582. */
  68583. r?: number,
  68584. /**
  68585. * Defines the green component (between 0 and 1, default is 0)
  68586. */
  68587. g?: number,
  68588. /**
  68589. * Defines the blue component (between 0 and 1, default is 0)
  68590. */
  68591. b?: number);
  68592. /**
  68593. * Creates a string with the Color3 current values
  68594. * @returns the string representation of the Color3 object
  68595. */
  68596. toString(): string;
  68597. /**
  68598. * Returns the string "Color3"
  68599. * @returns "Color3"
  68600. */
  68601. getClassName(): string;
  68602. /**
  68603. * Compute the Color3 hash code
  68604. * @returns an unique number that can be used to hash Color3 objects
  68605. */
  68606. getHashCode(): number;
  68607. /**
  68608. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68609. * @param array defines the array where to store the r,g,b components
  68610. * @param index defines an optional index in the target array to define where to start storing values
  68611. * @returns the current Color3 object
  68612. */
  68613. toArray(array: FloatArray, index?: number): Color3;
  68614. /**
  68615. * Returns a new Color4 object from the current Color3 and the given alpha
  68616. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68617. * @returns a new Color4 object
  68618. */
  68619. toColor4(alpha?: number): Color4;
  68620. /**
  68621. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68622. * @returns the new array
  68623. */
  68624. asArray(): number[];
  68625. /**
  68626. * Returns the luminance value
  68627. * @returns a float value
  68628. */
  68629. toLuminance(): number;
  68630. /**
  68631. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68632. * @param otherColor defines the second operand
  68633. * @returns the new Color3 object
  68634. */
  68635. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68636. /**
  68637. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68638. * @param otherColor defines the second operand
  68639. * @param result defines the Color3 object where to store the result
  68640. * @returns the current Color3
  68641. */
  68642. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68643. /**
  68644. * Determines equality between Color3 objects
  68645. * @param otherColor defines the second operand
  68646. * @returns true if the rgb values are equal to the given ones
  68647. */
  68648. equals(otherColor: DeepImmutable<Color3>): boolean;
  68649. /**
  68650. * Determines equality between the current Color3 object and a set of r,b,g values
  68651. * @param r defines the red component to check
  68652. * @param g defines the green component to check
  68653. * @param b defines the blue component to check
  68654. * @returns true if the rgb values are equal to the given ones
  68655. */
  68656. equalsFloats(r: number, g: number, b: number): boolean;
  68657. /**
  68658. * Multiplies in place each rgb value by scale
  68659. * @param scale defines the scaling factor
  68660. * @returns the updated Color3
  68661. */
  68662. scale(scale: number): Color3;
  68663. /**
  68664. * Multiplies the rgb values by scale and stores the result into "result"
  68665. * @param scale defines the scaling factor
  68666. * @param result defines the Color3 object where to store the result
  68667. * @returns the unmodified current Color3
  68668. */
  68669. scaleToRef(scale: number, result: Color3): Color3;
  68670. /**
  68671. * Scale the current Color3 values by a factor and add the result to a given Color3
  68672. * @param scale defines the scale factor
  68673. * @param result defines color to store the result into
  68674. * @returns the unmodified current Color3
  68675. */
  68676. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68677. /**
  68678. * Clamps the rgb values by the min and max values and stores the result into "result"
  68679. * @param min defines minimum clamping value (default is 0)
  68680. * @param max defines maximum clamping value (default is 1)
  68681. * @param result defines color to store the result into
  68682. * @returns the original Color3
  68683. */
  68684. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68685. /**
  68686. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68687. * @param otherColor defines the second operand
  68688. * @returns the new Color3
  68689. */
  68690. add(otherColor: DeepImmutable<Color3>): Color3;
  68691. /**
  68692. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68693. * @param otherColor defines the second operand
  68694. * @param result defines Color3 object to store the result into
  68695. * @returns the unmodified current Color3
  68696. */
  68697. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68698. /**
  68699. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68700. * @param otherColor defines the second operand
  68701. * @returns the new Color3
  68702. */
  68703. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68704. /**
  68705. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68706. * @param otherColor defines the second operand
  68707. * @param result defines Color3 object to store the result into
  68708. * @returns the unmodified current Color3
  68709. */
  68710. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68711. /**
  68712. * Copy the current object
  68713. * @returns a new Color3 copied the current one
  68714. */
  68715. clone(): Color3;
  68716. /**
  68717. * Copies the rgb values from the source in the current Color3
  68718. * @param source defines the source Color3 object
  68719. * @returns the updated Color3 object
  68720. */
  68721. copyFrom(source: DeepImmutable<Color3>): Color3;
  68722. /**
  68723. * Updates the Color3 rgb values from the given floats
  68724. * @param r defines the red component to read from
  68725. * @param g defines the green component to read from
  68726. * @param b defines the blue component to read from
  68727. * @returns the current Color3 object
  68728. */
  68729. copyFromFloats(r: number, g: number, b: number): Color3;
  68730. /**
  68731. * Updates the Color3 rgb values from the given floats
  68732. * @param r defines the red component to read from
  68733. * @param g defines the green component to read from
  68734. * @param b defines the blue component to read from
  68735. * @returns the current Color3 object
  68736. */
  68737. set(r: number, g: number, b: number): Color3;
  68738. /**
  68739. * Compute the Color3 hexadecimal code as a string
  68740. * @returns a string containing the hexadecimal representation of the Color3 object
  68741. */
  68742. toHexString(): string;
  68743. /**
  68744. * Computes a new Color3 converted from the current one to linear space
  68745. * @returns a new Color3 object
  68746. */
  68747. toLinearSpace(): Color3;
  68748. /**
  68749. * Converts current color in rgb space to HSV values
  68750. * @returns a new color3 representing the HSV values
  68751. */
  68752. toHSV(): Color3;
  68753. /**
  68754. * Converts current color in rgb space to HSV values
  68755. * @param result defines the Color3 where to store the HSV values
  68756. */
  68757. toHSVToRef(result: Color3): void;
  68758. /**
  68759. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68760. * @param convertedColor defines the Color3 object where to store the linear space version
  68761. * @returns the unmodified Color3
  68762. */
  68763. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68764. /**
  68765. * Computes a new Color3 converted from the current one to gamma space
  68766. * @returns a new Color3 object
  68767. */
  68768. toGammaSpace(): Color3;
  68769. /**
  68770. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68771. * @param convertedColor defines the Color3 object where to store the gamma space version
  68772. * @returns the unmodified Color3
  68773. */
  68774. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68775. private static _BlackReadOnly;
  68776. /**
  68777. * Convert Hue, saturation and value to a Color3 (RGB)
  68778. * @param hue defines the hue
  68779. * @param saturation defines the saturation
  68780. * @param value defines the value
  68781. * @param result defines the Color3 where to store the RGB values
  68782. */
  68783. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68784. /**
  68785. * Creates a new Color3 from the string containing valid hexadecimal values
  68786. * @param hex defines a string containing valid hexadecimal values
  68787. * @returns a new Color3 object
  68788. */
  68789. static FromHexString(hex: string): Color3;
  68790. /**
  68791. * Creates a new Color3 from the starting index of the given array
  68792. * @param array defines the source array
  68793. * @param offset defines an offset in the source array
  68794. * @returns a new Color3 object
  68795. */
  68796. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68797. /**
  68798. * Creates a new Color3 from integer values (< 256)
  68799. * @param r defines the red component to read from (value between 0 and 255)
  68800. * @param g defines the green component to read from (value between 0 and 255)
  68801. * @param b defines the blue component to read from (value between 0 and 255)
  68802. * @returns a new Color3 object
  68803. */
  68804. static FromInts(r: number, g: number, b: number): Color3;
  68805. /**
  68806. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68807. * @param start defines the start Color3 value
  68808. * @param end defines the end Color3 value
  68809. * @param amount defines the gradient value between start and end
  68810. * @returns a new Color3 object
  68811. */
  68812. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68813. /**
  68814. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68815. * @param left defines the start value
  68816. * @param right defines the end value
  68817. * @param amount defines the gradient factor
  68818. * @param result defines the Color3 object where to store the result
  68819. */
  68820. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68821. /**
  68822. * Returns a Color3 value containing a red color
  68823. * @returns a new Color3 object
  68824. */
  68825. static Red(): Color3;
  68826. /**
  68827. * Returns a Color3 value containing a green color
  68828. * @returns a new Color3 object
  68829. */
  68830. static Green(): Color3;
  68831. /**
  68832. * Returns a Color3 value containing a blue color
  68833. * @returns a new Color3 object
  68834. */
  68835. static Blue(): Color3;
  68836. /**
  68837. * Returns a Color3 value containing a black color
  68838. * @returns a new Color3 object
  68839. */
  68840. static Black(): Color3;
  68841. /**
  68842. * Gets a Color3 value containing a black color that must not be updated
  68843. */
  68844. static readonly BlackReadOnly: DeepImmutable<Color3>;
  68845. /**
  68846. * Returns a Color3 value containing a white color
  68847. * @returns a new Color3 object
  68848. */
  68849. static White(): Color3;
  68850. /**
  68851. * Returns a Color3 value containing a purple color
  68852. * @returns a new Color3 object
  68853. */
  68854. static Purple(): Color3;
  68855. /**
  68856. * Returns a Color3 value containing a magenta color
  68857. * @returns a new Color3 object
  68858. */
  68859. static Magenta(): Color3;
  68860. /**
  68861. * Returns a Color3 value containing a yellow color
  68862. * @returns a new Color3 object
  68863. */
  68864. static Yellow(): Color3;
  68865. /**
  68866. * Returns a Color3 value containing a gray color
  68867. * @returns a new Color3 object
  68868. */
  68869. static Gray(): Color3;
  68870. /**
  68871. * Returns a Color3 value containing a teal color
  68872. * @returns a new Color3 object
  68873. */
  68874. static Teal(): Color3;
  68875. /**
  68876. * Returns a Color3 value containing a random color
  68877. * @returns a new Color3 object
  68878. */
  68879. static Random(): Color3;
  68880. }
  68881. /**
  68882. * Class used to hold a RBGA color
  68883. */
  68884. export class Color4 {
  68885. /**
  68886. * Defines the red component (between 0 and 1, default is 0)
  68887. */
  68888. r: number;
  68889. /**
  68890. * Defines the green component (between 0 and 1, default is 0)
  68891. */
  68892. g: number;
  68893. /**
  68894. * Defines the blue component (between 0 and 1, default is 0)
  68895. */
  68896. b: number;
  68897. /**
  68898. * Defines the alpha component (between 0 and 1, default is 1)
  68899. */
  68900. a: number;
  68901. /**
  68902. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68903. * @param r defines the red component (between 0 and 1, default is 0)
  68904. * @param g defines the green component (between 0 and 1, default is 0)
  68905. * @param b defines the blue component (between 0 and 1, default is 0)
  68906. * @param a defines the alpha component (between 0 and 1, default is 1)
  68907. */
  68908. constructor(
  68909. /**
  68910. * Defines the red component (between 0 and 1, default is 0)
  68911. */
  68912. r?: number,
  68913. /**
  68914. * Defines the green component (between 0 and 1, default is 0)
  68915. */
  68916. g?: number,
  68917. /**
  68918. * Defines the blue component (between 0 and 1, default is 0)
  68919. */
  68920. b?: number,
  68921. /**
  68922. * Defines the alpha component (between 0 and 1, default is 1)
  68923. */
  68924. a?: number);
  68925. /**
  68926. * Adds in place the given Color4 values to the current Color4 object
  68927. * @param right defines the second operand
  68928. * @returns the current updated Color4 object
  68929. */
  68930. addInPlace(right: DeepImmutable<Color4>): Color4;
  68931. /**
  68932. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68933. * @returns the new array
  68934. */
  68935. asArray(): number[];
  68936. /**
  68937. * Stores from the starting index in the given array the Color4 successive values
  68938. * @param array defines the array where to store the r,g,b components
  68939. * @param index defines an optional index in the target array to define where to start storing values
  68940. * @returns the current Color4 object
  68941. */
  68942. toArray(array: number[], index?: number): Color4;
  68943. /**
  68944. * Determines equality between Color4 objects
  68945. * @param otherColor defines the second operand
  68946. * @returns true if the rgba values are equal to the given ones
  68947. */
  68948. equals(otherColor: DeepImmutable<Color4>): boolean;
  68949. /**
  68950. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68951. * @param right defines the second operand
  68952. * @returns a new Color4 object
  68953. */
  68954. add(right: DeepImmutable<Color4>): Color4;
  68955. /**
  68956. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68957. * @param right defines the second operand
  68958. * @returns a new Color4 object
  68959. */
  68960. subtract(right: DeepImmutable<Color4>): Color4;
  68961. /**
  68962. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68963. * @param right defines the second operand
  68964. * @param result defines the Color4 object where to store the result
  68965. * @returns the current Color4 object
  68966. */
  68967. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  68968. /**
  68969. * Creates a new Color4 with the current Color4 values multiplied by scale
  68970. * @param scale defines the scaling factor to apply
  68971. * @returns a new Color4 object
  68972. */
  68973. scale(scale: number): Color4;
  68974. /**
  68975. * Multiplies the current Color4 values by scale and stores the result in "result"
  68976. * @param scale defines the scaling factor to apply
  68977. * @param result defines the Color4 object where to store the result
  68978. * @returns the current unmodified Color4
  68979. */
  68980. scaleToRef(scale: number, result: Color4): Color4;
  68981. /**
  68982. * Scale the current Color4 values by a factor and add the result to a given Color4
  68983. * @param scale defines the scale factor
  68984. * @param result defines the Color4 object where to store the result
  68985. * @returns the unmodified current Color4
  68986. */
  68987. scaleAndAddToRef(scale: number, result: Color4): Color4;
  68988. /**
  68989. * Clamps the rgb values by the min and max values and stores the result into "result"
  68990. * @param min defines minimum clamping value (default is 0)
  68991. * @param max defines maximum clamping value (default is 1)
  68992. * @param result defines color to store the result into.
  68993. * @returns the cuurent Color4
  68994. */
  68995. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  68996. /**
  68997. * Multipy an Color4 value by another and return a new Color4 object
  68998. * @param color defines the Color4 value to multiply by
  68999. * @returns a new Color4 object
  69000. */
  69001. multiply(color: Color4): Color4;
  69002. /**
  69003. * Multipy a Color4 value by another and push the result in a reference value
  69004. * @param color defines the Color4 value to multiply by
  69005. * @param result defines the Color4 to fill the result in
  69006. * @returns the result Color4
  69007. */
  69008. multiplyToRef(color: Color4, result: Color4): Color4;
  69009. /**
  69010. * Creates a string with the Color4 current values
  69011. * @returns the string representation of the Color4 object
  69012. */
  69013. toString(): string;
  69014. /**
  69015. * Returns the string "Color4"
  69016. * @returns "Color4"
  69017. */
  69018. getClassName(): string;
  69019. /**
  69020. * Compute the Color4 hash code
  69021. * @returns an unique number that can be used to hash Color4 objects
  69022. */
  69023. getHashCode(): number;
  69024. /**
  69025. * Creates a new Color4 copied from the current one
  69026. * @returns a new Color4 object
  69027. */
  69028. clone(): Color4;
  69029. /**
  69030. * Copies the given Color4 values into the current one
  69031. * @param source defines the source Color4 object
  69032. * @returns the current updated Color4 object
  69033. */
  69034. copyFrom(source: Color4): Color4;
  69035. /**
  69036. * Copies the given float values into the current one
  69037. * @param r defines the red component to read from
  69038. * @param g defines the green component to read from
  69039. * @param b defines the blue component to read from
  69040. * @param a defines the alpha component to read from
  69041. * @returns the current updated Color4 object
  69042. */
  69043. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69044. /**
  69045. * Copies the given float values into the current one
  69046. * @param r defines the red component to read from
  69047. * @param g defines the green component to read from
  69048. * @param b defines the blue component to read from
  69049. * @param a defines the alpha component to read from
  69050. * @returns the current updated Color4 object
  69051. */
  69052. set(r: number, g: number, b: number, a: number): Color4;
  69053. /**
  69054. * Compute the Color4 hexadecimal code as a string
  69055. * @returns a string containing the hexadecimal representation of the Color4 object
  69056. */
  69057. toHexString(): string;
  69058. /**
  69059. * Computes a new Color4 converted from the current one to linear space
  69060. * @returns a new Color4 object
  69061. */
  69062. toLinearSpace(): Color4;
  69063. /**
  69064. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69065. * @param convertedColor defines the Color4 object where to store the linear space version
  69066. * @returns the unmodified Color4
  69067. */
  69068. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69069. /**
  69070. * Computes a new Color4 converted from the current one to gamma space
  69071. * @returns a new Color4 object
  69072. */
  69073. toGammaSpace(): Color4;
  69074. /**
  69075. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69076. * @param convertedColor defines the Color4 object where to store the gamma space version
  69077. * @returns the unmodified Color4
  69078. */
  69079. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69080. /**
  69081. * Creates a new Color4 from the string containing valid hexadecimal values
  69082. * @param hex defines a string containing valid hexadecimal values
  69083. * @returns a new Color4 object
  69084. */
  69085. static FromHexString(hex: string): Color4;
  69086. /**
  69087. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69088. * @param left defines the start value
  69089. * @param right defines the end value
  69090. * @param amount defines the gradient factor
  69091. * @returns a new Color4 object
  69092. */
  69093. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69094. /**
  69095. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69096. * @param left defines the start value
  69097. * @param right defines the end value
  69098. * @param amount defines the gradient factor
  69099. * @param result defines the Color4 object where to store data
  69100. */
  69101. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69102. /**
  69103. * Creates a new Color4 from a Color3 and an alpha value
  69104. * @param color3 defines the source Color3 to read from
  69105. * @param alpha defines the alpha component (1.0 by default)
  69106. * @returns a new Color4 object
  69107. */
  69108. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69109. /**
  69110. * Creates a new Color4 from the starting index element of the given array
  69111. * @param array defines the source array to read from
  69112. * @param offset defines the offset in the source array
  69113. * @returns a new Color4 object
  69114. */
  69115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69116. /**
  69117. * Creates a new Color3 from integer values (< 256)
  69118. * @param r defines the red component to read from (value between 0 and 255)
  69119. * @param g defines the green component to read from (value between 0 and 255)
  69120. * @param b defines the blue component to read from (value between 0 and 255)
  69121. * @param a defines the alpha component to read from (value between 0 and 255)
  69122. * @returns a new Color3 object
  69123. */
  69124. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69125. /**
  69126. * Check the content of a given array and convert it to an array containing RGBA data
  69127. * If the original array was already containing count * 4 values then it is returned directly
  69128. * @param colors defines the array to check
  69129. * @param count defines the number of RGBA data to expect
  69130. * @returns an array containing count * 4 values (RGBA)
  69131. */
  69132. static CheckColors4(colors: number[], count: number): number[];
  69133. }
  69134. /**
  69135. * @hidden
  69136. */
  69137. export class TmpColors {
  69138. static Color3: Color3[];
  69139. static Color4: Color4[];
  69140. }
  69141. }
  69142. declare module BABYLON {
  69143. /**
  69144. * Class representing spherical harmonics coefficients to the 3rd degree
  69145. */
  69146. export class SphericalHarmonics {
  69147. /**
  69148. * Defines whether or not the harmonics have been prescaled for rendering.
  69149. */
  69150. preScaled: boolean;
  69151. /**
  69152. * The l0,0 coefficients of the spherical harmonics
  69153. */
  69154. l00: Vector3;
  69155. /**
  69156. * The l1,-1 coefficients of the spherical harmonics
  69157. */
  69158. l1_1: Vector3;
  69159. /**
  69160. * The l1,0 coefficients of the spherical harmonics
  69161. */
  69162. l10: Vector3;
  69163. /**
  69164. * The l1,1 coefficients of the spherical harmonics
  69165. */
  69166. l11: Vector3;
  69167. /**
  69168. * The l2,-2 coefficients of the spherical harmonics
  69169. */
  69170. l2_2: Vector3;
  69171. /**
  69172. * The l2,-1 coefficients of the spherical harmonics
  69173. */
  69174. l2_1: Vector3;
  69175. /**
  69176. * The l2,0 coefficients of the spherical harmonics
  69177. */
  69178. l20: Vector3;
  69179. /**
  69180. * The l2,1 coefficients of the spherical harmonics
  69181. */
  69182. l21: Vector3;
  69183. /**
  69184. * The l2,2 coefficients of the spherical harmonics
  69185. */
  69186. l22: Vector3;
  69187. /**
  69188. * Adds a light to the spherical harmonics
  69189. * @param direction the direction of the light
  69190. * @param color the color of the light
  69191. * @param deltaSolidAngle the delta solid angle of the light
  69192. */
  69193. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69194. /**
  69195. * Scales the spherical harmonics by the given amount
  69196. * @param scale the amount to scale
  69197. */
  69198. scaleInPlace(scale: number): void;
  69199. /**
  69200. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69201. *
  69202. * ```
  69203. * E_lm = A_l * L_lm
  69204. * ```
  69205. *
  69206. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69207. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69208. * the scaling factors are given in equation 9.
  69209. */
  69210. convertIncidentRadianceToIrradiance(): void;
  69211. /**
  69212. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69213. *
  69214. * ```
  69215. * L = (1/pi) * E * rho
  69216. * ```
  69217. *
  69218. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69219. */
  69220. convertIrradianceToLambertianRadiance(): void;
  69221. /**
  69222. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69223. * required operations at run time.
  69224. *
  69225. * This is simply done by scaling back the SH with Ylm constants parameter.
  69226. * The trigonometric part being applied by the shader at run time.
  69227. */
  69228. preScaleForRendering(): void;
  69229. /**
  69230. * Constructs a spherical harmonics from an array.
  69231. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69232. * @returns the spherical harmonics
  69233. */
  69234. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69235. /**
  69236. * Gets the spherical harmonics from polynomial
  69237. * @param polynomial the spherical polynomial
  69238. * @returns the spherical harmonics
  69239. */
  69240. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69241. }
  69242. /**
  69243. * Class representing spherical polynomial coefficients to the 3rd degree
  69244. */
  69245. export class SphericalPolynomial {
  69246. private _harmonics;
  69247. /**
  69248. * The spherical harmonics used to create the polynomials.
  69249. */
  69250. readonly preScaledHarmonics: SphericalHarmonics;
  69251. /**
  69252. * The x coefficients of the spherical polynomial
  69253. */
  69254. x: Vector3;
  69255. /**
  69256. * The y coefficients of the spherical polynomial
  69257. */
  69258. y: Vector3;
  69259. /**
  69260. * The z coefficients of the spherical polynomial
  69261. */
  69262. z: Vector3;
  69263. /**
  69264. * The xx coefficients of the spherical polynomial
  69265. */
  69266. xx: Vector3;
  69267. /**
  69268. * The yy coefficients of the spherical polynomial
  69269. */
  69270. yy: Vector3;
  69271. /**
  69272. * The zz coefficients of the spherical polynomial
  69273. */
  69274. zz: Vector3;
  69275. /**
  69276. * The xy coefficients of the spherical polynomial
  69277. */
  69278. xy: Vector3;
  69279. /**
  69280. * The yz coefficients of the spherical polynomial
  69281. */
  69282. yz: Vector3;
  69283. /**
  69284. * The zx coefficients of the spherical polynomial
  69285. */
  69286. zx: Vector3;
  69287. /**
  69288. * Adds an ambient color to the spherical polynomial
  69289. * @param color the color to add
  69290. */
  69291. addAmbient(color: Color3): void;
  69292. /**
  69293. * Scales the spherical polynomial by the given amount
  69294. * @param scale the amount to scale
  69295. */
  69296. scaleInPlace(scale: number): void;
  69297. /**
  69298. * Gets the spherical polynomial from harmonics
  69299. * @param harmonics the spherical harmonics
  69300. * @returns the spherical polynomial
  69301. */
  69302. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69303. /**
  69304. * Constructs a spherical polynomial from an array.
  69305. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69306. * @returns the spherical polynomial
  69307. */
  69308. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69309. }
  69310. }
  69311. declare module BABYLON {
  69312. /**
  69313. * Define options used to create a render target texture
  69314. */
  69315. export class RenderTargetCreationOptions {
  69316. /**
  69317. * Specifies is mipmaps must be generated
  69318. */
  69319. generateMipMaps?: boolean;
  69320. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69321. generateDepthBuffer?: boolean;
  69322. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69323. generateStencilBuffer?: boolean;
  69324. /** Defines texture type (int by default) */
  69325. type?: number;
  69326. /** Defines sampling mode (trilinear by default) */
  69327. samplingMode?: number;
  69328. /** Defines format (RGBA by default) */
  69329. format?: number;
  69330. }
  69331. }
  69332. declare module BABYLON {
  69333. /**
  69334. * @hidden
  69335. **/
  69336. export class _AlphaState {
  69337. private _isAlphaBlendDirty;
  69338. private _isBlendFunctionParametersDirty;
  69339. private _isBlendEquationParametersDirty;
  69340. private _isBlendConstantsDirty;
  69341. private _alphaBlend;
  69342. private _blendFunctionParameters;
  69343. private _blendEquationParameters;
  69344. private _blendConstants;
  69345. /**
  69346. * Initializes the state.
  69347. */
  69348. constructor();
  69349. readonly isDirty: boolean;
  69350. alphaBlend: boolean;
  69351. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69352. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69353. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69354. reset(): void;
  69355. apply(gl: WebGLRenderingContext): void;
  69356. }
  69357. }
  69358. declare module BABYLON {
  69359. /**
  69360. * @hidden
  69361. **/
  69362. export class _DepthCullingState {
  69363. private _isDepthTestDirty;
  69364. private _isDepthMaskDirty;
  69365. private _isDepthFuncDirty;
  69366. private _isCullFaceDirty;
  69367. private _isCullDirty;
  69368. private _isZOffsetDirty;
  69369. private _isFrontFaceDirty;
  69370. private _depthTest;
  69371. private _depthMask;
  69372. private _depthFunc;
  69373. private _cull;
  69374. private _cullFace;
  69375. private _zOffset;
  69376. private _frontFace;
  69377. /**
  69378. * Initializes the state.
  69379. */
  69380. constructor();
  69381. readonly isDirty: boolean;
  69382. zOffset: number;
  69383. cullFace: Nullable<number>;
  69384. cull: Nullable<boolean>;
  69385. depthFunc: Nullable<number>;
  69386. depthMask: boolean;
  69387. depthTest: boolean;
  69388. frontFace: Nullable<number>;
  69389. reset(): void;
  69390. apply(gl: WebGLRenderingContext): void;
  69391. }
  69392. }
  69393. declare module BABYLON {
  69394. /**
  69395. * @hidden
  69396. **/
  69397. export class _StencilState {
  69398. /** 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 */
  69399. static readonly ALWAYS: number;
  69400. /** Passed to stencilOperation to specify that stencil value must be kept */
  69401. static readonly KEEP: number;
  69402. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69403. static readonly REPLACE: number;
  69404. private _isStencilTestDirty;
  69405. private _isStencilMaskDirty;
  69406. private _isStencilFuncDirty;
  69407. private _isStencilOpDirty;
  69408. private _stencilTest;
  69409. private _stencilMask;
  69410. private _stencilFunc;
  69411. private _stencilFuncRef;
  69412. private _stencilFuncMask;
  69413. private _stencilOpStencilFail;
  69414. private _stencilOpDepthFail;
  69415. private _stencilOpStencilDepthPass;
  69416. readonly isDirty: boolean;
  69417. stencilFunc: number;
  69418. stencilFuncRef: number;
  69419. stencilFuncMask: number;
  69420. stencilOpStencilFail: number;
  69421. stencilOpDepthFail: number;
  69422. stencilOpStencilDepthPass: number;
  69423. stencilMask: number;
  69424. stencilTest: boolean;
  69425. constructor();
  69426. reset(): void;
  69427. apply(gl: WebGLRenderingContext): void;
  69428. }
  69429. }
  69430. declare module BABYLON {
  69431. /**
  69432. * @hidden
  69433. **/
  69434. export class _TimeToken {
  69435. _startTimeQuery: Nullable<WebGLQuery>;
  69436. _endTimeQuery: Nullable<WebGLQuery>;
  69437. _timeElapsedQuery: Nullable<WebGLQuery>;
  69438. _timeElapsedQueryEnded: boolean;
  69439. }
  69440. }
  69441. declare module BABYLON {
  69442. /**
  69443. * Class used to evalaute queries containing `and` and `or` operators
  69444. */
  69445. export class AndOrNotEvaluator {
  69446. /**
  69447. * Evaluate a query
  69448. * @param query defines the query to evaluate
  69449. * @param evaluateCallback defines the callback used to filter result
  69450. * @returns true if the query matches
  69451. */
  69452. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69453. private static _HandleParenthesisContent;
  69454. private static _SimplifyNegation;
  69455. }
  69456. }
  69457. declare module BABYLON {
  69458. /**
  69459. * Class used to store custom tags
  69460. */
  69461. export class Tags {
  69462. /**
  69463. * Adds support for tags on the given object
  69464. * @param obj defines the object to use
  69465. */
  69466. static EnableFor(obj: any): void;
  69467. /**
  69468. * Removes tags support
  69469. * @param obj defines the object to use
  69470. */
  69471. static DisableFor(obj: any): void;
  69472. /**
  69473. * Gets a boolean indicating if the given object has tags
  69474. * @param obj defines the object to use
  69475. * @returns a boolean
  69476. */
  69477. static HasTags(obj: any): boolean;
  69478. /**
  69479. * Gets the tags available on a given object
  69480. * @param obj defines the object to use
  69481. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69482. * @returns the tags
  69483. */
  69484. static GetTags(obj: any, asString?: boolean): any;
  69485. /**
  69486. * Adds tags to an object
  69487. * @param obj defines the object to use
  69488. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69489. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69490. */
  69491. static AddTagsTo(obj: any, tagsString: string): void;
  69492. /**
  69493. * @hidden
  69494. */
  69495. static _AddTagTo(obj: any, tag: string): void;
  69496. /**
  69497. * Removes specific tags from a specific object
  69498. * @param obj defines the object to use
  69499. * @param tagsString defines the tags to remove
  69500. */
  69501. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69502. /**
  69503. * @hidden
  69504. */
  69505. static _RemoveTagFrom(obj: any, tag: string): void;
  69506. /**
  69507. * Defines if tags hosted on an object match a given query
  69508. * @param obj defines the object to use
  69509. * @param tagsQuery defines the tag query
  69510. * @returns a boolean
  69511. */
  69512. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69513. }
  69514. }
  69515. declare module BABYLON {
  69516. /**
  69517. * Defines potential orientation for back face culling
  69518. */
  69519. export enum Orientation {
  69520. /**
  69521. * Clockwise
  69522. */
  69523. CW = 0,
  69524. /** Counter clockwise */
  69525. CCW = 1
  69526. }
  69527. /** Class used to represent a Bezier curve */
  69528. export class BezierCurve {
  69529. /**
  69530. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69531. * @param t defines the time
  69532. * @param x1 defines the left coordinate on X axis
  69533. * @param y1 defines the left coordinate on Y axis
  69534. * @param x2 defines the right coordinate on X axis
  69535. * @param y2 defines the right coordinate on Y axis
  69536. * @returns the interpolated value
  69537. */
  69538. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69539. }
  69540. /**
  69541. * Defines angle representation
  69542. */
  69543. export class Angle {
  69544. private _radians;
  69545. /**
  69546. * Creates an Angle object of "radians" radians (float).
  69547. * @param radians the angle in radians
  69548. */
  69549. constructor(radians: number);
  69550. /**
  69551. * Get value in degrees
  69552. * @returns the Angle value in degrees (float)
  69553. */
  69554. degrees(): number;
  69555. /**
  69556. * Get value in radians
  69557. * @returns the Angle value in radians (float)
  69558. */
  69559. radians(): number;
  69560. /**
  69561. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69562. * @param a defines first vector
  69563. * @param b defines second vector
  69564. * @returns a new Angle
  69565. */
  69566. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69567. /**
  69568. * Gets a new Angle object from the given float in radians
  69569. * @param radians defines the angle value in radians
  69570. * @returns a new Angle
  69571. */
  69572. static FromRadians(radians: number): Angle;
  69573. /**
  69574. * Gets a new Angle object from the given float in degrees
  69575. * @param degrees defines the angle value in degrees
  69576. * @returns a new Angle
  69577. */
  69578. static FromDegrees(degrees: number): Angle;
  69579. }
  69580. /**
  69581. * This represents an arc in a 2d space.
  69582. */
  69583. export class Arc2 {
  69584. /** Defines the start point of the arc */
  69585. startPoint: Vector2;
  69586. /** Defines the mid point of the arc */
  69587. midPoint: Vector2;
  69588. /** Defines the end point of the arc */
  69589. endPoint: Vector2;
  69590. /**
  69591. * Defines the center point of the arc.
  69592. */
  69593. centerPoint: Vector2;
  69594. /**
  69595. * Defines the radius of the arc.
  69596. */
  69597. radius: number;
  69598. /**
  69599. * Defines the angle of the arc (from mid point to end point).
  69600. */
  69601. angle: Angle;
  69602. /**
  69603. * Defines the start angle of the arc (from start point to middle point).
  69604. */
  69605. startAngle: Angle;
  69606. /**
  69607. * Defines the orientation of the arc (clock wise/counter clock wise).
  69608. */
  69609. orientation: Orientation;
  69610. /**
  69611. * Creates an Arc object from the three given points : start, middle and end.
  69612. * @param startPoint Defines the start point of the arc
  69613. * @param midPoint Defines the midlle point of the arc
  69614. * @param endPoint Defines the end point of the arc
  69615. */
  69616. constructor(
  69617. /** Defines the start point of the arc */
  69618. startPoint: Vector2,
  69619. /** Defines the mid point of the arc */
  69620. midPoint: Vector2,
  69621. /** Defines the end point of the arc */
  69622. endPoint: Vector2);
  69623. }
  69624. /**
  69625. * Represents a 2D path made up of multiple 2D points
  69626. */
  69627. export class Path2 {
  69628. private _points;
  69629. private _length;
  69630. /**
  69631. * If the path start and end point are the same
  69632. */
  69633. closed: boolean;
  69634. /**
  69635. * Creates a Path2 object from the starting 2D coordinates x and y.
  69636. * @param x the starting points x value
  69637. * @param y the starting points y value
  69638. */
  69639. constructor(x: number, y: number);
  69640. /**
  69641. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69642. * @param x the added points x value
  69643. * @param y the added points y value
  69644. * @returns the updated Path2.
  69645. */
  69646. addLineTo(x: number, y: number): Path2;
  69647. /**
  69648. * 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.
  69649. * @param midX middle point x value
  69650. * @param midY middle point y value
  69651. * @param endX end point x value
  69652. * @param endY end point y value
  69653. * @param numberOfSegments (default: 36)
  69654. * @returns the updated Path2.
  69655. */
  69656. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69657. /**
  69658. * Closes the Path2.
  69659. * @returns the Path2.
  69660. */
  69661. close(): Path2;
  69662. /**
  69663. * Gets the sum of the distance between each sequential point in the path
  69664. * @returns the Path2 total length (float).
  69665. */
  69666. length(): number;
  69667. /**
  69668. * Gets the points which construct the path
  69669. * @returns the Path2 internal array of points.
  69670. */
  69671. getPoints(): Vector2[];
  69672. /**
  69673. * Retreives the point at the distance aways from the starting point
  69674. * @param normalizedLengthPosition the length along the path to retreive the point from
  69675. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69676. */
  69677. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69678. /**
  69679. * Creates a new path starting from an x and y position
  69680. * @param x starting x value
  69681. * @param y starting y value
  69682. * @returns a new Path2 starting at the coordinates (x, y).
  69683. */
  69684. static StartingAt(x: number, y: number): Path2;
  69685. }
  69686. /**
  69687. * Represents a 3D path made up of multiple 3D points
  69688. */
  69689. export class Path3D {
  69690. /**
  69691. * an array of Vector3, the curve axis of the Path3D
  69692. */
  69693. path: Vector3[];
  69694. private _curve;
  69695. private _distances;
  69696. private _tangents;
  69697. private _normals;
  69698. private _binormals;
  69699. private _raw;
  69700. /**
  69701. * new Path3D(path, normal, raw)
  69702. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69703. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69704. * @param path an array of Vector3, the curve axis of the Path3D
  69705. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69706. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69707. */
  69708. constructor(
  69709. /**
  69710. * an array of Vector3, the curve axis of the Path3D
  69711. */
  69712. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69713. /**
  69714. * Returns the Path3D array of successive Vector3 designing its curve.
  69715. * @returns the Path3D array of successive Vector3 designing its curve.
  69716. */
  69717. getCurve(): Vector3[];
  69718. /**
  69719. * Returns an array populated with tangent vectors on each Path3D curve point.
  69720. * @returns an array populated with tangent vectors on each Path3D curve point.
  69721. */
  69722. getTangents(): Vector3[];
  69723. /**
  69724. * Returns an array populated with normal vectors on each Path3D curve point.
  69725. * @returns an array populated with normal vectors on each Path3D curve point.
  69726. */
  69727. getNormals(): Vector3[];
  69728. /**
  69729. * Returns an array populated with binormal vectors on each Path3D curve point.
  69730. * @returns an array populated with binormal vectors on each Path3D curve point.
  69731. */
  69732. getBinormals(): Vector3[];
  69733. /**
  69734. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69735. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69736. */
  69737. getDistances(): number[];
  69738. /**
  69739. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69740. * @param path path which all values are copied into the curves points
  69741. * @param firstNormal which should be projected onto the curve
  69742. * @returns the same object updated.
  69743. */
  69744. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69745. private _compute;
  69746. private _getFirstNonNullVector;
  69747. private _getLastNonNullVector;
  69748. private _normalVector;
  69749. }
  69750. /**
  69751. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69752. * A Curve3 is designed from a series of successive Vector3.
  69753. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69754. */
  69755. export class Curve3 {
  69756. private _points;
  69757. private _length;
  69758. /**
  69759. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69760. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69761. * @param v1 (Vector3) the control point
  69762. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69763. * @param nbPoints (integer) the wanted number of points in the curve
  69764. * @returns the created Curve3
  69765. */
  69766. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69767. /**
  69768. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69769. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69770. * @param v1 (Vector3) the first control point
  69771. * @param v2 (Vector3) the second control point
  69772. * @param v3 (Vector3) the end point of the Cubic Bezier
  69773. * @param nbPoints (integer) the wanted number of points in the curve
  69774. * @returns the created Curve3
  69775. */
  69776. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69777. /**
  69778. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69779. * @param p1 (Vector3) the origin point of the Hermite Spline
  69780. * @param t1 (Vector3) the tangent vector at the origin point
  69781. * @param p2 (Vector3) the end point of the Hermite Spline
  69782. * @param t2 (Vector3) the tangent vector at the end point
  69783. * @param nbPoints (integer) the wanted number of points in the curve
  69784. * @returns the created Curve3
  69785. */
  69786. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69787. /**
  69788. * Returns a Curve3 object along a CatmullRom Spline curve :
  69789. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69790. * @param nbPoints (integer) the wanted number of points between each curve control points
  69791. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69792. * @returns the created Curve3
  69793. */
  69794. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69795. /**
  69796. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69797. * A Curve3 is designed from a series of successive Vector3.
  69798. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69799. * @param points points which make up the curve
  69800. */
  69801. constructor(points: Vector3[]);
  69802. /**
  69803. * @returns the Curve3 stored array of successive Vector3
  69804. */
  69805. getPoints(): Vector3[];
  69806. /**
  69807. * @returns the computed length (float) of the curve.
  69808. */
  69809. length(): number;
  69810. /**
  69811. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69812. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69813. * curveA and curveB keep unchanged.
  69814. * @param curve the curve to continue from this curve
  69815. * @returns the newly constructed curve
  69816. */
  69817. continue(curve: DeepImmutable<Curve3>): Curve3;
  69818. private _computeLength;
  69819. }
  69820. }
  69821. declare module BABYLON {
  69822. /**
  69823. * This represents the main contract an easing function should follow.
  69824. * Easing functions are used throughout the animation system.
  69825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69826. */
  69827. export interface IEasingFunction {
  69828. /**
  69829. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69830. * of the easing function.
  69831. * The link below provides some of the most common examples of easing functions.
  69832. * @see https://easings.net/
  69833. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69834. * @returns the corresponding value on the curve defined by the easing function
  69835. */
  69836. ease(gradient: number): number;
  69837. }
  69838. /**
  69839. * Base class used for every default easing function.
  69840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69841. */
  69842. export class EasingFunction implements IEasingFunction {
  69843. /**
  69844. * Interpolation follows the mathematical formula associated with the easing function.
  69845. */
  69846. static readonly EASINGMODE_EASEIN: number;
  69847. /**
  69848. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69849. */
  69850. static readonly EASINGMODE_EASEOUT: number;
  69851. /**
  69852. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69853. */
  69854. static readonly EASINGMODE_EASEINOUT: number;
  69855. private _easingMode;
  69856. /**
  69857. * Sets the easing mode of the current function.
  69858. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69859. */
  69860. setEasingMode(easingMode: number): void;
  69861. /**
  69862. * Gets the current easing mode.
  69863. * @returns the easing mode
  69864. */
  69865. getEasingMode(): number;
  69866. /**
  69867. * @hidden
  69868. */
  69869. easeInCore(gradient: number): number;
  69870. /**
  69871. * Given an input gradient between 0 and 1, this returns the corresponding value
  69872. * of the easing function.
  69873. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69874. * @returns the corresponding value on the curve defined by the easing function
  69875. */
  69876. ease(gradient: number): number;
  69877. }
  69878. /**
  69879. * Easing function with a circle shape (see link below).
  69880. * @see https://easings.net/#easeInCirc
  69881. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69882. */
  69883. export class CircleEase extends EasingFunction implements IEasingFunction {
  69884. /** @hidden */
  69885. easeInCore(gradient: number): number;
  69886. }
  69887. /**
  69888. * Easing function with a ease back shape (see link below).
  69889. * @see https://easings.net/#easeInBack
  69890. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69891. */
  69892. export class BackEase extends EasingFunction implements IEasingFunction {
  69893. /** Defines the amplitude of the function */
  69894. amplitude: number;
  69895. /**
  69896. * Instantiates a back ease easing
  69897. * @see https://easings.net/#easeInBack
  69898. * @param amplitude Defines the amplitude of the function
  69899. */
  69900. constructor(
  69901. /** Defines the amplitude of the function */
  69902. amplitude?: number);
  69903. /** @hidden */
  69904. easeInCore(gradient: number): number;
  69905. }
  69906. /**
  69907. * Easing function with a bouncing shape (see link below).
  69908. * @see https://easings.net/#easeInBounce
  69909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69910. */
  69911. export class BounceEase extends EasingFunction implements IEasingFunction {
  69912. /** Defines the number of bounces */
  69913. bounces: number;
  69914. /** Defines the amplitude of the bounce */
  69915. bounciness: number;
  69916. /**
  69917. * Instantiates a bounce easing
  69918. * @see https://easings.net/#easeInBounce
  69919. * @param bounces Defines the number of bounces
  69920. * @param bounciness Defines the amplitude of the bounce
  69921. */
  69922. constructor(
  69923. /** Defines the number of bounces */
  69924. bounces?: number,
  69925. /** Defines the amplitude of the bounce */
  69926. bounciness?: number);
  69927. /** @hidden */
  69928. easeInCore(gradient: number): number;
  69929. }
  69930. /**
  69931. * Easing function with a power of 3 shape (see link below).
  69932. * @see https://easings.net/#easeInCubic
  69933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69934. */
  69935. export class CubicEase extends EasingFunction implements IEasingFunction {
  69936. /** @hidden */
  69937. easeInCore(gradient: number): number;
  69938. }
  69939. /**
  69940. * Easing function with an elastic shape (see link below).
  69941. * @see https://easings.net/#easeInElastic
  69942. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69943. */
  69944. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69945. /** Defines the number of oscillations*/
  69946. oscillations: number;
  69947. /** Defines the amplitude of the oscillations*/
  69948. springiness: number;
  69949. /**
  69950. * Instantiates an elastic easing function
  69951. * @see https://easings.net/#easeInElastic
  69952. * @param oscillations Defines the number of oscillations
  69953. * @param springiness Defines the amplitude of the oscillations
  69954. */
  69955. constructor(
  69956. /** Defines the number of oscillations*/
  69957. oscillations?: number,
  69958. /** Defines the amplitude of the oscillations*/
  69959. springiness?: number);
  69960. /** @hidden */
  69961. easeInCore(gradient: number): number;
  69962. }
  69963. /**
  69964. * Easing function with an exponential shape (see link below).
  69965. * @see https://easings.net/#easeInExpo
  69966. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69967. */
  69968. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69969. /** Defines the exponent of the function */
  69970. exponent: number;
  69971. /**
  69972. * Instantiates an exponential easing function
  69973. * @see https://easings.net/#easeInExpo
  69974. * @param exponent Defines the exponent of the function
  69975. */
  69976. constructor(
  69977. /** Defines the exponent of the function */
  69978. exponent?: number);
  69979. /** @hidden */
  69980. easeInCore(gradient: number): number;
  69981. }
  69982. /**
  69983. * Easing function with a power shape (see link below).
  69984. * @see https://easings.net/#easeInQuad
  69985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69986. */
  69987. export class PowerEase extends EasingFunction implements IEasingFunction {
  69988. /** Defines the power of the function */
  69989. power: number;
  69990. /**
  69991. * Instantiates an power base easing function
  69992. * @see https://easings.net/#easeInQuad
  69993. * @param power Defines the power of the function
  69994. */
  69995. constructor(
  69996. /** Defines the power of the function */
  69997. power?: number);
  69998. /** @hidden */
  69999. easeInCore(gradient: number): number;
  70000. }
  70001. /**
  70002. * Easing function with a power of 2 shape (see link below).
  70003. * @see https://easings.net/#easeInQuad
  70004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70005. */
  70006. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  70007. /** @hidden */
  70008. easeInCore(gradient: number): number;
  70009. }
  70010. /**
  70011. * Easing function with a power of 4 shape (see link below).
  70012. * @see https://easings.net/#easeInQuart
  70013. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70014. */
  70015. export class QuarticEase extends EasingFunction implements IEasingFunction {
  70016. /** @hidden */
  70017. easeInCore(gradient: number): number;
  70018. }
  70019. /**
  70020. * Easing function with a power of 5 shape (see link below).
  70021. * @see https://easings.net/#easeInQuint
  70022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70023. */
  70024. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70025. /** @hidden */
  70026. easeInCore(gradient: number): number;
  70027. }
  70028. /**
  70029. * Easing function with a sin shape (see link below).
  70030. * @see https://easings.net/#easeInSine
  70031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70032. */
  70033. export class SineEase extends EasingFunction implements IEasingFunction {
  70034. /** @hidden */
  70035. easeInCore(gradient: number): number;
  70036. }
  70037. /**
  70038. * Easing function with a bezier shape (see link below).
  70039. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70041. */
  70042. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70043. /** Defines the x component of the start tangent in the bezier curve */
  70044. x1: number;
  70045. /** Defines the y component of the start tangent in the bezier curve */
  70046. y1: number;
  70047. /** Defines the x component of the end tangent in the bezier curve */
  70048. x2: number;
  70049. /** Defines the y component of the end tangent in the bezier curve */
  70050. y2: number;
  70051. /**
  70052. * Instantiates a bezier function
  70053. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70054. * @param x1 Defines the x component of the start tangent in the bezier curve
  70055. * @param y1 Defines the y component of the start tangent in the bezier curve
  70056. * @param x2 Defines the x component of the end tangent in the bezier curve
  70057. * @param y2 Defines the y component of the end tangent in the bezier curve
  70058. */
  70059. constructor(
  70060. /** Defines the x component of the start tangent in the bezier curve */
  70061. x1?: number,
  70062. /** Defines the y component of the start tangent in the bezier curve */
  70063. y1?: number,
  70064. /** Defines the x component of the end tangent in the bezier curve */
  70065. x2?: number,
  70066. /** Defines the y component of the end tangent in the bezier curve */
  70067. y2?: number);
  70068. /** @hidden */
  70069. easeInCore(gradient: number): number;
  70070. }
  70071. }
  70072. declare module BABYLON {
  70073. /**
  70074. * Defines an interface which represents an animation key frame
  70075. */
  70076. export interface IAnimationKey {
  70077. /**
  70078. * Frame of the key frame
  70079. */
  70080. frame: number;
  70081. /**
  70082. * Value at the specifies key frame
  70083. */
  70084. value: any;
  70085. /**
  70086. * The input tangent for the cubic hermite spline
  70087. */
  70088. inTangent?: any;
  70089. /**
  70090. * The output tangent for the cubic hermite spline
  70091. */
  70092. outTangent?: any;
  70093. /**
  70094. * The animation interpolation type
  70095. */
  70096. interpolation?: AnimationKeyInterpolation;
  70097. }
  70098. /**
  70099. * Enum for the animation key frame interpolation type
  70100. */
  70101. export enum AnimationKeyInterpolation {
  70102. /**
  70103. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70104. */
  70105. STEP = 1
  70106. }
  70107. }
  70108. declare module BABYLON {
  70109. /**
  70110. * Represents the range of an animation
  70111. */
  70112. export class AnimationRange {
  70113. /**The name of the animation range**/
  70114. name: string;
  70115. /**The starting frame of the animation */
  70116. from: number;
  70117. /**The ending frame of the animation*/
  70118. to: number;
  70119. /**
  70120. * Initializes the range of an animation
  70121. * @param name The name of the animation range
  70122. * @param from The starting frame of the animation
  70123. * @param to The ending frame of the animation
  70124. */
  70125. constructor(
  70126. /**The name of the animation range**/
  70127. name: string,
  70128. /**The starting frame of the animation */
  70129. from: number,
  70130. /**The ending frame of the animation*/
  70131. to: number);
  70132. /**
  70133. * Makes a copy of the animation range
  70134. * @returns A copy of the animation range
  70135. */
  70136. clone(): AnimationRange;
  70137. }
  70138. }
  70139. declare module BABYLON {
  70140. /**
  70141. * Composed of a frame, and an action function
  70142. */
  70143. export class AnimationEvent {
  70144. /** The frame for which the event is triggered **/
  70145. frame: number;
  70146. /** The event to perform when triggered **/
  70147. action: (currentFrame: number) => void;
  70148. /** Specifies if the event should be triggered only once**/
  70149. onlyOnce?: boolean | undefined;
  70150. /**
  70151. * Specifies if the animation event is done
  70152. */
  70153. isDone: boolean;
  70154. /**
  70155. * Initializes the animation event
  70156. * @param frame The frame for which the event is triggered
  70157. * @param action The event to perform when triggered
  70158. * @param onlyOnce Specifies if the event should be triggered only once
  70159. */
  70160. constructor(
  70161. /** The frame for which the event is triggered **/
  70162. frame: number,
  70163. /** The event to perform when triggered **/
  70164. action: (currentFrame: number) => void,
  70165. /** Specifies if the event should be triggered only once**/
  70166. onlyOnce?: boolean | undefined);
  70167. /** @hidden */
  70168. _clone(): AnimationEvent;
  70169. }
  70170. }
  70171. declare module BABYLON {
  70172. /**
  70173. * Interface used to define a behavior
  70174. */
  70175. export interface Behavior<T> {
  70176. /** gets or sets behavior's name */
  70177. name: string;
  70178. /**
  70179. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70180. */
  70181. init(): void;
  70182. /**
  70183. * Called when the behavior is attached to a target
  70184. * @param target defines the target where the behavior is attached to
  70185. */
  70186. attach(target: T): void;
  70187. /**
  70188. * Called when the behavior is detached from its target
  70189. */
  70190. detach(): void;
  70191. }
  70192. /**
  70193. * Interface implemented by classes supporting behaviors
  70194. */
  70195. export interface IBehaviorAware<T> {
  70196. /**
  70197. * Attach a behavior
  70198. * @param behavior defines the behavior to attach
  70199. * @returns the current host
  70200. */
  70201. addBehavior(behavior: Behavior<T>): T;
  70202. /**
  70203. * Remove a behavior from the current object
  70204. * @param behavior defines the behavior to detach
  70205. * @returns the current host
  70206. */
  70207. removeBehavior(behavior: Behavior<T>): T;
  70208. /**
  70209. * Gets a behavior using its name to search
  70210. * @param name defines the name to search
  70211. * @returns the behavior or null if not found
  70212. */
  70213. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70214. }
  70215. }
  70216. declare module BABYLON {
  70217. /**
  70218. * Defines an array and its length.
  70219. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70220. */
  70221. export interface ISmartArrayLike<T> {
  70222. /**
  70223. * The data of the array.
  70224. */
  70225. data: Array<T>;
  70226. /**
  70227. * The active length of the array.
  70228. */
  70229. length: number;
  70230. }
  70231. /**
  70232. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70233. */
  70234. export class SmartArray<T> implements ISmartArrayLike<T> {
  70235. /**
  70236. * The full set of data from the array.
  70237. */
  70238. data: Array<T>;
  70239. /**
  70240. * The active length of the array.
  70241. */
  70242. length: number;
  70243. protected _id: number;
  70244. /**
  70245. * Instantiates a Smart Array.
  70246. * @param capacity defines the default capacity of the array.
  70247. */
  70248. constructor(capacity: number);
  70249. /**
  70250. * Pushes a value at the end of the active data.
  70251. * @param value defines the object to push in the array.
  70252. */
  70253. push(value: T): void;
  70254. /**
  70255. * Iterates over the active data and apply the lambda to them.
  70256. * @param func defines the action to apply on each value.
  70257. */
  70258. forEach(func: (content: T) => void): void;
  70259. /**
  70260. * Sorts the full sets of data.
  70261. * @param compareFn defines the comparison function to apply.
  70262. */
  70263. sort(compareFn: (a: T, b: T) => number): void;
  70264. /**
  70265. * Resets the active data to an empty array.
  70266. */
  70267. reset(): void;
  70268. /**
  70269. * Releases all the data from the array as well as the array.
  70270. */
  70271. dispose(): void;
  70272. /**
  70273. * Concats the active data with a given array.
  70274. * @param array defines the data to concatenate with.
  70275. */
  70276. concat(array: any): void;
  70277. /**
  70278. * Returns the position of a value in the active data.
  70279. * @param value defines the value to find the index for
  70280. * @returns the index if found in the active data otherwise -1
  70281. */
  70282. indexOf(value: T): number;
  70283. /**
  70284. * Returns whether an element is part of the active data.
  70285. * @param value defines the value to look for
  70286. * @returns true if found in the active data otherwise false
  70287. */
  70288. contains(value: T): boolean;
  70289. private static _GlobalId;
  70290. }
  70291. /**
  70292. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70293. * The data in this array can only be present once
  70294. */
  70295. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70296. private _duplicateId;
  70297. /**
  70298. * Pushes a value at the end of the active data.
  70299. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70300. * @param value defines the object to push in the array.
  70301. */
  70302. push(value: T): void;
  70303. /**
  70304. * Pushes a value at the end of the active data.
  70305. * If the data is already present, it won t be added again
  70306. * @param value defines the object to push in the array.
  70307. * @returns true if added false if it was already present
  70308. */
  70309. pushNoDuplicate(value: T): boolean;
  70310. /**
  70311. * Resets the active data to an empty array.
  70312. */
  70313. reset(): void;
  70314. /**
  70315. * Concats the active data with a given array.
  70316. * This ensures no dupplicate will be present in the result.
  70317. * @param array defines the data to concatenate with.
  70318. */
  70319. concatWithNoDuplicate(array: any): void;
  70320. }
  70321. }
  70322. declare module BABYLON {
  70323. /**
  70324. * @ignore
  70325. * This is a list of all the different input types that are available in the application.
  70326. * Fo instance: ArcRotateCameraGamepadInput...
  70327. */
  70328. export var CameraInputTypes: {};
  70329. /**
  70330. * This is the contract to implement in order to create a new input class.
  70331. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70332. */
  70333. export interface ICameraInput<TCamera extends Camera> {
  70334. /**
  70335. * Defines the camera the input is attached to.
  70336. */
  70337. camera: Nullable<TCamera>;
  70338. /**
  70339. * Gets the class name of the current intput.
  70340. * @returns the class name
  70341. */
  70342. getClassName(): string;
  70343. /**
  70344. * Get the friendly name associated with the input class.
  70345. * @returns the input friendly name
  70346. */
  70347. getSimpleName(): string;
  70348. /**
  70349. * Attach the input controls to a specific dom element to get the input from.
  70350. * @param element Defines the element the controls should be listened from
  70351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70352. */
  70353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70354. /**
  70355. * Detach the current controls from the specified dom element.
  70356. * @param element Defines the element to stop listening the inputs from
  70357. */
  70358. detachControl(element: Nullable<HTMLElement>): void;
  70359. /**
  70360. * Update the current camera state depending on the inputs that have been used this frame.
  70361. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70362. */
  70363. checkInputs?: () => void;
  70364. }
  70365. /**
  70366. * Represents a map of input types to input instance or input index to input instance.
  70367. */
  70368. export interface CameraInputsMap<TCamera extends Camera> {
  70369. /**
  70370. * Accessor to the input by input type.
  70371. */
  70372. [name: string]: ICameraInput<TCamera>;
  70373. /**
  70374. * Accessor to the input by input index.
  70375. */
  70376. [idx: number]: ICameraInput<TCamera>;
  70377. }
  70378. /**
  70379. * This represents the input manager used within a camera.
  70380. * It helps dealing with all the different kind of input attached to a camera.
  70381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70382. */
  70383. export class CameraInputsManager<TCamera extends Camera> {
  70384. /**
  70385. * Defines the list of inputs attahed to the camera.
  70386. */
  70387. attached: CameraInputsMap<TCamera>;
  70388. /**
  70389. * Defines the dom element the camera is collecting inputs from.
  70390. * This is null if the controls have not been attached.
  70391. */
  70392. attachedElement: Nullable<HTMLElement>;
  70393. /**
  70394. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70395. */
  70396. noPreventDefault: boolean;
  70397. /**
  70398. * Defined the camera the input manager belongs to.
  70399. */
  70400. camera: TCamera;
  70401. /**
  70402. * Update the current camera state depending on the inputs that have been used this frame.
  70403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70404. */
  70405. checkInputs: () => void;
  70406. /**
  70407. * Instantiate a new Camera Input Manager.
  70408. * @param camera Defines the camera the input manager blongs to
  70409. */
  70410. constructor(camera: TCamera);
  70411. /**
  70412. * Add an input method to a camera
  70413. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70414. * @param input camera input method
  70415. */
  70416. add(input: ICameraInput<TCamera>): void;
  70417. /**
  70418. * Remove a specific input method from a camera
  70419. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70420. * @param inputToRemove camera input method
  70421. */
  70422. remove(inputToRemove: ICameraInput<TCamera>): void;
  70423. /**
  70424. * Remove a specific input type from a camera
  70425. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70426. * @param inputType the type of the input to remove
  70427. */
  70428. removeByType(inputType: string): void;
  70429. private _addCheckInputs;
  70430. /**
  70431. * Attach the input controls to the currently attached dom element to listen the events from.
  70432. * @param input Defines the input to attach
  70433. */
  70434. attachInput(input: ICameraInput<TCamera>): void;
  70435. /**
  70436. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70437. * @param element Defines the dom element to collect the events from
  70438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70439. */
  70440. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70441. /**
  70442. * Detach the current manager inputs controls from a specific dom element.
  70443. * @param element Defines the dom element to collect the events from
  70444. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70445. */
  70446. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70447. /**
  70448. * Rebuild the dynamic inputCheck function from the current list of
  70449. * defined inputs in the manager.
  70450. */
  70451. rebuildInputCheck(): void;
  70452. /**
  70453. * Remove all attached input methods from a camera
  70454. */
  70455. clear(): void;
  70456. /**
  70457. * Serialize the current input manager attached to a camera.
  70458. * This ensures than once parsed,
  70459. * the input associated to the camera will be identical to the current ones
  70460. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70461. */
  70462. serialize(serializedCamera: any): void;
  70463. /**
  70464. * Parses an input manager serialized JSON to restore the previous list of inputs
  70465. * and states associated to a camera.
  70466. * @param parsedCamera Defines the JSON to parse
  70467. */
  70468. parse(parsedCamera: any): void;
  70469. }
  70470. }
  70471. declare module BABYLON {
  70472. /**
  70473. * @hidden
  70474. */
  70475. export class IntersectionInfo {
  70476. bu: Nullable<number>;
  70477. bv: Nullable<number>;
  70478. distance: number;
  70479. faceId: number;
  70480. subMeshId: number;
  70481. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70482. }
  70483. }
  70484. declare module BABYLON {
  70485. /**
  70486. * Represens a plane by the equation ax + by + cz + d = 0
  70487. */
  70488. export class Plane {
  70489. private static _TmpMatrix;
  70490. /**
  70491. * Normal of the plane (a,b,c)
  70492. */
  70493. normal: Vector3;
  70494. /**
  70495. * d component of the plane
  70496. */
  70497. d: number;
  70498. /**
  70499. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70500. * @param a a component of the plane
  70501. * @param b b component of the plane
  70502. * @param c c component of the plane
  70503. * @param d d component of the plane
  70504. */
  70505. constructor(a: number, b: number, c: number, d: number);
  70506. /**
  70507. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70508. */
  70509. asArray(): number[];
  70510. /**
  70511. * @returns a new plane copied from the current Plane.
  70512. */
  70513. clone(): Plane;
  70514. /**
  70515. * @returns the string "Plane".
  70516. */
  70517. getClassName(): string;
  70518. /**
  70519. * @returns the Plane hash code.
  70520. */
  70521. getHashCode(): number;
  70522. /**
  70523. * Normalize the current Plane in place.
  70524. * @returns the updated Plane.
  70525. */
  70526. normalize(): Plane;
  70527. /**
  70528. * Applies a transformation the plane and returns the result
  70529. * @param transformation the transformation matrix to be applied to the plane
  70530. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70531. */
  70532. transform(transformation: DeepImmutable<Matrix>): Plane;
  70533. /**
  70534. * Calcualtte the dot product between the point and the plane normal
  70535. * @param point point to calculate the dot product with
  70536. * @returns the dot product (float) of the point coordinates and the plane normal.
  70537. */
  70538. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70539. /**
  70540. * Updates the current Plane from the plane defined by the three given points.
  70541. * @param point1 one of the points used to contruct the plane
  70542. * @param point2 one of the points used to contruct the plane
  70543. * @param point3 one of the points used to contruct the plane
  70544. * @returns the updated Plane.
  70545. */
  70546. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70547. /**
  70548. * Checks if the plane is facing a given direction
  70549. * @param direction the direction to check if the plane is facing
  70550. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70551. * @returns True is the vector "direction" is the same side than the plane normal.
  70552. */
  70553. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70554. /**
  70555. * Calculates the distance to a point
  70556. * @param point point to calculate distance to
  70557. * @returns the signed distance (float) from the given point to the Plane.
  70558. */
  70559. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70560. /**
  70561. * Creates a plane from an array
  70562. * @param array the array to create a plane from
  70563. * @returns a new Plane from the given array.
  70564. */
  70565. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70566. /**
  70567. * Creates a plane from three points
  70568. * @param point1 point used to create the plane
  70569. * @param point2 point used to create the plane
  70570. * @param point3 point used to create the plane
  70571. * @returns a new Plane defined by the three given points.
  70572. */
  70573. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70574. /**
  70575. * Creates a plane from an origin point and a normal
  70576. * @param origin origin of the plane to be constructed
  70577. * @param normal normal of the plane to be constructed
  70578. * @returns a new Plane the normal vector to this plane at the given origin point.
  70579. * Note : the vector "normal" is updated because normalized.
  70580. */
  70581. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70582. /**
  70583. * Calculates the distance from a plane and a point
  70584. * @param origin origin of the plane to be constructed
  70585. * @param normal normal of the plane to be constructed
  70586. * @param point point to calculate distance to
  70587. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70588. */
  70589. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /**
  70594. * Class used to store bounding sphere information
  70595. */
  70596. export class BoundingSphere {
  70597. /**
  70598. * Gets the center of the bounding sphere in local space
  70599. */
  70600. readonly center: Vector3;
  70601. /**
  70602. * Radius of the bounding sphere in local space
  70603. */
  70604. radius: number;
  70605. /**
  70606. * Gets the center of the bounding sphere in world space
  70607. */
  70608. readonly centerWorld: Vector3;
  70609. /**
  70610. * Radius of the bounding sphere in world space
  70611. */
  70612. radiusWorld: number;
  70613. /**
  70614. * Gets the minimum vector in local space
  70615. */
  70616. readonly minimum: Vector3;
  70617. /**
  70618. * Gets the maximum vector in local space
  70619. */
  70620. readonly maximum: Vector3;
  70621. private _worldMatrix;
  70622. private static readonly TmpVector3;
  70623. /**
  70624. * Creates a new bounding sphere
  70625. * @param min defines the minimum vector (in local space)
  70626. * @param max defines the maximum vector (in local space)
  70627. * @param worldMatrix defines the new world matrix
  70628. */
  70629. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70630. /**
  70631. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70632. * @param min defines the new minimum vector (in local space)
  70633. * @param max defines the new maximum vector (in local space)
  70634. * @param worldMatrix defines the new world matrix
  70635. */
  70636. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70637. /**
  70638. * Scale the current bounding sphere by applying a scale factor
  70639. * @param factor defines the scale factor to apply
  70640. * @returns the current bounding box
  70641. */
  70642. scale(factor: number): BoundingSphere;
  70643. /**
  70644. * Gets the world matrix of the bounding box
  70645. * @returns a matrix
  70646. */
  70647. getWorldMatrix(): DeepImmutable<Matrix>;
  70648. /** @hidden */
  70649. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70650. /**
  70651. * Tests if the bounding sphere is intersecting the frustum planes
  70652. * @param frustumPlanes defines the frustum planes to test
  70653. * @returns true if there is an intersection
  70654. */
  70655. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70656. /**
  70657. * Tests if the bounding sphere center is in between the frustum planes.
  70658. * Used for optimistic fast inclusion.
  70659. * @param frustumPlanes defines the frustum planes to test
  70660. * @returns true if the sphere center is in between the frustum planes
  70661. */
  70662. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70663. /**
  70664. * Tests if a point is inside the bounding sphere
  70665. * @param point defines the point to test
  70666. * @returns true if the point is inside the bounding sphere
  70667. */
  70668. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70669. /**
  70670. * Checks if two sphere intersct
  70671. * @param sphere0 sphere 0
  70672. * @param sphere1 sphere 1
  70673. * @returns true if the speres intersect
  70674. */
  70675. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70676. }
  70677. }
  70678. declare module BABYLON {
  70679. /**
  70680. * Class used to store bounding box information
  70681. */
  70682. export class BoundingBox implements ICullable {
  70683. /**
  70684. * Gets the 8 vectors representing the bounding box in local space
  70685. */
  70686. readonly vectors: Vector3[];
  70687. /**
  70688. * Gets the center of the bounding box in local space
  70689. */
  70690. readonly center: Vector3;
  70691. /**
  70692. * Gets the center of the bounding box in world space
  70693. */
  70694. readonly centerWorld: Vector3;
  70695. /**
  70696. * Gets the extend size in local space
  70697. */
  70698. readonly extendSize: Vector3;
  70699. /**
  70700. * Gets the extend size in world space
  70701. */
  70702. readonly extendSizeWorld: Vector3;
  70703. /**
  70704. * Gets the OBB (object bounding box) directions
  70705. */
  70706. readonly directions: Vector3[];
  70707. /**
  70708. * Gets the 8 vectors representing the bounding box in world space
  70709. */
  70710. readonly vectorsWorld: Vector3[];
  70711. /**
  70712. * Gets the minimum vector in world space
  70713. */
  70714. readonly minimumWorld: Vector3;
  70715. /**
  70716. * Gets the maximum vector in world space
  70717. */
  70718. readonly maximumWorld: Vector3;
  70719. /**
  70720. * Gets the minimum vector in local space
  70721. */
  70722. readonly minimum: Vector3;
  70723. /**
  70724. * Gets the maximum vector in local space
  70725. */
  70726. readonly maximum: Vector3;
  70727. private _worldMatrix;
  70728. private static readonly TmpVector3;
  70729. /**
  70730. * @hidden
  70731. */
  70732. _tag: number;
  70733. /**
  70734. * Creates a new bounding box
  70735. * @param min defines the minimum vector (in local space)
  70736. * @param max defines the maximum vector (in local space)
  70737. * @param worldMatrix defines the new world matrix
  70738. */
  70739. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70740. /**
  70741. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70742. * @param min defines the new minimum vector (in local space)
  70743. * @param max defines the new maximum vector (in local space)
  70744. * @param worldMatrix defines the new world matrix
  70745. */
  70746. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70747. /**
  70748. * Scale the current bounding box by applying a scale factor
  70749. * @param factor defines the scale factor to apply
  70750. * @returns the current bounding box
  70751. */
  70752. scale(factor: number): BoundingBox;
  70753. /**
  70754. * Gets the world matrix of the bounding box
  70755. * @returns a matrix
  70756. */
  70757. getWorldMatrix(): DeepImmutable<Matrix>;
  70758. /** @hidden */
  70759. _update(world: DeepImmutable<Matrix>): void;
  70760. /**
  70761. * Tests if the bounding box is intersecting the frustum planes
  70762. * @param frustumPlanes defines the frustum planes to test
  70763. * @returns true if there is an intersection
  70764. */
  70765. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70766. /**
  70767. * Tests if the bounding box is entirely inside the frustum planes
  70768. * @param frustumPlanes defines the frustum planes to test
  70769. * @returns true if there is an inclusion
  70770. */
  70771. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70772. /**
  70773. * Tests if a point is inside the bounding box
  70774. * @param point defines the point to test
  70775. * @returns true if the point is inside the bounding box
  70776. */
  70777. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70778. /**
  70779. * Tests if the bounding box intersects with a bounding sphere
  70780. * @param sphere defines the sphere to test
  70781. * @returns true if there is an intersection
  70782. */
  70783. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70784. /**
  70785. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70786. * @param min defines the min vector to use
  70787. * @param max defines the max vector to use
  70788. * @returns true if there is an intersection
  70789. */
  70790. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70791. /**
  70792. * Tests if two bounding boxes are intersections
  70793. * @param box0 defines the first box to test
  70794. * @param box1 defines the second box to test
  70795. * @returns true if there is an intersection
  70796. */
  70797. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70798. /**
  70799. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70800. * @param minPoint defines the minimum vector of the bounding box
  70801. * @param maxPoint defines the maximum vector of the bounding box
  70802. * @param sphereCenter defines the sphere center
  70803. * @param sphereRadius defines the sphere radius
  70804. * @returns true if there is an intersection
  70805. */
  70806. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70807. /**
  70808. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70809. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70810. * @param frustumPlanes defines the frustum planes to test
  70811. * @return true if there is an inclusion
  70812. */
  70813. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70814. /**
  70815. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70816. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70817. * @param frustumPlanes defines the frustum planes to test
  70818. * @return true if there is an intersection
  70819. */
  70820. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70821. }
  70822. }
  70823. declare module BABYLON {
  70824. /** @hidden */
  70825. export class Collider {
  70826. /** Define if a collision was found */
  70827. collisionFound: boolean;
  70828. /**
  70829. * Define last intersection point in local space
  70830. */
  70831. intersectionPoint: Vector3;
  70832. /**
  70833. * Define last collided mesh
  70834. */
  70835. collidedMesh: Nullable<AbstractMesh>;
  70836. private _collisionPoint;
  70837. private _planeIntersectionPoint;
  70838. private _tempVector;
  70839. private _tempVector2;
  70840. private _tempVector3;
  70841. private _tempVector4;
  70842. private _edge;
  70843. private _baseToVertex;
  70844. private _destinationPoint;
  70845. private _slidePlaneNormal;
  70846. private _displacementVector;
  70847. /** @hidden */
  70848. _radius: Vector3;
  70849. /** @hidden */
  70850. _retry: number;
  70851. private _velocity;
  70852. private _basePoint;
  70853. private _epsilon;
  70854. /** @hidden */
  70855. _velocityWorldLength: number;
  70856. /** @hidden */
  70857. _basePointWorld: Vector3;
  70858. private _velocityWorld;
  70859. private _normalizedVelocity;
  70860. /** @hidden */
  70861. _initialVelocity: Vector3;
  70862. /** @hidden */
  70863. _initialPosition: Vector3;
  70864. private _nearestDistance;
  70865. private _collisionMask;
  70866. collisionMask: number;
  70867. /**
  70868. * Gets the plane normal used to compute the sliding response (in local space)
  70869. */
  70870. readonly slidePlaneNormal: Vector3;
  70871. /** @hidden */
  70872. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70873. /** @hidden */
  70874. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70875. /** @hidden */
  70876. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70877. /** @hidden */
  70878. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70879. /** @hidden */
  70880. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70881. /** @hidden */
  70882. _getResponse(pos: Vector3, vel: Vector3): void;
  70883. }
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * Interface for cullable objects
  70888. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70889. */
  70890. export interface ICullable {
  70891. /**
  70892. * Checks if the object or part of the object is in the frustum
  70893. * @param frustumPlanes Camera near/planes
  70894. * @returns true if the object is in frustum otherwise false
  70895. */
  70896. isInFrustum(frustumPlanes: Plane[]): boolean;
  70897. /**
  70898. * Checks if a cullable object (mesh...) is in the camera frustum
  70899. * Unlike isInFrustum this cheks the full bounding box
  70900. * @param frustumPlanes Camera near/planes
  70901. * @returns true if the object is in frustum otherwise false
  70902. */
  70903. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70904. }
  70905. /**
  70906. * Info for a bounding data of a mesh
  70907. */
  70908. export class BoundingInfo implements ICullable {
  70909. /**
  70910. * Bounding box for the mesh
  70911. */
  70912. readonly boundingBox: BoundingBox;
  70913. /**
  70914. * Bounding sphere for the mesh
  70915. */
  70916. readonly boundingSphere: BoundingSphere;
  70917. private _isLocked;
  70918. private static readonly TmpVector3;
  70919. /**
  70920. * Constructs bounding info
  70921. * @param minimum min vector of the bounding box/sphere
  70922. * @param maximum max vector of the bounding box/sphere
  70923. * @param worldMatrix defines the new world matrix
  70924. */
  70925. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70926. /**
  70927. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70928. * @param min defines the new minimum vector (in local space)
  70929. * @param max defines the new maximum vector (in local space)
  70930. * @param worldMatrix defines the new world matrix
  70931. */
  70932. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70933. /**
  70934. * min vector of the bounding box/sphere
  70935. */
  70936. readonly minimum: Vector3;
  70937. /**
  70938. * max vector of the bounding box/sphere
  70939. */
  70940. readonly maximum: Vector3;
  70941. /**
  70942. * If the info is locked and won't be updated to avoid perf overhead
  70943. */
  70944. isLocked: boolean;
  70945. /**
  70946. * Updates the bounding sphere and box
  70947. * @param world world matrix to be used to update
  70948. */
  70949. update(world: DeepImmutable<Matrix>): void;
  70950. /**
  70951. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70952. * @param center New center of the bounding info
  70953. * @param extend New extend of the bounding info
  70954. * @returns the current bounding info
  70955. */
  70956. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70957. /**
  70958. * Scale the current bounding info by applying a scale factor
  70959. * @param factor defines the scale factor to apply
  70960. * @returns the current bounding info
  70961. */
  70962. scale(factor: number): BoundingInfo;
  70963. /**
  70964. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70965. * @param frustumPlanes defines the frustum to test
  70966. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70967. * @returns true if the bounding info is in the frustum planes
  70968. */
  70969. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70970. /**
  70971. * Gets the world distance between the min and max points of the bounding box
  70972. */
  70973. readonly diagonalLength: number;
  70974. /**
  70975. * Checks if a cullable object (mesh...) is in the camera frustum
  70976. * Unlike isInFrustum this cheks the full bounding box
  70977. * @param frustumPlanes Camera near/planes
  70978. * @returns true if the object is in frustum otherwise false
  70979. */
  70980. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70981. /** @hidden */
  70982. _checkCollision(collider: Collider): boolean;
  70983. /**
  70984. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70985. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70986. * @param point the point to check intersection with
  70987. * @returns if the point intersects
  70988. */
  70989. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70990. /**
  70991. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70992. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70993. * @param boundingInfo the bounding info to check intersection with
  70994. * @param precise if the intersection should be done using OBB
  70995. * @returns if the bounding info intersects
  70996. */
  70997. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70998. }
  70999. }
  71000. declare module BABYLON {
  71001. /**
  71002. * Extracts minimum and maximum values from a list of indexed positions
  71003. * @param positions defines the positions to use
  71004. * @param indices defines the indices to the positions
  71005. * @param indexStart defines the start index
  71006. * @param indexCount defines the end index
  71007. * @param bias defines bias value to add to the result
  71008. * @return minimum and maximum values
  71009. */
  71010. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  71011. minimum: Vector3;
  71012. maximum: Vector3;
  71013. };
  71014. /**
  71015. * Extracts minimum and maximum values from a list of positions
  71016. * @param positions defines the positions to use
  71017. * @param start defines the start index in the positions array
  71018. * @param count defines the number of positions to handle
  71019. * @param bias defines bias value to add to the result
  71020. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71021. * @return minimum and maximum values
  71022. */
  71023. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71024. minimum: Vector3;
  71025. maximum: Vector3;
  71026. };
  71027. }
  71028. declare module BABYLON {
  71029. /**
  71030. * Enum that determines the text-wrapping mode to use.
  71031. */
  71032. export enum InspectableType {
  71033. /**
  71034. * Checkbox for booleans
  71035. */
  71036. Checkbox = 0,
  71037. /**
  71038. * Sliders for numbers
  71039. */
  71040. Slider = 1,
  71041. /**
  71042. * Vector3
  71043. */
  71044. Vector3 = 2,
  71045. /**
  71046. * Quaternions
  71047. */
  71048. Quaternion = 3,
  71049. /**
  71050. * Color3
  71051. */
  71052. Color3 = 4,
  71053. /**
  71054. * String
  71055. */
  71056. String = 5
  71057. }
  71058. /**
  71059. * Interface used to define custom inspectable properties.
  71060. * This interface is used by the inspector to display custom property grids
  71061. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71062. */
  71063. export interface IInspectable {
  71064. /**
  71065. * Gets the label to display
  71066. */
  71067. label: string;
  71068. /**
  71069. * Gets the name of the property to edit
  71070. */
  71071. propertyName: string;
  71072. /**
  71073. * Gets the type of the editor to use
  71074. */
  71075. type: InspectableType;
  71076. /**
  71077. * Gets the minimum value of the property when using in "slider" mode
  71078. */
  71079. min?: number;
  71080. /**
  71081. * Gets the maximum value of the property when using in "slider" mode
  71082. */
  71083. max?: number;
  71084. /**
  71085. * Gets the setp to use when using in "slider" mode
  71086. */
  71087. step?: number;
  71088. }
  71089. }
  71090. declare module BABYLON {
  71091. /**
  71092. * Class used to provide helper for timing
  71093. */
  71094. export class TimingTools {
  71095. /**
  71096. * Polyfill for setImmediate
  71097. * @param action defines the action to execute after the current execution block
  71098. */
  71099. static SetImmediate(action: () => void): void;
  71100. }
  71101. }
  71102. declare module BABYLON {
  71103. /**
  71104. * Class used to enable instatition of objects by class name
  71105. */
  71106. export class InstantiationTools {
  71107. /**
  71108. * Use this object to register external classes like custom textures or material
  71109. * to allow the laoders to instantiate them
  71110. */
  71111. static RegisteredExternalClasses: {
  71112. [key: string]: Object;
  71113. };
  71114. /**
  71115. * Tries to instantiate a new object from a given class name
  71116. * @param className defines the class name to instantiate
  71117. * @returns the new object or null if the system was not able to do the instantiation
  71118. */
  71119. static Instantiate(className: string): any;
  71120. }
  71121. }
  71122. declare module BABYLON {
  71123. /**
  71124. * This represents the required contract to create a new type of texture loader.
  71125. */
  71126. export interface IInternalTextureLoader {
  71127. /**
  71128. * Defines wether the loader supports cascade loading the different faces.
  71129. */
  71130. supportCascades: boolean;
  71131. /**
  71132. * This returns if the loader support the current file information.
  71133. * @param extension defines the file extension of the file being loaded
  71134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71135. * @param fallback defines the fallback internal texture if any
  71136. * @param isBase64 defines whether the texture is encoded as a base64
  71137. * @param isBuffer defines whether the texture data are stored as a buffer
  71138. * @returns true if the loader can load the specified file
  71139. */
  71140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71141. /**
  71142. * Transform the url before loading if required.
  71143. * @param rootUrl the url of the texture
  71144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71145. * @returns the transformed texture
  71146. */
  71147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71148. /**
  71149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71150. * @param rootUrl the url of the texture
  71151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71152. * @returns the fallback texture
  71153. */
  71154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71155. /**
  71156. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71157. * @param data contains the texture data
  71158. * @param texture defines the BabylonJS internal texture
  71159. * @param createPolynomials will be true if polynomials have been requested
  71160. * @param onLoad defines the callback to trigger once the texture is ready
  71161. * @param onError defines the callback to trigger in case of error
  71162. */
  71163. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71164. /**
  71165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71166. * @param data contains the texture data
  71167. * @param texture defines the BabylonJS internal texture
  71168. * @param callback defines the method to call once ready to upload
  71169. */
  71170. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71171. }
  71172. }
  71173. declare module BABYLON {
  71174. interface Engine {
  71175. /**
  71176. * Creates a depth stencil cube texture.
  71177. * This is only available in WebGL 2.
  71178. * @param size The size of face edge in the cube texture.
  71179. * @param options The options defining the cube texture.
  71180. * @returns The cube texture
  71181. */
  71182. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71183. /**
  71184. * Creates a cube texture
  71185. * @param rootUrl defines the url where the files to load is located
  71186. * @param scene defines the current scene
  71187. * @param files defines the list of files to load (1 per face)
  71188. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71189. * @param onLoad defines an optional callback raised when the texture is loaded
  71190. * @param onError defines an optional callback raised if there is an issue to load the texture
  71191. * @param format defines the format of the data
  71192. * @param forcedExtension defines the extension to use to pick the right loader
  71193. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71194. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71195. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71196. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71197. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71198. * @returns the cube texture as an InternalTexture
  71199. */
  71200. 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;
  71201. /**
  71202. * Creates a cube texture
  71203. * @param rootUrl defines the url where the files to load is located
  71204. * @param scene defines the current scene
  71205. * @param files defines the list of files to load (1 per face)
  71206. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71207. * @param onLoad defines an optional callback raised when the texture is loaded
  71208. * @param onError defines an optional callback raised if there is an issue to load the texture
  71209. * @param format defines the format of the data
  71210. * @param forcedExtension defines the extension to use to pick the right loader
  71211. * @returns the cube texture as an InternalTexture
  71212. */
  71213. 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;
  71214. /**
  71215. * Creates a cube texture
  71216. * @param rootUrl defines the url where the files to load is located
  71217. * @param scene defines the current scene
  71218. * @param files defines the list of files to load (1 per face)
  71219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71220. * @param onLoad defines an optional callback raised when the texture is loaded
  71221. * @param onError defines an optional callback raised if there is an issue to load the texture
  71222. * @param format defines the format of the data
  71223. * @param forcedExtension defines the extension to use to pick the right loader
  71224. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71225. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71226. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71227. * @returns the cube texture as an InternalTexture
  71228. */
  71229. 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;
  71230. /** @hidden */
  71231. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71232. /** @hidden */
  71233. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71234. /** @hidden */
  71235. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71236. /** @hidden */
  71237. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71238. }
  71239. }
  71240. declare module BABYLON {
  71241. /**
  71242. * Class for creating a cube texture
  71243. */
  71244. export class CubeTexture extends BaseTexture {
  71245. private _delayedOnLoad;
  71246. /**
  71247. * The url of the texture
  71248. */
  71249. url: string;
  71250. /**
  71251. * Gets or sets the center of the bounding box associated with the cube texture.
  71252. * It must define where the camera used to render the texture was set
  71253. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71254. */
  71255. boundingBoxPosition: Vector3;
  71256. private _boundingBoxSize;
  71257. /**
  71258. * Gets or sets the size of the bounding box associated with the cube texture
  71259. * When defined, the cubemap will switch to local mode
  71260. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71261. * @example https://www.babylonjs-playground.com/#RNASML
  71262. */
  71263. /**
  71264. * Returns the bounding box size
  71265. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71266. */
  71267. boundingBoxSize: Vector3;
  71268. protected _rotationY: number;
  71269. /**
  71270. * Sets texture matrix rotation angle around Y axis in radians.
  71271. */
  71272. /**
  71273. * Gets texture matrix rotation angle around Y axis radians.
  71274. */
  71275. rotationY: number;
  71276. /**
  71277. * Are mip maps generated for this texture or not.
  71278. */
  71279. readonly noMipmap: boolean;
  71280. private _noMipmap;
  71281. private _files;
  71282. private _extensions;
  71283. private _textureMatrix;
  71284. private _format;
  71285. private _createPolynomials;
  71286. /** @hidden */
  71287. _prefiltered: boolean;
  71288. /**
  71289. * Creates a cube texture from an array of image urls
  71290. * @param files defines an array of image urls
  71291. * @param scene defines the hosting scene
  71292. * @param noMipmap specifies if mip maps are not used
  71293. * @returns a cube texture
  71294. */
  71295. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71296. /**
  71297. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71298. * @param url defines the url of the prefiltered texture
  71299. * @param scene defines the scene the texture is attached to
  71300. * @param forcedExtension defines the extension of the file if different from the url
  71301. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71302. * @return the prefiltered texture
  71303. */
  71304. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71305. /**
  71306. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71307. * as prefiltered data.
  71308. * @param rootUrl defines the url of the texture or the root name of the six images
  71309. * @param scene defines the scene the texture is attached to
  71310. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71311. * @param noMipmap defines if mipmaps should be created or not
  71312. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71313. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71314. * @param onError defines a callback triggered in case of error during load
  71315. * @param format defines the internal format to use for the texture once loaded
  71316. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71317. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71318. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71319. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71320. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71321. * @return the cube texture
  71322. */
  71323. 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);
  71324. /**
  71325. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71326. */
  71327. readonly isPrefiltered: boolean;
  71328. /**
  71329. * Get the current class name of the texture useful for serialization or dynamic coding.
  71330. * @returns "CubeTexture"
  71331. */
  71332. getClassName(): string;
  71333. /**
  71334. * Update the url (and optional buffer) of this texture if url was null during construction.
  71335. * @param url the url of the texture
  71336. * @param forcedExtension defines the extension to use
  71337. * @param onLoad callback called when the texture is loaded (defaults to null)
  71338. */
  71339. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71340. /**
  71341. * Delays loading of the cube texture
  71342. * @param forcedExtension defines the extension to use
  71343. */
  71344. delayLoad(forcedExtension?: string): void;
  71345. /**
  71346. * Returns the reflection texture matrix
  71347. * @returns the reflection texture matrix
  71348. */
  71349. getReflectionTextureMatrix(): Matrix;
  71350. /**
  71351. * Sets the reflection texture matrix
  71352. * @param value Reflection texture matrix
  71353. */
  71354. setReflectionTextureMatrix(value: Matrix): void;
  71355. /**
  71356. * Parses text to create a cube texture
  71357. * @param parsedTexture define the serialized text to read from
  71358. * @param scene defines the hosting scene
  71359. * @param rootUrl defines the root url of the cube texture
  71360. * @returns a cube texture
  71361. */
  71362. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71363. /**
  71364. * Makes a clone, or deep copy, of the cube texture
  71365. * @returns a new cube texture
  71366. */
  71367. clone(): CubeTexture;
  71368. }
  71369. }
  71370. declare module BABYLON {
  71371. /**
  71372. * Manages the defines for the Material
  71373. */
  71374. export class MaterialDefines {
  71375. /** @hidden */
  71376. protected _keys: string[];
  71377. private _isDirty;
  71378. /** @hidden */
  71379. _renderId: number;
  71380. /** @hidden */
  71381. _areLightsDirty: boolean;
  71382. /** @hidden */
  71383. _areAttributesDirty: boolean;
  71384. /** @hidden */
  71385. _areTexturesDirty: boolean;
  71386. /** @hidden */
  71387. _areFresnelDirty: boolean;
  71388. /** @hidden */
  71389. _areMiscDirty: boolean;
  71390. /** @hidden */
  71391. _areImageProcessingDirty: boolean;
  71392. /** @hidden */
  71393. _normals: boolean;
  71394. /** @hidden */
  71395. _uvs: boolean;
  71396. /** @hidden */
  71397. _needNormals: boolean;
  71398. /** @hidden */
  71399. _needUVs: boolean;
  71400. [id: string]: any;
  71401. /**
  71402. * Specifies if the material needs to be re-calculated
  71403. */
  71404. readonly isDirty: boolean;
  71405. /**
  71406. * Marks the material to indicate that it has been re-calculated
  71407. */
  71408. markAsProcessed(): void;
  71409. /**
  71410. * Marks the material to indicate that it needs to be re-calculated
  71411. */
  71412. markAsUnprocessed(): void;
  71413. /**
  71414. * Marks the material to indicate all of its defines need to be re-calculated
  71415. */
  71416. markAllAsDirty(): void;
  71417. /**
  71418. * Marks the material to indicate that image processing needs to be re-calculated
  71419. */
  71420. markAsImageProcessingDirty(): void;
  71421. /**
  71422. * Marks the material to indicate the lights need to be re-calculated
  71423. */
  71424. markAsLightDirty(): void;
  71425. /**
  71426. * Marks the attribute state as changed
  71427. */
  71428. markAsAttributesDirty(): void;
  71429. /**
  71430. * Marks the texture state as changed
  71431. */
  71432. markAsTexturesDirty(): void;
  71433. /**
  71434. * Marks the fresnel state as changed
  71435. */
  71436. markAsFresnelDirty(): void;
  71437. /**
  71438. * Marks the misc state as changed
  71439. */
  71440. markAsMiscDirty(): void;
  71441. /**
  71442. * Rebuilds the material defines
  71443. */
  71444. rebuild(): void;
  71445. /**
  71446. * Specifies if two material defines are equal
  71447. * @param other - A material define instance to compare to
  71448. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71449. */
  71450. isEqual(other: MaterialDefines): boolean;
  71451. /**
  71452. * Clones this instance's defines to another instance
  71453. * @param other - material defines to clone values to
  71454. */
  71455. cloneTo(other: MaterialDefines): void;
  71456. /**
  71457. * Resets the material define values
  71458. */
  71459. reset(): void;
  71460. /**
  71461. * Converts the material define values to a string
  71462. * @returns - String of material define information
  71463. */
  71464. toString(): string;
  71465. }
  71466. }
  71467. declare module BABYLON {
  71468. /**
  71469. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71470. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71471. * 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;
  71472. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71473. */
  71474. export class ColorCurves {
  71475. private _dirty;
  71476. private _tempColor;
  71477. private _globalCurve;
  71478. private _highlightsCurve;
  71479. private _midtonesCurve;
  71480. private _shadowsCurve;
  71481. private _positiveCurve;
  71482. private _negativeCurve;
  71483. private _globalHue;
  71484. private _globalDensity;
  71485. private _globalSaturation;
  71486. private _globalExposure;
  71487. /**
  71488. * Gets the global Hue value.
  71489. * 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).
  71490. */
  71491. /**
  71492. * Sets the global Hue value.
  71493. * 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).
  71494. */
  71495. globalHue: number;
  71496. /**
  71497. * Gets the global Density value.
  71498. * 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.
  71499. * Values less than zero provide a filter of opposite hue.
  71500. */
  71501. /**
  71502. * Sets the global Density value.
  71503. * 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.
  71504. * Values less than zero provide a filter of opposite hue.
  71505. */
  71506. globalDensity: number;
  71507. /**
  71508. * Gets the global Saturation value.
  71509. * 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.
  71510. */
  71511. /**
  71512. * Sets the global Saturation value.
  71513. * 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.
  71514. */
  71515. globalSaturation: number;
  71516. /**
  71517. * Gets the global Exposure value.
  71518. * 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.
  71519. */
  71520. /**
  71521. * Sets the global Exposure value.
  71522. * 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.
  71523. */
  71524. globalExposure: number;
  71525. private _highlightsHue;
  71526. private _highlightsDensity;
  71527. private _highlightsSaturation;
  71528. private _highlightsExposure;
  71529. /**
  71530. * Gets the highlights Hue value.
  71531. * 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).
  71532. */
  71533. /**
  71534. * Sets the highlights Hue value.
  71535. * 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).
  71536. */
  71537. highlightsHue: number;
  71538. /**
  71539. * Gets the highlights Density value.
  71540. * 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.
  71541. * Values less than zero provide a filter of opposite hue.
  71542. */
  71543. /**
  71544. * Sets the highlights Density value.
  71545. * 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.
  71546. * Values less than zero provide a filter of opposite hue.
  71547. */
  71548. highlightsDensity: number;
  71549. /**
  71550. * Gets the highlights Saturation value.
  71551. * 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.
  71552. */
  71553. /**
  71554. * Sets the highlights Saturation value.
  71555. * 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.
  71556. */
  71557. highlightsSaturation: number;
  71558. /**
  71559. * Gets the highlights Exposure value.
  71560. * 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.
  71561. */
  71562. /**
  71563. * Sets the highlights Exposure value.
  71564. * 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.
  71565. */
  71566. highlightsExposure: number;
  71567. private _midtonesHue;
  71568. private _midtonesDensity;
  71569. private _midtonesSaturation;
  71570. private _midtonesExposure;
  71571. /**
  71572. * Gets the midtones Hue value.
  71573. * 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).
  71574. */
  71575. /**
  71576. * Sets the midtones Hue value.
  71577. * 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).
  71578. */
  71579. midtonesHue: number;
  71580. /**
  71581. * Gets the midtones Density value.
  71582. * 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.
  71583. * Values less than zero provide a filter of opposite hue.
  71584. */
  71585. /**
  71586. * Sets the midtones Density value.
  71587. * 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.
  71588. * Values less than zero provide a filter of opposite hue.
  71589. */
  71590. midtonesDensity: number;
  71591. /**
  71592. * Gets the midtones Saturation value.
  71593. * 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.
  71594. */
  71595. /**
  71596. * Sets the midtones Saturation value.
  71597. * 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.
  71598. */
  71599. midtonesSaturation: number;
  71600. /**
  71601. * Gets the midtones Exposure value.
  71602. * 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.
  71603. */
  71604. /**
  71605. * Sets the midtones Exposure value.
  71606. * 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.
  71607. */
  71608. midtonesExposure: number;
  71609. private _shadowsHue;
  71610. private _shadowsDensity;
  71611. private _shadowsSaturation;
  71612. private _shadowsExposure;
  71613. /**
  71614. * Gets the shadows Hue value.
  71615. * 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).
  71616. */
  71617. /**
  71618. * Sets the shadows Hue value.
  71619. * 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).
  71620. */
  71621. shadowsHue: number;
  71622. /**
  71623. * Gets the shadows Density value.
  71624. * 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.
  71625. * Values less than zero provide a filter of opposite hue.
  71626. */
  71627. /**
  71628. * Sets the shadows Density value.
  71629. * 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.
  71630. * Values less than zero provide a filter of opposite hue.
  71631. */
  71632. shadowsDensity: number;
  71633. /**
  71634. * Gets the shadows Saturation value.
  71635. * 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.
  71636. */
  71637. /**
  71638. * Sets the shadows Saturation value.
  71639. * 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.
  71640. */
  71641. shadowsSaturation: number;
  71642. /**
  71643. * Gets the shadows Exposure value.
  71644. * 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.
  71645. */
  71646. /**
  71647. * Sets the shadows Exposure value.
  71648. * 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.
  71649. */
  71650. shadowsExposure: number;
  71651. /**
  71652. * Returns the class name
  71653. * @returns The class name
  71654. */
  71655. getClassName(): string;
  71656. /**
  71657. * Binds the color curves to the shader.
  71658. * @param colorCurves The color curve to bind
  71659. * @param effect The effect to bind to
  71660. * @param positiveUniform The positive uniform shader parameter
  71661. * @param neutralUniform The neutral uniform shader parameter
  71662. * @param negativeUniform The negative uniform shader parameter
  71663. */
  71664. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71665. /**
  71666. * Prepare the list of uniforms associated with the ColorCurves effects.
  71667. * @param uniformsList The list of uniforms used in the effect
  71668. */
  71669. static PrepareUniforms(uniformsList: string[]): void;
  71670. /**
  71671. * Returns color grading data based on a hue, density, saturation and exposure value.
  71672. * @param filterHue The hue of the color filter.
  71673. * @param filterDensity The density of the color filter.
  71674. * @param saturation The saturation.
  71675. * @param exposure The exposure.
  71676. * @param result The result data container.
  71677. */
  71678. private getColorGradingDataToRef;
  71679. /**
  71680. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71681. * @param value The input slider value in range [-100,100].
  71682. * @returns Adjusted value.
  71683. */
  71684. private static applyColorGradingSliderNonlinear;
  71685. /**
  71686. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71687. * @param hue The hue (H) input.
  71688. * @param saturation The saturation (S) input.
  71689. * @param brightness The brightness (B) input.
  71690. * @result An RGBA color represented as Vector4.
  71691. */
  71692. private static fromHSBToRef;
  71693. /**
  71694. * Returns a value clamped between min and max
  71695. * @param value The value to clamp
  71696. * @param min The minimum of value
  71697. * @param max The maximum of value
  71698. * @returns The clamped value.
  71699. */
  71700. private static clamp;
  71701. /**
  71702. * Clones the current color curve instance.
  71703. * @return The cloned curves
  71704. */
  71705. clone(): ColorCurves;
  71706. /**
  71707. * Serializes the current color curve instance to a json representation.
  71708. * @return a JSON representation
  71709. */
  71710. serialize(): any;
  71711. /**
  71712. * Parses the color curve from a json representation.
  71713. * @param source the JSON source to parse
  71714. * @return The parsed curves
  71715. */
  71716. static Parse(source: any): ColorCurves;
  71717. }
  71718. }
  71719. declare module BABYLON {
  71720. /**
  71721. * Interface to follow in your material defines to integrate easily the
  71722. * Image proccessing functions.
  71723. * @hidden
  71724. */
  71725. export interface IImageProcessingConfigurationDefines {
  71726. IMAGEPROCESSING: boolean;
  71727. VIGNETTE: boolean;
  71728. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71729. VIGNETTEBLENDMODEOPAQUE: boolean;
  71730. TONEMAPPING: boolean;
  71731. TONEMAPPING_ACES: boolean;
  71732. CONTRAST: boolean;
  71733. EXPOSURE: boolean;
  71734. COLORCURVES: boolean;
  71735. COLORGRADING: boolean;
  71736. COLORGRADING3D: boolean;
  71737. SAMPLER3DGREENDEPTH: boolean;
  71738. SAMPLER3DBGRMAP: boolean;
  71739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71740. }
  71741. /**
  71742. * @hidden
  71743. */
  71744. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71745. IMAGEPROCESSING: boolean;
  71746. VIGNETTE: boolean;
  71747. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71748. VIGNETTEBLENDMODEOPAQUE: boolean;
  71749. TONEMAPPING: boolean;
  71750. TONEMAPPING_ACES: boolean;
  71751. CONTRAST: boolean;
  71752. COLORCURVES: boolean;
  71753. COLORGRADING: boolean;
  71754. COLORGRADING3D: boolean;
  71755. SAMPLER3DGREENDEPTH: boolean;
  71756. SAMPLER3DBGRMAP: boolean;
  71757. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71758. EXPOSURE: boolean;
  71759. constructor();
  71760. }
  71761. /**
  71762. * This groups together the common properties used for image processing either in direct forward pass
  71763. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71764. * or not.
  71765. */
  71766. export class ImageProcessingConfiguration {
  71767. /**
  71768. * Default tone mapping applied in BabylonJS.
  71769. */
  71770. static readonly TONEMAPPING_STANDARD: number;
  71771. /**
  71772. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71773. * to other engines rendering to increase portability.
  71774. */
  71775. static readonly TONEMAPPING_ACES: number;
  71776. /**
  71777. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71778. */
  71779. colorCurves: Nullable<ColorCurves>;
  71780. private _colorCurvesEnabled;
  71781. /**
  71782. * Gets wether the color curves effect is enabled.
  71783. */
  71784. /**
  71785. * Sets wether the color curves effect is enabled.
  71786. */
  71787. colorCurvesEnabled: boolean;
  71788. private _colorGradingTexture;
  71789. /**
  71790. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71791. */
  71792. /**
  71793. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71794. */
  71795. colorGradingTexture: Nullable<BaseTexture>;
  71796. private _colorGradingEnabled;
  71797. /**
  71798. * Gets wether the color grading effect is enabled.
  71799. */
  71800. /**
  71801. * Sets wether the color grading effect is enabled.
  71802. */
  71803. colorGradingEnabled: boolean;
  71804. private _colorGradingWithGreenDepth;
  71805. /**
  71806. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71807. */
  71808. /**
  71809. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71810. */
  71811. colorGradingWithGreenDepth: boolean;
  71812. private _colorGradingBGR;
  71813. /**
  71814. * Gets wether the color grading texture contains BGR values.
  71815. */
  71816. /**
  71817. * Sets wether the color grading texture contains BGR values.
  71818. */
  71819. colorGradingBGR: boolean;
  71820. /** @hidden */
  71821. _exposure: number;
  71822. /**
  71823. * Gets the Exposure used in the effect.
  71824. */
  71825. /**
  71826. * Sets the Exposure used in the effect.
  71827. */
  71828. exposure: number;
  71829. private _toneMappingEnabled;
  71830. /**
  71831. * Gets wether the tone mapping effect is enabled.
  71832. */
  71833. /**
  71834. * Sets wether the tone mapping effect is enabled.
  71835. */
  71836. toneMappingEnabled: boolean;
  71837. private _toneMappingType;
  71838. /**
  71839. * Gets the type of tone mapping effect.
  71840. */
  71841. /**
  71842. * Sets the type of tone mapping effect used in BabylonJS.
  71843. */
  71844. toneMappingType: number;
  71845. protected _contrast: number;
  71846. /**
  71847. * Gets the contrast used in the effect.
  71848. */
  71849. /**
  71850. * Sets the contrast used in the effect.
  71851. */
  71852. contrast: number;
  71853. /**
  71854. * Vignette stretch size.
  71855. */
  71856. vignetteStretch: number;
  71857. /**
  71858. * Vignette centre X Offset.
  71859. */
  71860. vignetteCentreX: number;
  71861. /**
  71862. * Vignette centre Y Offset.
  71863. */
  71864. vignetteCentreY: number;
  71865. /**
  71866. * Vignette weight or intensity of the vignette effect.
  71867. */
  71868. vignetteWeight: number;
  71869. /**
  71870. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  71871. * if vignetteEnabled is set to true.
  71872. */
  71873. vignetteColor: Color4;
  71874. /**
  71875. * Camera field of view used by the Vignette effect.
  71876. */
  71877. vignetteCameraFov: number;
  71878. private _vignetteBlendMode;
  71879. /**
  71880. * Gets the vignette blend mode allowing different kind of effect.
  71881. */
  71882. /**
  71883. * Sets the vignette blend mode allowing different kind of effect.
  71884. */
  71885. vignetteBlendMode: number;
  71886. private _vignetteEnabled;
  71887. /**
  71888. * Gets wether the vignette effect is enabled.
  71889. */
  71890. /**
  71891. * Sets wether the vignette effect is enabled.
  71892. */
  71893. vignetteEnabled: boolean;
  71894. private _applyByPostProcess;
  71895. /**
  71896. * Gets wether the image processing is applied through a post process or not.
  71897. */
  71898. /**
  71899. * Sets wether the image processing is applied through a post process or not.
  71900. */
  71901. applyByPostProcess: boolean;
  71902. private _isEnabled;
  71903. /**
  71904. * Gets wether the image processing is enabled or not.
  71905. */
  71906. /**
  71907. * Sets wether the image processing is enabled or not.
  71908. */
  71909. isEnabled: boolean;
  71910. /**
  71911. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  71912. */
  71913. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  71914. /**
  71915. * Method called each time the image processing information changes requires to recompile the effect.
  71916. */
  71917. protected _updateParameters(): void;
  71918. /**
  71919. * Gets the current class name.
  71920. * @return "ImageProcessingConfiguration"
  71921. */
  71922. getClassName(): string;
  71923. /**
  71924. * Prepare the list of uniforms associated with the Image Processing effects.
  71925. * @param uniforms The list of uniforms used in the effect
  71926. * @param defines the list of defines currently in use
  71927. */
  71928. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  71929. /**
  71930. * Prepare the list of samplers associated with the Image Processing effects.
  71931. * @param samplersList The list of uniforms used in the effect
  71932. * @param defines the list of defines currently in use
  71933. */
  71934. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  71935. /**
  71936. * Prepare the list of defines associated to the shader.
  71937. * @param defines the list of defines to complete
  71938. * @param forPostProcess Define if we are currently in post process mode or not
  71939. */
  71940. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  71941. /**
  71942. * Returns true if all the image processing information are ready.
  71943. * @returns True if ready, otherwise, false
  71944. */
  71945. isReady(): boolean;
  71946. /**
  71947. * Binds the image processing to the shader.
  71948. * @param effect The effect to bind to
  71949. * @param aspectRatio Define the current aspect ratio of the effect
  71950. */
  71951. bind(effect: Effect, aspectRatio?: number): void;
  71952. /**
  71953. * Clones the current image processing instance.
  71954. * @return The cloned image processing
  71955. */
  71956. clone(): ImageProcessingConfiguration;
  71957. /**
  71958. * Serializes the current image processing instance to a json representation.
  71959. * @return a JSON representation
  71960. */
  71961. serialize(): any;
  71962. /**
  71963. * Parses the image processing from a json representation.
  71964. * @param source the JSON source to parse
  71965. * @return The parsed image processing
  71966. */
  71967. static Parse(source: any): ImageProcessingConfiguration;
  71968. private static _VIGNETTEMODE_MULTIPLY;
  71969. private static _VIGNETTEMODE_OPAQUE;
  71970. /**
  71971. * Used to apply the vignette as a mix with the pixel color.
  71972. */
  71973. static readonly VIGNETTEMODE_MULTIPLY: number;
  71974. /**
  71975. * Used to apply the vignette as a replacement of the pixel color.
  71976. */
  71977. static readonly VIGNETTEMODE_OPAQUE: number;
  71978. }
  71979. }
  71980. declare module BABYLON {
  71981. /** @hidden */
  71982. export var postprocessVertexShader: {
  71983. name: string;
  71984. shader: string;
  71985. };
  71986. }
  71987. declare module BABYLON {
  71988. /** Defines supported spaces */
  71989. export enum Space {
  71990. /** Local (object) space */
  71991. LOCAL = 0,
  71992. /** World space */
  71993. WORLD = 1,
  71994. /** Bone space */
  71995. BONE = 2
  71996. }
  71997. /** Defines the 3 main axes */
  71998. export class Axis {
  71999. /** X axis */
  72000. static X: Vector3;
  72001. /** Y axis */
  72002. static Y: Vector3;
  72003. /** Z axis */
  72004. static Z: Vector3;
  72005. }
  72006. }
  72007. declare module BABYLON {
  72008. /**
  72009. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  72010. * This is the base of the follow, arc rotate cameras and Free camera
  72011. * @see http://doc.babylonjs.com/features/cameras
  72012. */
  72013. export class TargetCamera extends Camera {
  72014. private static _RigCamTransformMatrix;
  72015. private static _TargetTransformMatrix;
  72016. private static _TargetFocalPoint;
  72017. /**
  72018. * Define the current direction the camera is moving to
  72019. */
  72020. cameraDirection: Vector3;
  72021. /**
  72022. * Define the current rotation the camera is rotating to
  72023. */
  72024. cameraRotation: Vector2;
  72025. /**
  72026. * When set, the up vector of the camera will be updated by the rotation of the camera
  72027. */
  72028. updateUpVectorFromRotation: boolean;
  72029. private _tmpQuaternion;
  72030. /**
  72031. * Define the current rotation of the camera
  72032. */
  72033. rotation: Vector3;
  72034. /**
  72035. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72036. */
  72037. rotationQuaternion: Quaternion;
  72038. /**
  72039. * Define the current speed of the camera
  72040. */
  72041. speed: number;
  72042. /**
  72043. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72044. * around all axis.
  72045. */
  72046. noRotationConstraint: boolean;
  72047. /**
  72048. * Define the current target of the camera as an object or a position.
  72049. */
  72050. lockedTarget: any;
  72051. /** @hidden */
  72052. _currentTarget: Vector3;
  72053. /** @hidden */
  72054. _initialFocalDistance: number;
  72055. /** @hidden */
  72056. _viewMatrix: Matrix;
  72057. /** @hidden */
  72058. _camMatrix: Matrix;
  72059. /** @hidden */
  72060. _cameraTransformMatrix: Matrix;
  72061. /** @hidden */
  72062. _cameraRotationMatrix: Matrix;
  72063. /** @hidden */
  72064. _referencePoint: Vector3;
  72065. /** @hidden */
  72066. _transformedReferencePoint: Vector3;
  72067. protected _globalCurrentTarget: Vector3;
  72068. protected _globalCurrentUpVector: Vector3;
  72069. /** @hidden */
  72070. _reset: () => void;
  72071. private _defaultUp;
  72072. /**
  72073. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72074. * This is the base of the follow, arc rotate cameras and Free camera
  72075. * @see http://doc.babylonjs.com/features/cameras
  72076. * @param name Defines the name of the camera in the scene
  72077. * @param position Defines the start position of the camera in the scene
  72078. * @param scene Defines the scene the camera belongs to
  72079. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72080. */
  72081. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72082. /**
  72083. * Gets the position in front of the camera at a given distance.
  72084. * @param distance The distance from the camera we want the position to be
  72085. * @returns the position
  72086. */
  72087. getFrontPosition(distance: number): Vector3;
  72088. /** @hidden */
  72089. _getLockedTargetPosition(): Nullable<Vector3>;
  72090. private _storedPosition;
  72091. private _storedRotation;
  72092. private _storedRotationQuaternion;
  72093. /**
  72094. * Store current camera state of the camera (fov, position, rotation, etc..)
  72095. * @returns the camera
  72096. */
  72097. storeState(): Camera;
  72098. /**
  72099. * Restored camera state. You must call storeState() first
  72100. * @returns whether it was successful or not
  72101. * @hidden
  72102. */
  72103. _restoreStateValues(): boolean;
  72104. /** @hidden */
  72105. _initCache(): void;
  72106. /** @hidden */
  72107. _updateCache(ignoreParentClass?: boolean): void;
  72108. /** @hidden */
  72109. _isSynchronizedViewMatrix(): boolean;
  72110. /** @hidden */
  72111. _computeLocalCameraSpeed(): number;
  72112. /**
  72113. * Defines the target the camera should look at.
  72114. * @param target Defines the new target as a Vector or a mesh
  72115. */
  72116. setTarget(target: Vector3): void;
  72117. /**
  72118. * Return the current target position of the camera. This value is expressed in local space.
  72119. * @returns the target position
  72120. */
  72121. getTarget(): Vector3;
  72122. /** @hidden */
  72123. _decideIfNeedsToMove(): boolean;
  72124. /** @hidden */
  72125. _updatePosition(): void;
  72126. /** @hidden */
  72127. _checkInputs(): void;
  72128. protected _updateCameraRotationMatrix(): void;
  72129. /**
  72130. * 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)
  72131. * @returns the current camera
  72132. */
  72133. private _rotateUpVectorWithCameraRotationMatrix;
  72134. private _cachedRotationZ;
  72135. private _cachedQuaternionRotationZ;
  72136. /** @hidden */
  72137. _getViewMatrix(): Matrix;
  72138. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72139. /**
  72140. * @hidden
  72141. */
  72142. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72143. /**
  72144. * @hidden
  72145. */
  72146. _updateRigCameras(): void;
  72147. private _getRigCamPositionAndTarget;
  72148. /**
  72149. * Gets the current object class name.
  72150. * @return the class name
  72151. */
  72152. getClassName(): string;
  72153. }
  72154. }
  72155. declare module BABYLON {
  72156. /**
  72157. * Gather the list of keyboard event types as constants.
  72158. */
  72159. export class KeyboardEventTypes {
  72160. /**
  72161. * The keydown event is fired when a key becomes active (pressed).
  72162. */
  72163. static readonly KEYDOWN: number;
  72164. /**
  72165. * The keyup event is fired when a key has been released.
  72166. */
  72167. static readonly KEYUP: number;
  72168. }
  72169. /**
  72170. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72171. */
  72172. export class KeyboardInfo {
  72173. /**
  72174. * Defines the type of event (KeyboardEventTypes)
  72175. */
  72176. type: number;
  72177. /**
  72178. * Defines the related dom event
  72179. */
  72180. event: KeyboardEvent;
  72181. /**
  72182. * Instantiates a new keyboard info.
  72183. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72184. * @param type Defines the type of event (KeyboardEventTypes)
  72185. * @param event Defines the related dom event
  72186. */
  72187. constructor(
  72188. /**
  72189. * Defines the type of event (KeyboardEventTypes)
  72190. */
  72191. type: number,
  72192. /**
  72193. * Defines the related dom event
  72194. */
  72195. event: KeyboardEvent);
  72196. }
  72197. /**
  72198. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72199. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72200. */
  72201. export class KeyboardInfoPre extends KeyboardInfo {
  72202. /**
  72203. * Defines the type of event (KeyboardEventTypes)
  72204. */
  72205. type: number;
  72206. /**
  72207. * Defines the related dom event
  72208. */
  72209. event: KeyboardEvent;
  72210. /**
  72211. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72212. */
  72213. skipOnPointerObservable: boolean;
  72214. /**
  72215. * Instantiates a new keyboard pre info.
  72216. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72217. * @param type Defines the type of event (KeyboardEventTypes)
  72218. * @param event Defines the related dom event
  72219. */
  72220. constructor(
  72221. /**
  72222. * Defines the type of event (KeyboardEventTypes)
  72223. */
  72224. type: number,
  72225. /**
  72226. * Defines the related dom event
  72227. */
  72228. event: KeyboardEvent);
  72229. }
  72230. }
  72231. declare module BABYLON {
  72232. /**
  72233. * Manage the keyboard inputs to control the movement of a free camera.
  72234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72235. */
  72236. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72237. /**
  72238. * Defines the camera the input is attached to.
  72239. */
  72240. camera: FreeCamera;
  72241. /**
  72242. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72243. */
  72244. keysUp: number[];
  72245. /**
  72246. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72247. */
  72248. keysDown: number[];
  72249. /**
  72250. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72251. */
  72252. keysLeft: number[];
  72253. /**
  72254. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72255. */
  72256. keysRight: number[];
  72257. private _keys;
  72258. private _onCanvasBlurObserver;
  72259. private _onKeyboardObserver;
  72260. private _engine;
  72261. private _scene;
  72262. /**
  72263. * Attach the input controls to a specific dom element to get the input from.
  72264. * @param element Defines the element the controls should be listened from
  72265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72266. */
  72267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72268. /**
  72269. * Detach the current controls from the specified dom element.
  72270. * @param element Defines the element to stop listening the inputs from
  72271. */
  72272. detachControl(element: Nullable<HTMLElement>): void;
  72273. /**
  72274. * Update the current camera state depending on the inputs that have been used this frame.
  72275. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72276. */
  72277. checkInputs(): void;
  72278. /**
  72279. * Gets the class name of the current intput.
  72280. * @returns the class name
  72281. */
  72282. getClassName(): string;
  72283. /** @hidden */
  72284. _onLostFocus(): void;
  72285. /**
  72286. * Get the friendly name associated with the input class.
  72287. * @returns the input friendly name
  72288. */
  72289. getSimpleName(): string;
  72290. }
  72291. }
  72292. declare module BABYLON {
  72293. /**
  72294. * Interface describing all the common properties and methods a shadow light needs to implement.
  72295. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72296. * as well as binding the different shadow properties to the effects.
  72297. */
  72298. export interface IShadowLight extends Light {
  72299. /**
  72300. * The light id in the scene (used in scene.findLighById for instance)
  72301. */
  72302. id: string;
  72303. /**
  72304. * The position the shdow will be casted from.
  72305. */
  72306. position: Vector3;
  72307. /**
  72308. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72309. */
  72310. direction: Vector3;
  72311. /**
  72312. * The transformed position. Position of the light in world space taking parenting in account.
  72313. */
  72314. transformedPosition: Vector3;
  72315. /**
  72316. * The transformed direction. Direction of the light in world space taking parenting in account.
  72317. */
  72318. transformedDirection: Vector3;
  72319. /**
  72320. * The friendly name of the light in the scene.
  72321. */
  72322. name: string;
  72323. /**
  72324. * Defines the shadow projection clipping minimum z value.
  72325. */
  72326. shadowMinZ: number;
  72327. /**
  72328. * Defines the shadow projection clipping maximum z value.
  72329. */
  72330. shadowMaxZ: number;
  72331. /**
  72332. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72333. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72334. */
  72335. computeTransformedInformation(): boolean;
  72336. /**
  72337. * Gets the scene the light belongs to.
  72338. * @returns The scene
  72339. */
  72340. getScene(): Scene;
  72341. /**
  72342. * Callback defining a custom Projection Matrix Builder.
  72343. * This can be used to override the default projection matrix computation.
  72344. */
  72345. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72346. /**
  72347. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72348. * @param matrix The materix to updated with the projection information
  72349. * @param viewMatrix The transform matrix of the light
  72350. * @param renderList The list of mesh to render in the map
  72351. * @returns The current light
  72352. */
  72353. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72354. /**
  72355. * Gets the current depth scale used in ESM.
  72356. * @returns The scale
  72357. */
  72358. getDepthScale(): number;
  72359. /**
  72360. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72361. * @returns true if a cube texture needs to be use
  72362. */
  72363. needCube(): boolean;
  72364. /**
  72365. * Detects if the projection matrix requires to be recomputed this frame.
  72366. * @returns true if it requires to be recomputed otherwise, false.
  72367. */
  72368. needProjectionMatrixCompute(): boolean;
  72369. /**
  72370. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72371. */
  72372. forceProjectionMatrixCompute(): void;
  72373. /**
  72374. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72375. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72376. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72377. */
  72378. getShadowDirection(faceIndex?: number): Vector3;
  72379. /**
  72380. * Gets the minZ used for shadow according to both the scene and the light.
  72381. * @param activeCamera The camera we are returning the min for
  72382. * @returns the depth min z
  72383. */
  72384. getDepthMinZ(activeCamera: Camera): number;
  72385. /**
  72386. * Gets the maxZ used for shadow according to both the scene and the light.
  72387. * @param activeCamera The camera we are returning the max for
  72388. * @returns the depth max z
  72389. */
  72390. getDepthMaxZ(activeCamera: Camera): number;
  72391. }
  72392. /**
  72393. * Base implementation IShadowLight
  72394. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72395. */
  72396. export abstract class ShadowLight extends Light implements IShadowLight {
  72397. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72398. protected _position: Vector3;
  72399. protected _setPosition(value: Vector3): void;
  72400. /**
  72401. * Sets the position the shadow will be casted from. Also use as the light position for both
  72402. * point and spot lights.
  72403. */
  72404. /**
  72405. * Sets the position the shadow will be casted from. Also use as the light position for both
  72406. * point and spot lights.
  72407. */
  72408. position: Vector3;
  72409. protected _direction: Vector3;
  72410. protected _setDirection(value: Vector3): void;
  72411. /**
  72412. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72413. * Also use as the light direction on spot and directional lights.
  72414. */
  72415. /**
  72416. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72417. * Also use as the light direction on spot and directional lights.
  72418. */
  72419. direction: Vector3;
  72420. private _shadowMinZ;
  72421. /**
  72422. * Gets the shadow projection clipping minimum z value.
  72423. */
  72424. /**
  72425. * Sets the shadow projection clipping minimum z value.
  72426. */
  72427. shadowMinZ: number;
  72428. private _shadowMaxZ;
  72429. /**
  72430. * Sets the shadow projection clipping maximum z value.
  72431. */
  72432. /**
  72433. * Gets the shadow projection clipping maximum z value.
  72434. */
  72435. shadowMaxZ: number;
  72436. /**
  72437. * Callback defining a custom Projection Matrix Builder.
  72438. * This can be used to override the default projection matrix computation.
  72439. */
  72440. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72441. /**
  72442. * The transformed position. Position of the light in world space taking parenting in account.
  72443. */
  72444. transformedPosition: Vector3;
  72445. /**
  72446. * The transformed direction. Direction of the light in world space taking parenting in account.
  72447. */
  72448. transformedDirection: Vector3;
  72449. private _needProjectionMatrixCompute;
  72450. /**
  72451. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72452. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72453. */
  72454. computeTransformedInformation(): boolean;
  72455. /**
  72456. * Return the depth scale used for the shadow map.
  72457. * @returns the depth scale.
  72458. */
  72459. getDepthScale(): number;
  72460. /**
  72461. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72462. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72463. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72464. */
  72465. getShadowDirection(faceIndex?: number): Vector3;
  72466. /**
  72467. * Returns the ShadowLight absolute position in the World.
  72468. * @returns the position vector in world space
  72469. */
  72470. getAbsolutePosition(): Vector3;
  72471. /**
  72472. * Sets the ShadowLight direction toward the passed target.
  72473. * @param target The point to target in local space
  72474. * @returns the updated ShadowLight direction
  72475. */
  72476. setDirectionToTarget(target: Vector3): Vector3;
  72477. /**
  72478. * Returns the light rotation in euler definition.
  72479. * @returns the x y z rotation in local space.
  72480. */
  72481. getRotation(): Vector3;
  72482. /**
  72483. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72484. * @returns true if a cube texture needs to be use
  72485. */
  72486. needCube(): boolean;
  72487. /**
  72488. * Detects if the projection matrix requires to be recomputed this frame.
  72489. * @returns true if it requires to be recomputed otherwise, false.
  72490. */
  72491. needProjectionMatrixCompute(): boolean;
  72492. /**
  72493. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72494. */
  72495. forceProjectionMatrixCompute(): void;
  72496. /** @hidden */
  72497. _initCache(): void;
  72498. /** @hidden */
  72499. _isSynchronized(): boolean;
  72500. /**
  72501. * Computes the world matrix of the node
  72502. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72503. * @returns the world matrix
  72504. */
  72505. computeWorldMatrix(force?: boolean): Matrix;
  72506. /**
  72507. * Gets the minZ used for shadow according to both the scene and the light.
  72508. * @param activeCamera The camera we are returning the min for
  72509. * @returns the depth min z
  72510. */
  72511. getDepthMinZ(activeCamera: Camera): number;
  72512. /**
  72513. * Gets the maxZ used for shadow according to both the scene and the light.
  72514. * @param activeCamera The camera we are returning the max for
  72515. * @returns the depth max z
  72516. */
  72517. getDepthMaxZ(activeCamera: Camera): number;
  72518. /**
  72519. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72520. * @param matrix The materix to updated with the projection information
  72521. * @param viewMatrix The transform matrix of the light
  72522. * @param renderList The list of mesh to render in the map
  72523. * @returns The current light
  72524. */
  72525. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72526. }
  72527. }
  72528. declare module BABYLON {
  72529. /**
  72530. * "Static Class" containing the most commonly used helper while dealing with material for
  72531. * rendering purpose.
  72532. *
  72533. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72534. *
  72535. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72536. */
  72537. export class MaterialHelper {
  72538. /**
  72539. * Bind the current view position to an effect.
  72540. * @param effect The effect to be bound
  72541. * @param scene The scene the eyes position is used from
  72542. */
  72543. static BindEyePosition(effect: Effect, scene: Scene): void;
  72544. /**
  72545. * Helps preparing the defines values about the UVs in used in the effect.
  72546. * UVs are shared as much as we can accross channels in the shaders.
  72547. * @param texture The texture we are preparing the UVs for
  72548. * @param defines The defines to update
  72549. * @param key The channel key "diffuse", "specular"... used in the shader
  72550. */
  72551. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72552. /**
  72553. * Binds a texture matrix value to its corrsponding uniform
  72554. * @param texture The texture to bind the matrix for
  72555. * @param uniformBuffer The uniform buffer receivin the data
  72556. * @param key The channel key "diffuse", "specular"... used in the shader
  72557. */
  72558. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72559. /**
  72560. * Gets the current status of the fog (should it be enabled?)
  72561. * @param mesh defines the mesh to evaluate for fog support
  72562. * @param scene defines the hosting scene
  72563. * @returns true if fog must be enabled
  72564. */
  72565. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72566. /**
  72567. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72568. * @param mesh defines the current mesh
  72569. * @param scene defines the current scene
  72570. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72571. * @param pointsCloud defines if point cloud rendering has to be turned on
  72572. * @param fogEnabled defines if fog has to be turned on
  72573. * @param alphaTest defines if alpha testing has to be turned on
  72574. * @param defines defines the current list of defines
  72575. */
  72576. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72577. /**
  72578. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72579. * @param scene defines the current scene
  72580. * @param engine defines the current engine
  72581. * @param defines specifies the list of active defines
  72582. * @param useInstances defines if instances have to be turned on
  72583. * @param useClipPlane defines if clip plane have to be turned on
  72584. */
  72585. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72586. /**
  72587. * Prepares the defines for bones
  72588. * @param mesh The mesh containing the geometry data we will draw
  72589. * @param defines The defines to update
  72590. */
  72591. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72592. /**
  72593. * Prepares the defines for morph targets
  72594. * @param mesh The mesh containing the geometry data we will draw
  72595. * @param defines The defines to update
  72596. */
  72597. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72598. /**
  72599. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72600. * @param mesh The mesh containing the geometry data we will draw
  72601. * @param defines The defines to update
  72602. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72603. * @param useBones Precise whether bones should be used or not (override mesh info)
  72604. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72605. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72606. * @returns false if defines are considered not dirty and have not been checked
  72607. */
  72608. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72609. /**
  72610. * Prepares the defines related to multiview
  72611. * @param scene The scene we are intending to draw
  72612. * @param defines The defines to update
  72613. */
  72614. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72615. /**
  72616. * Prepares the defines related to the light information passed in parameter
  72617. * @param scene The scene we are intending to draw
  72618. * @param mesh The mesh the effect is compiling for
  72619. * @param light The light the effect is compiling for
  72620. * @param lightIndex The index of the light
  72621. * @param defines The defines to update
  72622. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72623. * @param state Defines the current state regarding what is needed (normals, etc...)
  72624. */
  72625. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72626. needNormals: boolean;
  72627. needRebuild: boolean;
  72628. shadowEnabled: boolean;
  72629. specularEnabled: boolean;
  72630. lightmapMode: boolean;
  72631. }): void;
  72632. /**
  72633. * Prepares the defines related to the light information passed in parameter
  72634. * @param scene The scene we are intending to draw
  72635. * @param mesh The mesh the effect is compiling for
  72636. * @param defines The defines to update
  72637. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72638. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72639. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72640. * @returns true if normals will be required for the rest of the effect
  72641. */
  72642. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72643. /**
  72644. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72645. * @param lightIndex defines the light index
  72646. * @param uniformsList The uniform list
  72647. * @param samplersList The sampler list
  72648. * @param projectedLightTexture defines if projected texture must be used
  72649. * @param uniformBuffersList defines an optional list of uniform buffers
  72650. */
  72651. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72652. /**
  72653. * Prepares the uniforms and samplers list to be used in the effect
  72654. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72655. * @param samplersList The sampler list
  72656. * @param defines The defines helping in the list generation
  72657. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72658. */
  72659. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72660. /**
  72661. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72662. * @param defines The defines to update while falling back
  72663. * @param fallbacks The authorized effect fallbacks
  72664. * @param maxSimultaneousLights The maximum number of lights allowed
  72665. * @param rank the current rank of the Effect
  72666. * @returns The newly affected rank
  72667. */
  72668. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72669. private static _TmpMorphInfluencers;
  72670. /**
  72671. * Prepares the list of attributes required for morph targets according to the effect defines.
  72672. * @param attribs The current list of supported attribs
  72673. * @param mesh The mesh to prepare the morph targets attributes for
  72674. * @param influencers The number of influencers
  72675. */
  72676. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72677. /**
  72678. * Prepares the list of attributes required for morph targets according to the effect defines.
  72679. * @param attribs The current list of supported attribs
  72680. * @param mesh The mesh to prepare the morph targets attributes for
  72681. * @param defines The current Defines of the effect
  72682. */
  72683. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72684. /**
  72685. * Prepares the list of attributes required for bones according to the effect defines.
  72686. * @param attribs The current list of supported attribs
  72687. * @param mesh The mesh to prepare the bones attributes for
  72688. * @param defines The current Defines of the effect
  72689. * @param fallbacks The current efffect fallback strategy
  72690. */
  72691. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72692. /**
  72693. * Check and prepare the list of attributes required for instances according to the effect defines.
  72694. * @param attribs The current list of supported attribs
  72695. * @param defines The current MaterialDefines of the effect
  72696. */
  72697. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72698. /**
  72699. * Add the list of attributes required for instances to the attribs array.
  72700. * @param attribs The current list of supported attribs
  72701. */
  72702. static PushAttributesForInstances(attribs: string[]): void;
  72703. /**
  72704. * Binds the light shadow information to the effect for the given mesh.
  72705. * @param light The light containing the generator
  72706. * @param scene The scene the lights belongs to
  72707. * @param mesh The mesh we are binding the information to render
  72708. * @param lightIndex The light index in the effect used to render the mesh
  72709. * @param effect The effect we are binding the data to
  72710. */
  72711. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72712. /**
  72713. * Binds the light information to the effect.
  72714. * @param light The light containing the generator
  72715. * @param effect The effect we are binding the data to
  72716. * @param lightIndex The light index in the effect used to render
  72717. */
  72718. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72719. /**
  72720. * Binds the lights information from the scene to the effect for the given mesh.
  72721. * @param light Light to bind
  72722. * @param lightIndex Light index
  72723. * @param scene The scene where the light belongs to
  72724. * @param mesh The mesh we are binding the information to render
  72725. * @param effect The effect we are binding the data to
  72726. * @param useSpecular Defines if specular is supported
  72727. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72728. */
  72729. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72730. /**
  72731. * Binds the lights information from the scene to the effect for the given mesh.
  72732. * @param scene The scene the lights belongs to
  72733. * @param mesh The mesh we are binding the information to render
  72734. * @param effect The effect we are binding the data to
  72735. * @param defines The generated defines for the effect
  72736. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72737. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72738. */
  72739. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72740. private static _tempFogColor;
  72741. /**
  72742. * Binds the fog information from the scene to the effect for the given mesh.
  72743. * @param scene The scene the lights belongs to
  72744. * @param mesh The mesh we are binding the information to render
  72745. * @param effect The effect we are binding the data to
  72746. * @param linearSpace Defines if the fog effect is applied in linear space
  72747. */
  72748. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72749. /**
  72750. * Binds the bones information from the mesh to the effect.
  72751. * @param mesh The mesh we are binding the information to render
  72752. * @param effect The effect we are binding the data to
  72753. */
  72754. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72755. /**
  72756. * Binds the morph targets information from the mesh to the effect.
  72757. * @param abstractMesh The mesh we are binding the information to render
  72758. * @param effect The effect we are binding the data to
  72759. */
  72760. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72761. /**
  72762. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72763. * @param defines The generated defines used in the effect
  72764. * @param effect The effect we are binding the data to
  72765. * @param scene The scene we are willing to render with logarithmic scale for
  72766. */
  72767. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72768. /**
  72769. * Binds the clip plane information from the scene to the effect.
  72770. * @param scene The scene the clip plane information are extracted from
  72771. * @param effect The effect we are binding the data to
  72772. */
  72773. static BindClipPlane(effect: Effect, scene: Scene): void;
  72774. }
  72775. }
  72776. declare module BABYLON {
  72777. /** @hidden */
  72778. export var packingFunctions: {
  72779. name: string;
  72780. shader: string;
  72781. };
  72782. }
  72783. declare module BABYLON {
  72784. /** @hidden */
  72785. export var shadowMapPixelShader: {
  72786. name: string;
  72787. shader: string;
  72788. };
  72789. }
  72790. declare module BABYLON {
  72791. /** @hidden */
  72792. export var bonesDeclaration: {
  72793. name: string;
  72794. shader: string;
  72795. };
  72796. }
  72797. declare module BABYLON {
  72798. /** @hidden */
  72799. export var morphTargetsVertexGlobalDeclaration: {
  72800. name: string;
  72801. shader: string;
  72802. };
  72803. }
  72804. declare module BABYLON {
  72805. /** @hidden */
  72806. export var morphTargetsVertexDeclaration: {
  72807. name: string;
  72808. shader: string;
  72809. };
  72810. }
  72811. declare module BABYLON {
  72812. /** @hidden */
  72813. export var instancesDeclaration: {
  72814. name: string;
  72815. shader: string;
  72816. };
  72817. }
  72818. declare module BABYLON {
  72819. /** @hidden */
  72820. export var helperFunctions: {
  72821. name: string;
  72822. shader: string;
  72823. };
  72824. }
  72825. declare module BABYLON {
  72826. /** @hidden */
  72827. export var morphTargetsVertex: {
  72828. name: string;
  72829. shader: string;
  72830. };
  72831. }
  72832. declare module BABYLON {
  72833. /** @hidden */
  72834. export var instancesVertex: {
  72835. name: string;
  72836. shader: string;
  72837. };
  72838. }
  72839. declare module BABYLON {
  72840. /** @hidden */
  72841. export var bonesVertex: {
  72842. name: string;
  72843. shader: string;
  72844. };
  72845. }
  72846. declare module BABYLON {
  72847. /** @hidden */
  72848. export var shadowMapVertexShader: {
  72849. name: string;
  72850. shader: string;
  72851. };
  72852. }
  72853. declare module BABYLON {
  72854. /** @hidden */
  72855. export var depthBoxBlurPixelShader: {
  72856. name: string;
  72857. shader: string;
  72858. };
  72859. }
  72860. declare module BABYLON {
  72861. /**
  72862. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72863. */
  72864. export interface ICustomShaderOptions {
  72865. /**
  72866. * Gets or sets the custom shader name to use
  72867. */
  72868. shaderName: string;
  72869. /**
  72870. * The list of attribute names used in the shader
  72871. */
  72872. attributes?: string[];
  72873. /**
  72874. * The list of unifrom names used in the shader
  72875. */
  72876. uniforms?: string[];
  72877. /**
  72878. * The list of sampler names used in the shader
  72879. */
  72880. samplers?: string[];
  72881. /**
  72882. * The list of defines used in the shader
  72883. */
  72884. defines?: string[];
  72885. }
  72886. /**
  72887. * Interface to implement to create a shadow generator compatible with BJS.
  72888. */
  72889. export interface IShadowGenerator {
  72890. /**
  72891. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72892. * @returns The render target texture if present otherwise, null
  72893. */
  72894. getShadowMap(): Nullable<RenderTargetTexture>;
  72895. /**
  72896. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72897. * @returns The render target texture if the shadow map is present otherwise, null
  72898. */
  72899. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72900. /**
  72901. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72902. * @param subMesh The submesh we want to render in the shadow map
  72903. * @param useInstances Defines wether will draw in the map using instances
  72904. * @returns true if ready otherwise, false
  72905. */
  72906. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72907. /**
  72908. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72909. * @param defines Defines of the material we want to update
  72910. * @param lightIndex Index of the light in the enabled light list of the material
  72911. */
  72912. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72913. /**
  72914. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72915. * defined in the generator but impacting the effect).
  72916. * It implies the unifroms available on the materials are the standard BJS ones.
  72917. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72918. * @param effect The effect we are binfing the information for
  72919. */
  72920. bindShadowLight(lightIndex: string, effect: Effect): void;
  72921. /**
  72922. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72923. * (eq to shadow prjection matrix * light transform matrix)
  72924. * @returns The transform matrix used to create the shadow map
  72925. */
  72926. getTransformMatrix(): Matrix;
  72927. /**
  72928. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72929. * Cube and 2D textures for instance.
  72930. */
  72931. recreateShadowMap(): void;
  72932. /**
  72933. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72934. * @param onCompiled Callback triggered at the and of the effects compilation
  72935. * @param options Sets of optional options forcing the compilation with different modes
  72936. */
  72937. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72938. useInstances: boolean;
  72939. }>): void;
  72940. /**
  72941. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72942. * @param options Sets of optional options forcing the compilation with different modes
  72943. * @returns A promise that resolves when the compilation completes
  72944. */
  72945. forceCompilationAsync(options?: Partial<{
  72946. useInstances: boolean;
  72947. }>): Promise<void>;
  72948. /**
  72949. * Serializes the shadow generator setup to a json object.
  72950. * @returns The serialized JSON object
  72951. */
  72952. serialize(): any;
  72953. /**
  72954. * Disposes the Shadow map and related Textures and effects.
  72955. */
  72956. dispose(): void;
  72957. }
  72958. /**
  72959. * Default implementation IShadowGenerator.
  72960. * This is the main object responsible of generating shadows in the framework.
  72961. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72962. */
  72963. export class ShadowGenerator implements IShadowGenerator {
  72964. /**
  72965. * Shadow generator mode None: no filtering applied.
  72966. */
  72967. static readonly FILTER_NONE: number;
  72968. /**
  72969. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72970. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72971. */
  72972. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72973. /**
  72974. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72975. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72976. */
  72977. static readonly FILTER_POISSONSAMPLING: number;
  72978. /**
  72979. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72980. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72981. */
  72982. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72983. /**
  72984. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72985. * edge artifacts on steep falloff.
  72986. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72987. */
  72988. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72989. /**
  72990. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72991. * edge artifacts on steep falloff.
  72992. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72993. */
  72994. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72995. /**
  72996. * Shadow generator mode PCF: Percentage Closer Filtering
  72997. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72998. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72999. */
  73000. static readonly FILTER_PCF: number;
  73001. /**
  73002. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73003. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73004. * Contact Hardening
  73005. */
  73006. static readonly FILTER_PCSS: number;
  73007. /**
  73008. * Reserved for PCF and PCSS
  73009. * Highest Quality.
  73010. *
  73011. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73012. *
  73013. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73014. */
  73015. static readonly QUALITY_HIGH: number;
  73016. /**
  73017. * Reserved for PCF and PCSS
  73018. * Good tradeoff for quality/perf cross devices
  73019. *
  73020. * Execute PCF on a 3*3 kernel.
  73021. *
  73022. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73023. */
  73024. static readonly QUALITY_MEDIUM: number;
  73025. /**
  73026. * Reserved for PCF and PCSS
  73027. * The lowest quality but the fastest.
  73028. *
  73029. * Execute PCF on a 1*1 kernel.
  73030. *
  73031. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73032. */
  73033. static readonly QUALITY_LOW: number;
  73034. /** Gets or sets the custom shader name to use */
  73035. customShaderOptions: ICustomShaderOptions;
  73036. /**
  73037. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73038. */
  73039. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73040. /**
  73041. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73042. */
  73043. onAfterShadowMapRenderObservable: Observable<Effect>;
  73044. /**
  73045. * Observable triggered before a mesh is rendered in the shadow map.
  73046. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73047. */
  73048. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73049. /**
  73050. * Observable triggered after a mesh is rendered in the shadow map.
  73051. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73052. */
  73053. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73054. private _bias;
  73055. /**
  73056. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73057. */
  73058. /**
  73059. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73060. */
  73061. bias: number;
  73062. private _normalBias;
  73063. /**
  73064. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73065. */
  73066. /**
  73067. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73068. */
  73069. normalBias: number;
  73070. private _blurBoxOffset;
  73071. /**
  73072. * Gets the blur box offset: offset applied during the blur pass.
  73073. * Only useful if useKernelBlur = false
  73074. */
  73075. /**
  73076. * Sets the blur box offset: offset applied during the blur pass.
  73077. * Only useful if useKernelBlur = false
  73078. */
  73079. blurBoxOffset: number;
  73080. private _blurScale;
  73081. /**
  73082. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73083. * 2 means half of the size.
  73084. */
  73085. /**
  73086. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73087. * 2 means half of the size.
  73088. */
  73089. blurScale: number;
  73090. private _blurKernel;
  73091. /**
  73092. * Gets the blur kernel: kernel size of the blur pass.
  73093. * Only useful if useKernelBlur = true
  73094. */
  73095. /**
  73096. * Sets the blur kernel: kernel size of the blur pass.
  73097. * Only useful if useKernelBlur = true
  73098. */
  73099. blurKernel: number;
  73100. private _useKernelBlur;
  73101. /**
  73102. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73103. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73104. */
  73105. /**
  73106. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73107. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73108. */
  73109. useKernelBlur: boolean;
  73110. private _depthScale;
  73111. /**
  73112. * Gets the depth scale used in ESM mode.
  73113. */
  73114. /**
  73115. * Sets the depth scale used in ESM mode.
  73116. * This can override the scale stored on the light.
  73117. */
  73118. depthScale: number;
  73119. private _filter;
  73120. /**
  73121. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73122. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73123. */
  73124. /**
  73125. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73126. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73127. */
  73128. filter: number;
  73129. /**
  73130. * Gets if the current filter is set to Poisson Sampling.
  73131. */
  73132. /**
  73133. * Sets the current filter to Poisson Sampling.
  73134. */
  73135. usePoissonSampling: boolean;
  73136. /**
  73137. * Gets if the current filter is set to ESM.
  73138. */
  73139. /**
  73140. * Sets the current filter is to ESM.
  73141. */
  73142. useExponentialShadowMap: boolean;
  73143. /**
  73144. * Gets if the current filter is set to filtered ESM.
  73145. */
  73146. /**
  73147. * Gets if the current filter is set to filtered ESM.
  73148. */
  73149. useBlurExponentialShadowMap: boolean;
  73150. /**
  73151. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73152. * exponential to prevent steep falloff artifacts).
  73153. */
  73154. /**
  73155. * Sets the current filter to "close ESM" (using the inverse of the
  73156. * exponential to prevent steep falloff artifacts).
  73157. */
  73158. useCloseExponentialShadowMap: boolean;
  73159. /**
  73160. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73161. * exponential to prevent steep falloff artifacts).
  73162. */
  73163. /**
  73164. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73165. * exponential to prevent steep falloff artifacts).
  73166. */
  73167. useBlurCloseExponentialShadowMap: boolean;
  73168. /**
  73169. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73170. */
  73171. /**
  73172. * Sets the current filter to "PCF" (percentage closer filtering).
  73173. */
  73174. usePercentageCloserFiltering: boolean;
  73175. private _filteringQuality;
  73176. /**
  73177. * Gets the PCF or PCSS Quality.
  73178. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73179. */
  73180. /**
  73181. * Sets the PCF or PCSS Quality.
  73182. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73183. */
  73184. filteringQuality: number;
  73185. /**
  73186. * Gets if the current filter is set to "PCSS" (contact hardening).
  73187. */
  73188. /**
  73189. * Sets the current filter to "PCSS" (contact hardening).
  73190. */
  73191. useContactHardeningShadow: boolean;
  73192. private _contactHardeningLightSizeUVRatio;
  73193. /**
  73194. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73195. * Using a ratio helps keeping shape stability independently of the map size.
  73196. *
  73197. * It does not account for the light projection as it was having too much
  73198. * instability during the light setup or during light position changes.
  73199. *
  73200. * Only valid if useContactHardeningShadow is true.
  73201. */
  73202. /**
  73203. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73204. * Using a ratio helps keeping shape stability independently of the map size.
  73205. *
  73206. * It does not account for the light projection as it was having too much
  73207. * instability during the light setup or during light position changes.
  73208. *
  73209. * Only valid if useContactHardeningShadow is true.
  73210. */
  73211. contactHardeningLightSizeUVRatio: number;
  73212. private _darkness;
  73213. /** Gets or sets the actual darkness of a shadow */
  73214. darkness: number;
  73215. /**
  73216. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73217. * 0 means strongest and 1 would means no shadow.
  73218. * @returns the darkness.
  73219. */
  73220. getDarkness(): number;
  73221. /**
  73222. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73223. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73224. * @returns the shadow generator allowing fluent coding.
  73225. */
  73226. setDarkness(darkness: number): ShadowGenerator;
  73227. private _transparencyShadow;
  73228. /** Gets or sets the ability to have transparent shadow */
  73229. transparencyShadow: boolean;
  73230. /**
  73231. * Sets the ability to have transparent shadow (boolean).
  73232. * @param transparent True if transparent else False
  73233. * @returns the shadow generator allowing fluent coding
  73234. */
  73235. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73236. private _shadowMap;
  73237. private _shadowMap2;
  73238. /**
  73239. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73240. * @returns The render target texture if present otherwise, null
  73241. */
  73242. getShadowMap(): Nullable<RenderTargetTexture>;
  73243. /**
  73244. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73245. * @returns The render target texture if the shadow map is present otherwise, null
  73246. */
  73247. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73248. /**
  73249. * Gets the class name of that object
  73250. * @returns "ShadowGenerator"
  73251. */
  73252. getClassName(): string;
  73253. /**
  73254. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73255. * @param mesh Mesh to add
  73256. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73257. * @returns the Shadow Generator itself
  73258. */
  73259. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73260. /**
  73261. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73262. * @param mesh Mesh to remove
  73263. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73264. * @returns the Shadow Generator itself
  73265. */
  73266. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73267. /**
  73268. * Controls the extent to which the shadows fade out at the edge of the frustum
  73269. * Used only by directionals and spots
  73270. */
  73271. frustumEdgeFalloff: number;
  73272. private _light;
  73273. /**
  73274. * Returns the associated light object.
  73275. * @returns the light generating the shadow
  73276. */
  73277. getLight(): IShadowLight;
  73278. /**
  73279. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73280. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73281. * It might on the other hand introduce peter panning.
  73282. */
  73283. forceBackFacesOnly: boolean;
  73284. private _scene;
  73285. private _lightDirection;
  73286. private _effect;
  73287. private _viewMatrix;
  73288. private _projectionMatrix;
  73289. private _transformMatrix;
  73290. private _cachedPosition;
  73291. private _cachedDirection;
  73292. private _cachedDefines;
  73293. private _currentRenderID;
  73294. private _boxBlurPostprocess;
  73295. private _kernelBlurXPostprocess;
  73296. private _kernelBlurYPostprocess;
  73297. private _blurPostProcesses;
  73298. private _mapSize;
  73299. private _currentFaceIndex;
  73300. private _currentFaceIndexCache;
  73301. private _textureType;
  73302. private _defaultTextureMatrix;
  73303. /** @hidden */
  73304. static _SceneComponentInitialization: (scene: Scene) => void;
  73305. /**
  73306. * Creates a ShadowGenerator object.
  73307. * A ShadowGenerator is the required tool to use the shadows.
  73308. * Each light casting shadows needs to use its own ShadowGenerator.
  73309. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73310. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73311. * @param light The light object generating the shadows.
  73312. * @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.
  73313. */
  73314. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73315. private _initializeGenerator;
  73316. private _initializeShadowMap;
  73317. private _initializeBlurRTTAndPostProcesses;
  73318. private _renderForShadowMap;
  73319. private _renderSubMeshForShadowMap;
  73320. private _applyFilterValues;
  73321. /**
  73322. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73323. * @param onCompiled Callback triggered at the and of the effects compilation
  73324. * @param options Sets of optional options forcing the compilation with different modes
  73325. */
  73326. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73327. useInstances: boolean;
  73328. }>): void;
  73329. /**
  73330. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73331. * @param options Sets of optional options forcing the compilation with different modes
  73332. * @returns A promise that resolves when the compilation completes
  73333. */
  73334. forceCompilationAsync(options?: Partial<{
  73335. useInstances: boolean;
  73336. }>): Promise<void>;
  73337. /**
  73338. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73339. * @param subMesh The submesh we want to render in the shadow map
  73340. * @param useInstances Defines wether will draw in the map using instances
  73341. * @returns true if ready otherwise, false
  73342. */
  73343. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73344. /**
  73345. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73346. * @param defines Defines of the material we want to update
  73347. * @param lightIndex Index of the light in the enabled light list of the material
  73348. */
  73349. prepareDefines(defines: any, lightIndex: number): void;
  73350. /**
  73351. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73352. * defined in the generator but impacting the effect).
  73353. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73354. * @param effect The effect we are binfing the information for
  73355. */
  73356. bindShadowLight(lightIndex: string, effect: Effect): void;
  73357. /**
  73358. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73359. * (eq to shadow prjection matrix * light transform matrix)
  73360. * @returns The transform matrix used to create the shadow map
  73361. */
  73362. getTransformMatrix(): Matrix;
  73363. /**
  73364. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73365. * Cube and 2D textures for instance.
  73366. */
  73367. recreateShadowMap(): void;
  73368. private _disposeBlurPostProcesses;
  73369. private _disposeRTTandPostProcesses;
  73370. /**
  73371. * Disposes the ShadowGenerator.
  73372. * Returns nothing.
  73373. */
  73374. dispose(): void;
  73375. /**
  73376. * Serializes the shadow generator setup to a json object.
  73377. * @returns The serialized JSON object
  73378. */
  73379. serialize(): any;
  73380. /**
  73381. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73382. * @param parsedShadowGenerator The JSON object to parse
  73383. * @param scene The scene to create the shadow map for
  73384. * @returns The parsed shadow generator
  73385. */
  73386. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73387. }
  73388. }
  73389. declare module BABYLON {
  73390. /**
  73391. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73392. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73393. * 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.
  73394. */
  73395. export abstract class Light extends Node {
  73396. /**
  73397. * Falloff Default: light is falling off following the material specification:
  73398. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73399. */
  73400. static readonly FALLOFF_DEFAULT: number;
  73401. /**
  73402. * Falloff Physical: light is falling off following the inverse squared distance law.
  73403. */
  73404. static readonly FALLOFF_PHYSICAL: number;
  73405. /**
  73406. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73407. * to enhance interoperability with other engines.
  73408. */
  73409. static readonly FALLOFF_GLTF: number;
  73410. /**
  73411. * Falloff Standard: light is falling off like in the standard material
  73412. * to enhance interoperability with other materials.
  73413. */
  73414. static readonly FALLOFF_STANDARD: number;
  73415. /**
  73416. * If every light affecting the material is in this lightmapMode,
  73417. * material.lightmapTexture adds or multiplies
  73418. * (depends on material.useLightmapAsShadowmap)
  73419. * after every other light calculations.
  73420. */
  73421. static readonly LIGHTMAP_DEFAULT: number;
  73422. /**
  73423. * material.lightmapTexture as only diffuse lighting from this light
  73424. * adds only specular lighting from this light
  73425. * adds dynamic shadows
  73426. */
  73427. static readonly LIGHTMAP_SPECULAR: number;
  73428. /**
  73429. * material.lightmapTexture as only lighting
  73430. * no light calculation from this light
  73431. * only adds dynamic shadows from this light
  73432. */
  73433. static readonly LIGHTMAP_SHADOWSONLY: number;
  73434. /**
  73435. * Each light type uses the default quantity according to its type:
  73436. * point/spot lights use luminous intensity
  73437. * directional lights use illuminance
  73438. */
  73439. static readonly INTENSITYMODE_AUTOMATIC: number;
  73440. /**
  73441. * lumen (lm)
  73442. */
  73443. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73444. /**
  73445. * candela (lm/sr)
  73446. */
  73447. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73448. /**
  73449. * lux (lm/m^2)
  73450. */
  73451. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73452. /**
  73453. * nit (cd/m^2)
  73454. */
  73455. static readonly INTENSITYMODE_LUMINANCE: number;
  73456. /**
  73457. * Light type const id of the point light.
  73458. */
  73459. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73460. /**
  73461. * Light type const id of the directional light.
  73462. */
  73463. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73464. /**
  73465. * Light type const id of the spot light.
  73466. */
  73467. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73468. /**
  73469. * Light type const id of the hemispheric light.
  73470. */
  73471. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73472. /**
  73473. * Diffuse gives the basic color to an object.
  73474. */
  73475. diffuse: Color3;
  73476. /**
  73477. * Specular produces a highlight color on an object.
  73478. * Note: This is note affecting PBR materials.
  73479. */
  73480. specular: Color3;
  73481. /**
  73482. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73483. * falling off base on range or angle.
  73484. * This can be set to any values in Light.FALLOFF_x.
  73485. *
  73486. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73487. * other types of materials.
  73488. */
  73489. falloffType: number;
  73490. /**
  73491. * Strength of the light.
  73492. * Note: By default it is define in the framework own unit.
  73493. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73494. */
  73495. intensity: number;
  73496. private _range;
  73497. protected _inverseSquaredRange: number;
  73498. /**
  73499. * Defines how far from the source the light is impacting in scene units.
  73500. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73501. */
  73502. /**
  73503. * Defines how far from the source the light is impacting in scene units.
  73504. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73505. */
  73506. range: number;
  73507. /**
  73508. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73509. * of light.
  73510. */
  73511. private _photometricScale;
  73512. private _intensityMode;
  73513. /**
  73514. * Gets the photometric scale used to interpret the intensity.
  73515. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73516. */
  73517. /**
  73518. * Sets the photometric scale used to interpret the intensity.
  73519. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73520. */
  73521. intensityMode: number;
  73522. private _radius;
  73523. /**
  73524. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73525. */
  73526. /**
  73527. * sets the light radius used by PBR Materials to simulate soft area lights.
  73528. */
  73529. radius: number;
  73530. private _renderPriority;
  73531. /**
  73532. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73533. * exceeding the number allowed of the materials.
  73534. */
  73535. renderPriority: number;
  73536. private _shadowEnabled;
  73537. /**
  73538. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73539. * the current shadow generator.
  73540. */
  73541. /**
  73542. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73543. * the current shadow generator.
  73544. */
  73545. shadowEnabled: boolean;
  73546. private _includedOnlyMeshes;
  73547. /**
  73548. * Gets the only meshes impacted by this light.
  73549. */
  73550. /**
  73551. * Sets the only meshes impacted by this light.
  73552. */
  73553. includedOnlyMeshes: AbstractMesh[];
  73554. private _excludedMeshes;
  73555. /**
  73556. * Gets the meshes not impacted by this light.
  73557. */
  73558. /**
  73559. * Sets the meshes not impacted by this light.
  73560. */
  73561. excludedMeshes: AbstractMesh[];
  73562. private _excludeWithLayerMask;
  73563. /**
  73564. * Gets the layer id use to find what meshes are not impacted by the light.
  73565. * Inactive if 0
  73566. */
  73567. /**
  73568. * Sets the layer id use to find what meshes are not impacted by the light.
  73569. * Inactive if 0
  73570. */
  73571. excludeWithLayerMask: number;
  73572. private _includeOnlyWithLayerMask;
  73573. /**
  73574. * Gets the layer id use to find what meshes are impacted by the light.
  73575. * Inactive if 0
  73576. */
  73577. /**
  73578. * Sets the layer id use to find what meshes are impacted by the light.
  73579. * Inactive if 0
  73580. */
  73581. includeOnlyWithLayerMask: number;
  73582. private _lightmapMode;
  73583. /**
  73584. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73585. */
  73586. /**
  73587. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73588. */
  73589. lightmapMode: number;
  73590. /**
  73591. * Shadow generator associted to the light.
  73592. * @hidden Internal use only.
  73593. */
  73594. _shadowGenerator: Nullable<IShadowGenerator>;
  73595. /**
  73596. * @hidden Internal use only.
  73597. */
  73598. _excludedMeshesIds: string[];
  73599. /**
  73600. * @hidden Internal use only.
  73601. */
  73602. _includedOnlyMeshesIds: string[];
  73603. /**
  73604. * The current light unifom buffer.
  73605. * @hidden Internal use only.
  73606. */
  73607. _uniformBuffer: UniformBuffer;
  73608. /**
  73609. * Creates a Light object in the scene.
  73610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73611. * @param name The firendly name of the light
  73612. * @param scene The scene the light belongs too
  73613. */
  73614. constructor(name: string, scene: Scene);
  73615. protected abstract _buildUniformLayout(): void;
  73616. /**
  73617. * Sets the passed Effect "effect" with the Light information.
  73618. * @param effect The effect to update
  73619. * @param lightIndex The index of the light in the effect to update
  73620. * @returns The light
  73621. */
  73622. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73623. /**
  73624. * Returns the string "Light".
  73625. * @returns the class name
  73626. */
  73627. getClassName(): string;
  73628. /** @hidden */
  73629. readonly _isLight: boolean;
  73630. /**
  73631. * Converts the light information to a readable string for debug purpose.
  73632. * @param fullDetails Supports for multiple levels of logging within scene loading
  73633. * @returns the human readable light info
  73634. */
  73635. toString(fullDetails?: boolean): string;
  73636. /** @hidden */
  73637. protected _syncParentEnabledState(): void;
  73638. /**
  73639. * Set the enabled state of this node.
  73640. * @param value - the new enabled state
  73641. */
  73642. setEnabled(value: boolean): void;
  73643. /**
  73644. * Returns the Light associated shadow generator if any.
  73645. * @return the associated shadow generator.
  73646. */
  73647. getShadowGenerator(): Nullable<IShadowGenerator>;
  73648. /**
  73649. * Returns a Vector3, the absolute light position in the World.
  73650. * @returns the world space position of the light
  73651. */
  73652. getAbsolutePosition(): Vector3;
  73653. /**
  73654. * Specifies if the light will affect the passed mesh.
  73655. * @param mesh The mesh to test against the light
  73656. * @return true the mesh is affected otherwise, false.
  73657. */
  73658. canAffectMesh(mesh: AbstractMesh): boolean;
  73659. /**
  73660. * Sort function to order lights for rendering.
  73661. * @param a First Light object to compare to second.
  73662. * @param b Second Light object to compare first.
  73663. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73664. */
  73665. static CompareLightsPriority(a: Light, b: Light): number;
  73666. /**
  73667. * Releases resources associated with this node.
  73668. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73669. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73670. */
  73671. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73672. /**
  73673. * Returns the light type ID (integer).
  73674. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73675. */
  73676. getTypeID(): number;
  73677. /**
  73678. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73679. * @returns the scaled intensity in intensity mode unit
  73680. */
  73681. getScaledIntensity(): number;
  73682. /**
  73683. * Returns a new Light object, named "name", from the current one.
  73684. * @param name The name of the cloned light
  73685. * @returns the new created light
  73686. */
  73687. clone(name: string): Nullable<Light>;
  73688. /**
  73689. * Serializes the current light into a Serialization object.
  73690. * @returns the serialized object.
  73691. */
  73692. serialize(): any;
  73693. /**
  73694. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73695. * This new light is named "name" and added to the passed scene.
  73696. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73697. * @param name The friendly name of the light
  73698. * @param scene The scene the new light will belong to
  73699. * @returns the constructor function
  73700. */
  73701. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73702. /**
  73703. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73704. * @param parsedLight The JSON representation of the light
  73705. * @param scene The scene to create the parsed light in
  73706. * @returns the created light after parsing
  73707. */
  73708. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73709. private _hookArrayForExcluded;
  73710. private _hookArrayForIncludedOnly;
  73711. private _resyncMeshes;
  73712. /**
  73713. * Forces the meshes to update their light related information in their rendering used effects
  73714. * @hidden Internal Use Only
  73715. */
  73716. _markMeshesAsLightDirty(): void;
  73717. /**
  73718. * Recomputes the cached photometric scale if needed.
  73719. */
  73720. private _computePhotometricScale;
  73721. /**
  73722. * Returns the Photometric Scale according to the light type and intensity mode.
  73723. */
  73724. private _getPhotometricScale;
  73725. /**
  73726. * Reorder the light in the scene according to their defined priority.
  73727. * @hidden Internal Use Only
  73728. */
  73729. _reorderLightsInScene(): void;
  73730. /**
  73731. * Prepares the list of defines specific to the light type.
  73732. * @param defines the list of defines
  73733. * @param lightIndex defines the index of the light for the effect
  73734. */
  73735. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73736. }
  73737. }
  73738. declare module BABYLON {
  73739. /**
  73740. * Interface used to define Action
  73741. */
  73742. export interface IAction {
  73743. /**
  73744. * Trigger for the action
  73745. */
  73746. trigger: number;
  73747. /** Options of the trigger */
  73748. triggerOptions: any;
  73749. /**
  73750. * Gets the trigger parameters
  73751. * @returns the trigger parameters
  73752. */
  73753. getTriggerParameter(): any;
  73754. /**
  73755. * Internal only - executes current action event
  73756. * @hidden
  73757. */
  73758. _executeCurrent(evt?: ActionEvent): void;
  73759. /**
  73760. * Serialize placeholder for child classes
  73761. * @param parent of child
  73762. * @returns the serialized object
  73763. */
  73764. serialize(parent: any): any;
  73765. /**
  73766. * Internal only
  73767. * @hidden
  73768. */
  73769. _prepare(): void;
  73770. /**
  73771. * Internal only - manager for action
  73772. * @hidden
  73773. */
  73774. _actionManager: AbstractActionManager;
  73775. /**
  73776. * Adds action to chain of actions, may be a DoNothingAction
  73777. * @param action defines the next action to execute
  73778. * @returns The action passed in
  73779. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73780. */
  73781. then(action: IAction): IAction;
  73782. }
  73783. /**
  73784. * The action to be carried out following a trigger
  73785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73786. */
  73787. export class Action implements IAction {
  73788. /** the trigger, with or without parameters, for the action */
  73789. triggerOptions: any;
  73790. /**
  73791. * Trigger for the action
  73792. */
  73793. trigger: number;
  73794. /**
  73795. * Internal only - manager for action
  73796. * @hidden
  73797. */
  73798. _actionManager: ActionManager;
  73799. private _nextActiveAction;
  73800. private _child;
  73801. private _condition?;
  73802. private _triggerParameter;
  73803. /**
  73804. * An event triggered prior to action being executed.
  73805. */
  73806. onBeforeExecuteObservable: Observable<Action>;
  73807. /**
  73808. * Creates a new Action
  73809. * @param triggerOptions the trigger, with or without parameters, for the action
  73810. * @param condition an optional determinant of action
  73811. */
  73812. constructor(
  73813. /** the trigger, with or without parameters, for the action */
  73814. triggerOptions: any, condition?: Condition);
  73815. /**
  73816. * Internal only
  73817. * @hidden
  73818. */
  73819. _prepare(): void;
  73820. /**
  73821. * Gets the trigger parameters
  73822. * @returns the trigger parameters
  73823. */
  73824. getTriggerParameter(): any;
  73825. /**
  73826. * Internal only - executes current action event
  73827. * @hidden
  73828. */
  73829. _executeCurrent(evt?: ActionEvent): void;
  73830. /**
  73831. * Execute placeholder for child classes
  73832. * @param evt optional action event
  73833. */
  73834. execute(evt?: ActionEvent): void;
  73835. /**
  73836. * Skips to next active action
  73837. */
  73838. skipToNextActiveAction(): void;
  73839. /**
  73840. * Adds action to chain of actions, may be a DoNothingAction
  73841. * @param action defines the next action to execute
  73842. * @returns The action passed in
  73843. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73844. */
  73845. then(action: Action): Action;
  73846. /**
  73847. * Internal only
  73848. * @hidden
  73849. */
  73850. _getProperty(propertyPath: string): string;
  73851. /**
  73852. * Internal only
  73853. * @hidden
  73854. */
  73855. _getEffectiveTarget(target: any, propertyPath: string): any;
  73856. /**
  73857. * Serialize placeholder for child classes
  73858. * @param parent of child
  73859. * @returns the serialized object
  73860. */
  73861. serialize(parent: any): any;
  73862. /**
  73863. * Internal only called by serialize
  73864. * @hidden
  73865. */
  73866. protected _serialize(serializedAction: any, parent?: any): any;
  73867. /**
  73868. * Internal only
  73869. * @hidden
  73870. */
  73871. static _SerializeValueAsString: (value: any) => string;
  73872. /**
  73873. * Internal only
  73874. * @hidden
  73875. */
  73876. static _GetTargetProperty: (target: Node | Scene) => {
  73877. name: string;
  73878. targetType: string;
  73879. value: string;
  73880. };
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * A Condition applied to an Action
  73886. */
  73887. export class Condition {
  73888. /**
  73889. * Internal only - manager for action
  73890. * @hidden
  73891. */
  73892. _actionManager: ActionManager;
  73893. /**
  73894. * Internal only
  73895. * @hidden
  73896. */
  73897. _evaluationId: number;
  73898. /**
  73899. * Internal only
  73900. * @hidden
  73901. */
  73902. _currentResult: boolean;
  73903. /**
  73904. * Creates a new Condition
  73905. * @param actionManager the manager of the action the condition is applied to
  73906. */
  73907. constructor(actionManager: ActionManager);
  73908. /**
  73909. * Check if the current condition is valid
  73910. * @returns a boolean
  73911. */
  73912. isValid(): boolean;
  73913. /**
  73914. * Internal only
  73915. * @hidden
  73916. */
  73917. _getProperty(propertyPath: string): string;
  73918. /**
  73919. * Internal only
  73920. * @hidden
  73921. */
  73922. _getEffectiveTarget(target: any, propertyPath: string): any;
  73923. /**
  73924. * Serialize placeholder for child classes
  73925. * @returns the serialized object
  73926. */
  73927. serialize(): any;
  73928. /**
  73929. * Internal only
  73930. * @hidden
  73931. */
  73932. protected _serialize(serializedCondition: any): any;
  73933. }
  73934. /**
  73935. * Defines specific conditional operators as extensions of Condition
  73936. */
  73937. export class ValueCondition extends Condition {
  73938. /** path to specify the property of the target the conditional operator uses */
  73939. propertyPath: string;
  73940. /** the value compared by the conditional operator against the current value of the property */
  73941. value: any;
  73942. /** the conditional operator, default ValueCondition.IsEqual */
  73943. operator: number;
  73944. /**
  73945. * Internal only
  73946. * @hidden
  73947. */
  73948. private static _IsEqual;
  73949. /**
  73950. * Internal only
  73951. * @hidden
  73952. */
  73953. private static _IsDifferent;
  73954. /**
  73955. * Internal only
  73956. * @hidden
  73957. */
  73958. private static _IsGreater;
  73959. /**
  73960. * Internal only
  73961. * @hidden
  73962. */
  73963. private static _IsLesser;
  73964. /**
  73965. * returns the number for IsEqual
  73966. */
  73967. static readonly IsEqual: number;
  73968. /**
  73969. * Returns the number for IsDifferent
  73970. */
  73971. static readonly IsDifferent: number;
  73972. /**
  73973. * Returns the number for IsGreater
  73974. */
  73975. static readonly IsGreater: number;
  73976. /**
  73977. * Returns the number for IsLesser
  73978. */
  73979. static readonly IsLesser: number;
  73980. /**
  73981. * Internal only The action manager for the condition
  73982. * @hidden
  73983. */
  73984. _actionManager: ActionManager;
  73985. /**
  73986. * Internal only
  73987. * @hidden
  73988. */
  73989. private _target;
  73990. /**
  73991. * Internal only
  73992. * @hidden
  73993. */
  73994. private _effectiveTarget;
  73995. /**
  73996. * Internal only
  73997. * @hidden
  73998. */
  73999. private _property;
  74000. /**
  74001. * Creates a new ValueCondition
  74002. * @param actionManager manager for the action the condition applies to
  74003. * @param target for the action
  74004. * @param propertyPath path to specify the property of the target the conditional operator uses
  74005. * @param value the value compared by the conditional operator against the current value of the property
  74006. * @param operator the conditional operator, default ValueCondition.IsEqual
  74007. */
  74008. constructor(actionManager: ActionManager, target: any,
  74009. /** path to specify the property of the target the conditional operator uses */
  74010. propertyPath: string,
  74011. /** the value compared by the conditional operator against the current value of the property */
  74012. value: any,
  74013. /** the conditional operator, default ValueCondition.IsEqual */
  74014. operator?: number);
  74015. /**
  74016. * Compares the given value with the property value for the specified conditional operator
  74017. * @returns the result of the comparison
  74018. */
  74019. isValid(): boolean;
  74020. /**
  74021. * Serialize the ValueCondition into a JSON compatible object
  74022. * @returns serialization object
  74023. */
  74024. serialize(): any;
  74025. /**
  74026. * Gets the name of the conditional operator for the ValueCondition
  74027. * @param operator the conditional operator
  74028. * @returns the name
  74029. */
  74030. static GetOperatorName(operator: number): string;
  74031. }
  74032. /**
  74033. * Defines a predicate condition as an extension of Condition
  74034. */
  74035. export class PredicateCondition extends Condition {
  74036. /** defines the predicate function used to validate the condition */
  74037. predicate: () => boolean;
  74038. /**
  74039. * Internal only - manager for action
  74040. * @hidden
  74041. */
  74042. _actionManager: ActionManager;
  74043. /**
  74044. * Creates a new PredicateCondition
  74045. * @param actionManager manager for the action the condition applies to
  74046. * @param predicate defines the predicate function used to validate the condition
  74047. */
  74048. constructor(actionManager: ActionManager,
  74049. /** defines the predicate function used to validate the condition */
  74050. predicate: () => boolean);
  74051. /**
  74052. * @returns the validity of the predicate condition
  74053. */
  74054. isValid(): boolean;
  74055. }
  74056. /**
  74057. * Defines a state condition as an extension of Condition
  74058. */
  74059. export class StateCondition extends Condition {
  74060. /** Value to compare with target state */
  74061. value: string;
  74062. /**
  74063. * Internal only - manager for action
  74064. * @hidden
  74065. */
  74066. _actionManager: ActionManager;
  74067. /**
  74068. * Internal only
  74069. * @hidden
  74070. */
  74071. private _target;
  74072. /**
  74073. * Creates a new StateCondition
  74074. * @param actionManager manager for the action the condition applies to
  74075. * @param target of the condition
  74076. * @param value to compare with target state
  74077. */
  74078. constructor(actionManager: ActionManager, target: any,
  74079. /** Value to compare with target state */
  74080. value: string);
  74081. /**
  74082. * Gets a boolean indicating if the current condition is met
  74083. * @returns the validity of the state
  74084. */
  74085. isValid(): boolean;
  74086. /**
  74087. * Serialize the StateCondition into a JSON compatible object
  74088. * @returns serialization object
  74089. */
  74090. serialize(): any;
  74091. }
  74092. }
  74093. declare module BABYLON {
  74094. /**
  74095. * This defines an action responsible to toggle a boolean once triggered.
  74096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74097. */
  74098. export class SwitchBooleanAction extends Action {
  74099. /**
  74100. * The path to the boolean property in the target object
  74101. */
  74102. propertyPath: string;
  74103. private _target;
  74104. private _effectiveTarget;
  74105. private _property;
  74106. /**
  74107. * Instantiate the action
  74108. * @param triggerOptions defines the trigger options
  74109. * @param target defines the object containing the boolean
  74110. * @param propertyPath defines the path to the boolean property in the target object
  74111. * @param condition defines the trigger related conditions
  74112. */
  74113. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74114. /** @hidden */
  74115. _prepare(): void;
  74116. /**
  74117. * Execute the action toggle the boolean value.
  74118. */
  74119. execute(): void;
  74120. /**
  74121. * Serializes the actions and its related information.
  74122. * @param parent defines the object to serialize in
  74123. * @returns the serialized object
  74124. */
  74125. serialize(parent: any): any;
  74126. }
  74127. /**
  74128. * This defines an action responsible to set a the state field of the target
  74129. * to a desired value once triggered.
  74130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74131. */
  74132. export class SetStateAction extends Action {
  74133. /**
  74134. * The value to store in the state field.
  74135. */
  74136. value: string;
  74137. private _target;
  74138. /**
  74139. * Instantiate the action
  74140. * @param triggerOptions defines the trigger options
  74141. * @param target defines the object containing the state property
  74142. * @param value defines the value to store in the state field
  74143. * @param condition defines the trigger related conditions
  74144. */
  74145. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74146. /**
  74147. * Execute the action and store the value on the target state property.
  74148. */
  74149. execute(): void;
  74150. /**
  74151. * Serializes the actions and its related information.
  74152. * @param parent defines the object to serialize in
  74153. * @returns the serialized object
  74154. */
  74155. serialize(parent: any): any;
  74156. }
  74157. /**
  74158. * This defines an action responsible to set a property of the target
  74159. * to a desired value once triggered.
  74160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74161. */
  74162. export class SetValueAction extends Action {
  74163. /**
  74164. * The path of the property to set in the target.
  74165. */
  74166. propertyPath: string;
  74167. /**
  74168. * The value to set in the property
  74169. */
  74170. value: any;
  74171. private _target;
  74172. private _effectiveTarget;
  74173. private _property;
  74174. /**
  74175. * Instantiate the action
  74176. * @param triggerOptions defines the trigger options
  74177. * @param target defines the object containing the property
  74178. * @param propertyPath defines the path of the property to set in the target
  74179. * @param value defines the value to set in the property
  74180. * @param condition defines the trigger related conditions
  74181. */
  74182. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74183. /** @hidden */
  74184. _prepare(): void;
  74185. /**
  74186. * Execute the action and set the targetted property to the desired value.
  74187. */
  74188. execute(): void;
  74189. /**
  74190. * Serializes the actions and its related information.
  74191. * @param parent defines the object to serialize in
  74192. * @returns the serialized object
  74193. */
  74194. serialize(parent: any): any;
  74195. }
  74196. /**
  74197. * This defines an action responsible to increment the target value
  74198. * to a desired value once triggered.
  74199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74200. */
  74201. export class IncrementValueAction extends Action {
  74202. /**
  74203. * The path of the property to increment in the target.
  74204. */
  74205. propertyPath: string;
  74206. /**
  74207. * The value we should increment the property by.
  74208. */
  74209. value: any;
  74210. private _target;
  74211. private _effectiveTarget;
  74212. private _property;
  74213. /**
  74214. * Instantiate the action
  74215. * @param triggerOptions defines the trigger options
  74216. * @param target defines the object containing the property
  74217. * @param propertyPath defines the path of the property to increment in the target
  74218. * @param value defines the value value we should increment the property by
  74219. * @param condition defines the trigger related conditions
  74220. */
  74221. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74222. /** @hidden */
  74223. _prepare(): void;
  74224. /**
  74225. * Execute the action and increment the target of the value amount.
  74226. */
  74227. execute(): void;
  74228. /**
  74229. * Serializes the actions and its related information.
  74230. * @param parent defines the object to serialize in
  74231. * @returns the serialized object
  74232. */
  74233. serialize(parent: any): any;
  74234. }
  74235. /**
  74236. * This defines an action responsible to start an animation once triggered.
  74237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74238. */
  74239. export class PlayAnimationAction extends Action {
  74240. /**
  74241. * Where the animation should start (animation frame)
  74242. */
  74243. from: number;
  74244. /**
  74245. * Where the animation should stop (animation frame)
  74246. */
  74247. to: number;
  74248. /**
  74249. * Define if the animation should loop or stop after the first play.
  74250. */
  74251. loop?: boolean;
  74252. private _target;
  74253. /**
  74254. * Instantiate the action
  74255. * @param triggerOptions defines the trigger options
  74256. * @param target defines the target animation or animation name
  74257. * @param from defines from where the animation should start (animation frame)
  74258. * @param end defines where the animation should stop (animation frame)
  74259. * @param loop defines if the animation should loop or stop after the first play
  74260. * @param condition defines the trigger related conditions
  74261. */
  74262. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74263. /** @hidden */
  74264. _prepare(): void;
  74265. /**
  74266. * Execute the action and play the animation.
  74267. */
  74268. execute(): void;
  74269. /**
  74270. * Serializes the actions and its related information.
  74271. * @param parent defines the object to serialize in
  74272. * @returns the serialized object
  74273. */
  74274. serialize(parent: any): any;
  74275. }
  74276. /**
  74277. * This defines an action responsible to stop an animation once triggered.
  74278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74279. */
  74280. export class StopAnimationAction extends Action {
  74281. private _target;
  74282. /**
  74283. * Instantiate the action
  74284. * @param triggerOptions defines the trigger options
  74285. * @param target defines the target animation or animation name
  74286. * @param condition defines the trigger related conditions
  74287. */
  74288. constructor(triggerOptions: any, target: any, condition?: Condition);
  74289. /** @hidden */
  74290. _prepare(): void;
  74291. /**
  74292. * Execute the action and stop the animation.
  74293. */
  74294. execute(): void;
  74295. /**
  74296. * Serializes the actions and its related information.
  74297. * @param parent defines the object to serialize in
  74298. * @returns the serialized object
  74299. */
  74300. serialize(parent: any): any;
  74301. }
  74302. /**
  74303. * This defines an action responsible that does nothing once triggered.
  74304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74305. */
  74306. export class DoNothingAction extends Action {
  74307. /**
  74308. * Instantiate the action
  74309. * @param triggerOptions defines the trigger options
  74310. * @param condition defines the trigger related conditions
  74311. */
  74312. constructor(triggerOptions?: any, condition?: Condition);
  74313. /**
  74314. * Execute the action and do nothing.
  74315. */
  74316. execute(): void;
  74317. /**
  74318. * Serializes the actions and its related information.
  74319. * @param parent defines the object to serialize in
  74320. * @returns the serialized object
  74321. */
  74322. serialize(parent: any): any;
  74323. }
  74324. /**
  74325. * This defines an action responsible to trigger several actions once triggered.
  74326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74327. */
  74328. export class CombineAction extends Action {
  74329. /**
  74330. * The list of aggregated animations to run.
  74331. */
  74332. children: Action[];
  74333. /**
  74334. * Instantiate the action
  74335. * @param triggerOptions defines the trigger options
  74336. * @param children defines the list of aggregated animations to run
  74337. * @param condition defines the trigger related conditions
  74338. */
  74339. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74340. /** @hidden */
  74341. _prepare(): void;
  74342. /**
  74343. * Execute the action and executes all the aggregated actions.
  74344. */
  74345. execute(evt: ActionEvent): void;
  74346. /**
  74347. * Serializes the actions and its related information.
  74348. * @param parent defines the object to serialize in
  74349. * @returns the serialized object
  74350. */
  74351. serialize(parent: any): any;
  74352. }
  74353. /**
  74354. * This defines an action responsible to run code (external event) once triggered.
  74355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74356. */
  74357. export class ExecuteCodeAction extends Action {
  74358. /**
  74359. * The callback function to run.
  74360. */
  74361. func: (evt: ActionEvent) => void;
  74362. /**
  74363. * Instantiate the action
  74364. * @param triggerOptions defines the trigger options
  74365. * @param func defines the callback function to run
  74366. * @param condition defines the trigger related conditions
  74367. */
  74368. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74369. /**
  74370. * Execute the action and run the attached code.
  74371. */
  74372. execute(evt: ActionEvent): void;
  74373. }
  74374. /**
  74375. * This defines an action responsible to set the parent property of the target once triggered.
  74376. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74377. */
  74378. export class SetParentAction extends Action {
  74379. private _parent;
  74380. private _target;
  74381. /**
  74382. * Instantiate the action
  74383. * @param triggerOptions defines the trigger options
  74384. * @param target defines the target containing the parent property
  74385. * @param parent defines from where the animation should start (animation frame)
  74386. * @param condition defines the trigger related conditions
  74387. */
  74388. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74389. /** @hidden */
  74390. _prepare(): void;
  74391. /**
  74392. * Execute the action and set the parent property.
  74393. */
  74394. execute(): void;
  74395. /**
  74396. * Serializes the actions and its related information.
  74397. * @param parent defines the object to serialize in
  74398. * @returns the serialized object
  74399. */
  74400. serialize(parent: any): any;
  74401. }
  74402. }
  74403. declare module BABYLON {
  74404. /**
  74405. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74406. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74408. */
  74409. export class ActionManager extends AbstractActionManager {
  74410. /**
  74411. * Nothing
  74412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74413. */
  74414. static readonly NothingTrigger: number;
  74415. /**
  74416. * On pick
  74417. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74418. */
  74419. static readonly OnPickTrigger: number;
  74420. /**
  74421. * On left pick
  74422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74423. */
  74424. static readonly OnLeftPickTrigger: number;
  74425. /**
  74426. * On right pick
  74427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74428. */
  74429. static readonly OnRightPickTrigger: number;
  74430. /**
  74431. * On center pick
  74432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74433. */
  74434. static readonly OnCenterPickTrigger: number;
  74435. /**
  74436. * On pick down
  74437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74438. */
  74439. static readonly OnPickDownTrigger: number;
  74440. /**
  74441. * On double pick
  74442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74443. */
  74444. static readonly OnDoublePickTrigger: number;
  74445. /**
  74446. * On pick up
  74447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74448. */
  74449. static readonly OnPickUpTrigger: number;
  74450. /**
  74451. * On pick out.
  74452. * This trigger will only be raised if you also declared a OnPickDown
  74453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74454. */
  74455. static readonly OnPickOutTrigger: number;
  74456. /**
  74457. * On long press
  74458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74459. */
  74460. static readonly OnLongPressTrigger: number;
  74461. /**
  74462. * On pointer over
  74463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74464. */
  74465. static readonly OnPointerOverTrigger: number;
  74466. /**
  74467. * On pointer out
  74468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74469. */
  74470. static readonly OnPointerOutTrigger: number;
  74471. /**
  74472. * On every frame
  74473. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74474. */
  74475. static readonly OnEveryFrameTrigger: number;
  74476. /**
  74477. * On intersection enter
  74478. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74479. */
  74480. static readonly OnIntersectionEnterTrigger: number;
  74481. /**
  74482. * On intersection exit
  74483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74484. */
  74485. static readonly OnIntersectionExitTrigger: number;
  74486. /**
  74487. * On key down
  74488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74489. */
  74490. static readonly OnKeyDownTrigger: number;
  74491. /**
  74492. * On key up
  74493. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74494. */
  74495. static readonly OnKeyUpTrigger: number;
  74496. private _scene;
  74497. /**
  74498. * Creates a new action manager
  74499. * @param scene defines the hosting scene
  74500. */
  74501. constructor(scene: Scene);
  74502. /**
  74503. * Releases all associated resources
  74504. */
  74505. dispose(): void;
  74506. /**
  74507. * Gets hosting scene
  74508. * @returns the hosting scene
  74509. */
  74510. getScene(): Scene;
  74511. /**
  74512. * Does this action manager handles actions of any of the given triggers
  74513. * @param triggers defines the triggers to be tested
  74514. * @return a boolean indicating whether one (or more) of the triggers is handled
  74515. */
  74516. hasSpecificTriggers(triggers: number[]): boolean;
  74517. /**
  74518. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74519. * speed.
  74520. * @param triggerA defines the trigger to be tested
  74521. * @param triggerB defines the trigger to be tested
  74522. * @return a boolean indicating whether one (or more) of the triggers is handled
  74523. */
  74524. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74525. /**
  74526. * Does this action manager handles actions of a given trigger
  74527. * @param trigger defines the trigger to be tested
  74528. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74529. * @return whether the trigger is handled
  74530. */
  74531. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74532. /**
  74533. * Does this action manager has pointer triggers
  74534. */
  74535. readonly hasPointerTriggers: boolean;
  74536. /**
  74537. * Does this action manager has pick triggers
  74538. */
  74539. readonly hasPickTriggers: boolean;
  74540. /**
  74541. * Registers an action to this action manager
  74542. * @param action defines the action to be registered
  74543. * @return the action amended (prepared) after registration
  74544. */
  74545. registerAction(action: IAction): Nullable<IAction>;
  74546. /**
  74547. * Unregisters an action to this action manager
  74548. * @param action defines the action to be unregistered
  74549. * @return a boolean indicating whether the action has been unregistered
  74550. */
  74551. unregisterAction(action: IAction): Boolean;
  74552. /**
  74553. * Process a specific trigger
  74554. * @param trigger defines the trigger to process
  74555. * @param evt defines the event details to be processed
  74556. */
  74557. processTrigger(trigger: number, evt?: IActionEvent): void;
  74558. /** @hidden */
  74559. _getEffectiveTarget(target: any, propertyPath: string): any;
  74560. /** @hidden */
  74561. _getProperty(propertyPath: string): string;
  74562. /**
  74563. * Serialize this manager to a JSON object
  74564. * @param name defines the property name to store this manager
  74565. * @returns a JSON representation of this manager
  74566. */
  74567. serialize(name: string): any;
  74568. /**
  74569. * Creates a new ActionManager from a JSON data
  74570. * @param parsedActions defines the JSON data to read from
  74571. * @param object defines the hosting mesh
  74572. * @param scene defines the hosting scene
  74573. */
  74574. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74575. /**
  74576. * Get a trigger name by index
  74577. * @param trigger defines the trigger index
  74578. * @returns a trigger name
  74579. */
  74580. static GetTriggerName(trigger: number): string;
  74581. }
  74582. }
  74583. declare module BABYLON {
  74584. /**
  74585. * Class representing a ray with position and direction
  74586. */
  74587. export class Ray {
  74588. /** origin point */
  74589. origin: Vector3;
  74590. /** direction */
  74591. direction: Vector3;
  74592. /** length of the ray */
  74593. length: number;
  74594. private static readonly TmpVector3;
  74595. private _tmpRay;
  74596. /**
  74597. * Creates a new ray
  74598. * @param origin origin point
  74599. * @param direction direction
  74600. * @param length length of the ray
  74601. */
  74602. constructor(
  74603. /** origin point */
  74604. origin: Vector3,
  74605. /** direction */
  74606. direction: Vector3,
  74607. /** length of the ray */
  74608. length?: number);
  74609. /**
  74610. * Checks if the ray intersects a box
  74611. * @param minimum bound of the box
  74612. * @param maximum bound of the box
  74613. * @param intersectionTreshold extra extend to be added to the box in all direction
  74614. * @returns if the box was hit
  74615. */
  74616. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74617. /**
  74618. * Checks if the ray intersects a box
  74619. * @param box the bounding box to check
  74620. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74621. * @returns if the box was hit
  74622. */
  74623. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74624. /**
  74625. * If the ray hits a sphere
  74626. * @param sphere the bounding sphere to check
  74627. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74628. * @returns true if it hits the sphere
  74629. */
  74630. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74631. /**
  74632. * If the ray hits a triange
  74633. * @param vertex0 triangle vertex
  74634. * @param vertex1 triangle vertex
  74635. * @param vertex2 triangle vertex
  74636. * @returns intersection information if hit
  74637. */
  74638. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74639. /**
  74640. * Checks if ray intersects a plane
  74641. * @param plane the plane to check
  74642. * @returns the distance away it was hit
  74643. */
  74644. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74645. /**
  74646. * Calculate the intercept of a ray on a given axis
  74647. * @param axis to check 'x' | 'y' | 'z'
  74648. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74649. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74650. */
  74651. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74652. /**
  74653. * Checks if ray intersects a mesh
  74654. * @param mesh the mesh to check
  74655. * @param fastCheck if only the bounding box should checked
  74656. * @returns picking info of the intersecton
  74657. */
  74658. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74659. /**
  74660. * Checks if ray intersects a mesh
  74661. * @param meshes the meshes to check
  74662. * @param fastCheck if only the bounding box should checked
  74663. * @param results array to store result in
  74664. * @returns Array of picking infos
  74665. */
  74666. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74667. private _comparePickingInfo;
  74668. private static smallnum;
  74669. private static rayl;
  74670. /**
  74671. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74672. * @param sega the first point of the segment to test the intersection against
  74673. * @param segb the second point of the segment to test the intersection against
  74674. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74675. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74676. */
  74677. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74678. /**
  74679. * Update the ray from viewport position
  74680. * @param x position
  74681. * @param y y position
  74682. * @param viewportWidth viewport width
  74683. * @param viewportHeight viewport height
  74684. * @param world world matrix
  74685. * @param view view matrix
  74686. * @param projection projection matrix
  74687. * @returns this ray updated
  74688. */
  74689. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74690. /**
  74691. * Creates a ray with origin and direction of 0,0,0
  74692. * @returns the new ray
  74693. */
  74694. static Zero(): Ray;
  74695. /**
  74696. * Creates a new ray from screen space and viewport
  74697. * @param x position
  74698. * @param y y position
  74699. * @param viewportWidth viewport width
  74700. * @param viewportHeight viewport height
  74701. * @param world world matrix
  74702. * @param view view matrix
  74703. * @param projection projection matrix
  74704. * @returns new ray
  74705. */
  74706. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74707. /**
  74708. * 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
  74709. * transformed to the given world matrix.
  74710. * @param origin The origin point
  74711. * @param end The end point
  74712. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74713. * @returns the new ray
  74714. */
  74715. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74716. /**
  74717. * Transforms a ray by a matrix
  74718. * @param ray ray to transform
  74719. * @param matrix matrix to apply
  74720. * @returns the resulting new ray
  74721. */
  74722. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74723. /**
  74724. * Transforms a ray by a matrix
  74725. * @param ray ray to transform
  74726. * @param matrix matrix to apply
  74727. * @param result ray to store result in
  74728. */
  74729. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74730. /**
  74731. * Unproject a ray from screen space to object space
  74732. * @param sourceX defines the screen space x coordinate to use
  74733. * @param sourceY defines the screen space y coordinate to use
  74734. * @param viewportWidth defines the current width of the viewport
  74735. * @param viewportHeight defines the current height of the viewport
  74736. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74737. * @param view defines the view matrix to use
  74738. * @param projection defines the projection matrix to use
  74739. */
  74740. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74741. }
  74742. /**
  74743. * Type used to define predicate used to select faces when a mesh intersection is detected
  74744. */
  74745. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74746. interface Scene {
  74747. /** @hidden */
  74748. _tempPickingRay: Nullable<Ray>;
  74749. /** @hidden */
  74750. _cachedRayForTransform: Ray;
  74751. /** @hidden */
  74752. _pickWithRayInverseMatrix: Matrix;
  74753. /** @hidden */
  74754. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74755. /** @hidden */
  74756. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74757. }
  74758. }
  74759. declare module BABYLON {
  74760. /**
  74761. * Groups all the scene component constants in one place to ease maintenance.
  74762. * @hidden
  74763. */
  74764. export class SceneComponentConstants {
  74765. static readonly NAME_EFFECTLAYER: string;
  74766. static readonly NAME_LAYER: string;
  74767. static readonly NAME_LENSFLARESYSTEM: string;
  74768. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74769. static readonly NAME_PARTICLESYSTEM: string;
  74770. static readonly NAME_GAMEPAD: string;
  74771. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74772. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74773. static readonly NAME_DEPTHRENDERER: string;
  74774. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74775. static readonly NAME_SPRITE: string;
  74776. static readonly NAME_OUTLINERENDERER: string;
  74777. static readonly NAME_PROCEDURALTEXTURE: string;
  74778. static readonly NAME_SHADOWGENERATOR: string;
  74779. static readonly NAME_OCTREE: string;
  74780. static readonly NAME_PHYSICSENGINE: string;
  74781. static readonly NAME_AUDIO: string;
  74782. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74783. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74784. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74785. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74786. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74787. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74788. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74789. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74790. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74791. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74792. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74793. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74794. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74795. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74796. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74797. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74798. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74799. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74800. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74801. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74802. static readonly STEP_AFTERRENDER_AUDIO: number;
  74803. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74804. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74805. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74806. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74807. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74808. static readonly STEP_POINTERMOVE_SPRITE: number;
  74809. static readonly STEP_POINTERDOWN_SPRITE: number;
  74810. static readonly STEP_POINTERUP_SPRITE: number;
  74811. }
  74812. /**
  74813. * This represents a scene component.
  74814. *
  74815. * This is used to decouple the dependency the scene is having on the different workloads like
  74816. * layers, post processes...
  74817. */
  74818. export interface ISceneComponent {
  74819. /**
  74820. * The name of the component. Each component must have a unique name.
  74821. */
  74822. name: string;
  74823. /**
  74824. * The scene the component belongs to.
  74825. */
  74826. scene: Scene;
  74827. /**
  74828. * Register the component to one instance of a scene.
  74829. */
  74830. register(): void;
  74831. /**
  74832. * Rebuilds the elements related to this component in case of
  74833. * context lost for instance.
  74834. */
  74835. rebuild(): void;
  74836. /**
  74837. * Disposes the component and the associated ressources.
  74838. */
  74839. dispose(): void;
  74840. }
  74841. /**
  74842. * This represents a SERIALIZABLE scene component.
  74843. *
  74844. * This extends Scene Component to add Serialization methods on top.
  74845. */
  74846. export interface ISceneSerializableComponent extends ISceneComponent {
  74847. /**
  74848. * Adds all the elements from the container to the scene
  74849. * @param container the container holding the elements
  74850. */
  74851. addFromContainer(container: AbstractScene): void;
  74852. /**
  74853. * Removes all the elements in the container from the scene
  74854. * @param container contains the elements to remove
  74855. * @param dispose if the removed element should be disposed (default: false)
  74856. */
  74857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74858. /**
  74859. * Serializes the component data to the specified json object
  74860. * @param serializationObject The object to serialize to
  74861. */
  74862. serialize(serializationObject: any): void;
  74863. }
  74864. /**
  74865. * Strong typing of a Mesh related stage step action
  74866. */
  74867. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74868. /**
  74869. * Strong typing of a Evaluate Sub Mesh related stage step action
  74870. */
  74871. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74872. /**
  74873. * Strong typing of a Active Mesh related stage step action
  74874. */
  74875. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74876. /**
  74877. * Strong typing of a Camera related stage step action
  74878. */
  74879. export type CameraStageAction = (camera: Camera) => void;
  74880. /**
  74881. * Strong typing of a Camera Frame buffer related stage step action
  74882. */
  74883. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74884. /**
  74885. * Strong typing of a Render Target related stage step action
  74886. */
  74887. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74888. /**
  74889. * Strong typing of a RenderingGroup related stage step action
  74890. */
  74891. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74892. /**
  74893. * Strong typing of a Mesh Render related stage step action
  74894. */
  74895. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74896. /**
  74897. * Strong typing of a simple stage step action
  74898. */
  74899. export type SimpleStageAction = () => void;
  74900. /**
  74901. * Strong typing of a render target action.
  74902. */
  74903. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74904. /**
  74905. * Strong typing of a pointer move action.
  74906. */
  74907. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74908. /**
  74909. * Strong typing of a pointer up/down action.
  74910. */
  74911. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74912. /**
  74913. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74914. * @hidden
  74915. */
  74916. export class Stage<T extends Function> extends Array<{
  74917. index: number;
  74918. component: ISceneComponent;
  74919. action: T;
  74920. }> {
  74921. /**
  74922. * Hide ctor from the rest of the world.
  74923. * @param items The items to add.
  74924. */
  74925. private constructor();
  74926. /**
  74927. * Creates a new Stage.
  74928. * @returns A new instance of a Stage
  74929. */
  74930. static Create<T extends Function>(): Stage<T>;
  74931. /**
  74932. * Registers a step in an ordered way in the targeted stage.
  74933. * @param index Defines the position to register the step in
  74934. * @param component Defines the component attached to the step
  74935. * @param action Defines the action to launch during the step
  74936. */
  74937. registerStep(index: number, component: ISceneComponent, action: T): void;
  74938. /**
  74939. * Clears all the steps from the stage.
  74940. */
  74941. clear(): void;
  74942. }
  74943. }
  74944. declare module BABYLON {
  74945. interface Scene {
  74946. /** @hidden */
  74947. _pointerOverSprite: Nullable<Sprite>;
  74948. /** @hidden */
  74949. _pickedDownSprite: Nullable<Sprite>;
  74950. /** @hidden */
  74951. _tempSpritePickingRay: Nullable<Ray>;
  74952. /**
  74953. * All of the sprite managers added to this scene
  74954. * @see http://doc.babylonjs.com/babylon101/sprites
  74955. */
  74956. spriteManagers: Array<ISpriteManager>;
  74957. /**
  74958. * An event triggered when sprites rendering is about to start
  74959. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74960. */
  74961. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74962. /**
  74963. * An event triggered when sprites rendering is done
  74964. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74965. */
  74966. onAfterSpritesRenderingObservable: Observable<Scene>;
  74967. /** @hidden */
  74968. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74969. /** Launch a ray to try to pick a sprite in the scene
  74970. * @param x position on screen
  74971. * @param y position on screen
  74972. * @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
  74973. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74974. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74975. * @returns a PickingInfo
  74976. */
  74977. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74978. /** Use the given ray to pick a sprite in the scene
  74979. * @param ray The ray (in world space) to use to pick meshes
  74980. * @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
  74981. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74982. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74983. * @returns a PickingInfo
  74984. */
  74985. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74986. /**
  74987. * Force the sprite under the pointer
  74988. * @param sprite defines the sprite to use
  74989. */
  74990. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74991. /**
  74992. * Gets the sprite under the pointer
  74993. * @returns a Sprite or null if no sprite is under the pointer
  74994. */
  74995. getPointerOverSprite(): Nullable<Sprite>;
  74996. }
  74997. /**
  74998. * Defines the sprite scene component responsible to manage sprites
  74999. * in a given scene.
  75000. */
  75001. export class SpriteSceneComponent implements ISceneComponent {
  75002. /**
  75003. * The component name helpfull to identify the component in the list of scene components.
  75004. */
  75005. readonly name: string;
  75006. /**
  75007. * The scene the component belongs to.
  75008. */
  75009. scene: Scene;
  75010. /** @hidden */
  75011. private _spritePredicate;
  75012. /**
  75013. * Creates a new instance of the component for the given scene
  75014. * @param scene Defines the scene to register the component in
  75015. */
  75016. constructor(scene: Scene);
  75017. /**
  75018. * Registers the component in a given scene
  75019. */
  75020. register(): void;
  75021. /**
  75022. * Rebuilds the elements related to this component in case of
  75023. * context lost for instance.
  75024. */
  75025. rebuild(): void;
  75026. /**
  75027. * Disposes the component and the associated ressources.
  75028. */
  75029. dispose(): void;
  75030. private _pickSpriteButKeepRay;
  75031. private _pointerMove;
  75032. private _pointerDown;
  75033. private _pointerUp;
  75034. }
  75035. }
  75036. declare module BABYLON {
  75037. /** @hidden */
  75038. export var fogFragmentDeclaration: {
  75039. name: string;
  75040. shader: string;
  75041. };
  75042. }
  75043. declare module BABYLON {
  75044. /** @hidden */
  75045. export var fogFragment: {
  75046. name: string;
  75047. shader: string;
  75048. };
  75049. }
  75050. declare module BABYLON {
  75051. /** @hidden */
  75052. export var spritesPixelShader: {
  75053. name: string;
  75054. shader: string;
  75055. };
  75056. }
  75057. declare module BABYLON {
  75058. /** @hidden */
  75059. export var fogVertexDeclaration: {
  75060. name: string;
  75061. shader: string;
  75062. };
  75063. }
  75064. declare module BABYLON {
  75065. /** @hidden */
  75066. export var spritesVertexShader: {
  75067. name: string;
  75068. shader: string;
  75069. };
  75070. }
  75071. declare module BABYLON {
  75072. /**
  75073. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75074. */
  75075. export interface ISpriteManager extends IDisposable {
  75076. /**
  75077. * Restricts the camera to viewing objects with the same layerMask.
  75078. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75079. */
  75080. layerMask: number;
  75081. /**
  75082. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75083. */
  75084. isPickable: boolean;
  75085. /**
  75086. * Specifies the rendering group id for this mesh (0 by default)
  75087. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75088. */
  75089. renderingGroupId: number;
  75090. /**
  75091. * Defines the list of sprites managed by the manager.
  75092. */
  75093. sprites: Array<Sprite>;
  75094. /**
  75095. * Tests the intersection of a sprite with a specific ray.
  75096. * @param ray The ray we are sending to test the collision
  75097. * @param camera The camera space we are sending rays in
  75098. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75099. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75100. * @returns picking info or null.
  75101. */
  75102. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75103. /**
  75104. * Renders the list of sprites on screen.
  75105. */
  75106. render(): void;
  75107. }
  75108. /**
  75109. * Class used to manage multiple sprites on the same spritesheet
  75110. * @see http://doc.babylonjs.com/babylon101/sprites
  75111. */
  75112. export class SpriteManager implements ISpriteManager {
  75113. /** defines the manager's name */
  75114. name: string;
  75115. /** Gets the list of sprites */
  75116. sprites: Sprite[];
  75117. /** Gets or sets the rendering group id (0 by default) */
  75118. renderingGroupId: number;
  75119. /** Gets or sets camera layer mask */
  75120. layerMask: number;
  75121. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75122. fogEnabled: boolean;
  75123. /** Gets or sets a boolean indicating if the sprites are pickable */
  75124. isPickable: boolean;
  75125. /** Defines the default width of a cell in the spritesheet */
  75126. cellWidth: number;
  75127. /** Defines the default height of a cell in the spritesheet */
  75128. cellHeight: number;
  75129. /**
  75130. * An event triggered when the manager is disposed.
  75131. */
  75132. onDisposeObservable: Observable<SpriteManager>;
  75133. private _onDisposeObserver;
  75134. /**
  75135. * Callback called when the manager is disposed
  75136. */
  75137. onDispose: () => void;
  75138. private _capacity;
  75139. private _spriteTexture;
  75140. private _epsilon;
  75141. private _scene;
  75142. private _vertexData;
  75143. private _buffer;
  75144. private _vertexBuffers;
  75145. private _indexBuffer;
  75146. private _effectBase;
  75147. private _effectFog;
  75148. /**
  75149. * Gets or sets the spritesheet texture
  75150. */
  75151. texture: Texture;
  75152. /**
  75153. * Creates a new sprite manager
  75154. * @param name defines the manager's name
  75155. * @param imgUrl defines the sprite sheet url
  75156. * @param capacity defines the maximum allowed number of sprites
  75157. * @param cellSize defines the size of a sprite cell
  75158. * @param scene defines the hosting scene
  75159. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75160. * @param samplingMode defines the smapling mode to use with spritesheet
  75161. */
  75162. constructor(
  75163. /** defines the manager's name */
  75164. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75165. private _appendSpriteVertex;
  75166. /**
  75167. * Intersects the sprites with a ray
  75168. * @param ray defines the ray to intersect with
  75169. * @param camera defines the current active camera
  75170. * @param predicate defines a predicate used to select candidate sprites
  75171. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75172. * @returns null if no hit or a PickingInfo
  75173. */
  75174. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75175. /**
  75176. * Render all child sprites
  75177. */
  75178. render(): void;
  75179. /**
  75180. * Release associated resources
  75181. */
  75182. dispose(): void;
  75183. }
  75184. }
  75185. declare module BABYLON {
  75186. /**
  75187. * Class used to represent a sprite
  75188. * @see http://doc.babylonjs.com/babylon101/sprites
  75189. */
  75190. export class Sprite {
  75191. /** defines the name */
  75192. name: string;
  75193. /** Gets or sets the current world position */
  75194. position: Vector3;
  75195. /** Gets or sets the main color */
  75196. color: Color4;
  75197. /** Gets or sets the width */
  75198. width: number;
  75199. /** Gets or sets the height */
  75200. height: number;
  75201. /** Gets or sets rotation angle */
  75202. angle: number;
  75203. /** Gets or sets the cell index in the sprite sheet */
  75204. cellIndex: number;
  75205. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75206. invertU: number;
  75207. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75208. invertV: number;
  75209. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75210. disposeWhenFinishedAnimating: boolean;
  75211. /** Gets the list of attached animations */
  75212. animations: Animation[];
  75213. /** Gets or sets a boolean indicating if the sprite can be picked */
  75214. isPickable: boolean;
  75215. /**
  75216. * Gets or sets the associated action manager
  75217. */
  75218. actionManager: Nullable<ActionManager>;
  75219. private _animationStarted;
  75220. private _loopAnimation;
  75221. private _fromIndex;
  75222. private _toIndex;
  75223. private _delay;
  75224. private _direction;
  75225. private _manager;
  75226. private _time;
  75227. private _onAnimationEnd;
  75228. /**
  75229. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75230. */
  75231. isVisible: boolean;
  75232. /**
  75233. * Gets or sets the sprite size
  75234. */
  75235. size: number;
  75236. /**
  75237. * Creates a new Sprite
  75238. * @param name defines the name
  75239. * @param manager defines the manager
  75240. */
  75241. constructor(
  75242. /** defines the name */
  75243. name: string, manager: ISpriteManager);
  75244. /**
  75245. * Starts an animation
  75246. * @param from defines the initial key
  75247. * @param to defines the end key
  75248. * @param loop defines if the animation must loop
  75249. * @param delay defines the start delay (in ms)
  75250. * @param onAnimationEnd defines a callback to call when animation ends
  75251. */
  75252. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75253. /** Stops current animation (if any) */
  75254. stopAnimation(): void;
  75255. /** @hidden */
  75256. _animate(deltaTime: number): void;
  75257. /** Release associated resources */
  75258. dispose(): void;
  75259. }
  75260. }
  75261. declare module BABYLON {
  75262. /**
  75263. * Information about the result of picking within a scene
  75264. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75265. */
  75266. export class PickingInfo {
  75267. /** @hidden */
  75268. _pickingUnavailable: boolean;
  75269. /**
  75270. * If the pick collided with an object
  75271. */
  75272. hit: boolean;
  75273. /**
  75274. * Distance away where the pick collided
  75275. */
  75276. distance: number;
  75277. /**
  75278. * The location of pick collision
  75279. */
  75280. pickedPoint: Nullable<Vector3>;
  75281. /**
  75282. * The mesh corresponding the the pick collision
  75283. */
  75284. pickedMesh: Nullable<AbstractMesh>;
  75285. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75286. bu: number;
  75287. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75288. bv: number;
  75289. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75290. faceId: number;
  75291. /** Id of the the submesh that was picked */
  75292. subMeshId: number;
  75293. /** If a sprite was picked, this will be the sprite the pick collided with */
  75294. pickedSprite: Nullable<Sprite>;
  75295. /**
  75296. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75297. */
  75298. originMesh: Nullable<AbstractMesh>;
  75299. /**
  75300. * The ray that was used to perform the picking.
  75301. */
  75302. ray: Nullable<Ray>;
  75303. /**
  75304. * Gets the normal correspodning to the face the pick collided with
  75305. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75306. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75307. * @returns The normal correspodning to the face the pick collided with
  75308. */
  75309. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75310. /**
  75311. * Gets the texture coordinates of where the pick occured
  75312. * @returns the vector containing the coordnates of the texture
  75313. */
  75314. getTextureCoordinates(): Nullable<Vector2>;
  75315. }
  75316. }
  75317. declare module BABYLON {
  75318. /**
  75319. * Gather the list of pointer event types as constants.
  75320. */
  75321. export class PointerEventTypes {
  75322. /**
  75323. * 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.
  75324. */
  75325. static readonly POINTERDOWN: number;
  75326. /**
  75327. * The pointerup event is fired when a pointer is no longer active.
  75328. */
  75329. static readonly POINTERUP: number;
  75330. /**
  75331. * The pointermove event is fired when a pointer changes coordinates.
  75332. */
  75333. static readonly POINTERMOVE: number;
  75334. /**
  75335. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75336. */
  75337. static readonly POINTERWHEEL: number;
  75338. /**
  75339. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75340. */
  75341. static readonly POINTERPICK: number;
  75342. /**
  75343. * The pointertap event is fired when a the object has been touched and released without drag.
  75344. */
  75345. static readonly POINTERTAP: number;
  75346. /**
  75347. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75348. */
  75349. static readonly POINTERDOUBLETAP: number;
  75350. }
  75351. /**
  75352. * Base class of pointer info types.
  75353. */
  75354. export class PointerInfoBase {
  75355. /**
  75356. * Defines the type of event (PointerEventTypes)
  75357. */
  75358. type: number;
  75359. /**
  75360. * Defines the related dom event
  75361. */
  75362. event: PointerEvent | MouseWheelEvent;
  75363. /**
  75364. * Instantiates the base class of pointers info.
  75365. * @param type Defines the type of event (PointerEventTypes)
  75366. * @param event Defines the related dom event
  75367. */
  75368. constructor(
  75369. /**
  75370. * Defines the type of event (PointerEventTypes)
  75371. */
  75372. type: number,
  75373. /**
  75374. * Defines the related dom event
  75375. */
  75376. event: PointerEvent | MouseWheelEvent);
  75377. }
  75378. /**
  75379. * This class is used to store pointer related info for the onPrePointerObservable event.
  75380. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75381. */
  75382. export class PointerInfoPre extends PointerInfoBase {
  75383. /**
  75384. * Ray from a pointer if availible (eg. 6dof controller)
  75385. */
  75386. ray: Nullable<Ray>;
  75387. /**
  75388. * Defines the local position of the pointer on the canvas.
  75389. */
  75390. localPosition: Vector2;
  75391. /**
  75392. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75393. */
  75394. skipOnPointerObservable: boolean;
  75395. /**
  75396. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75397. * @param type Defines the type of event (PointerEventTypes)
  75398. * @param event Defines the related dom event
  75399. * @param localX Defines the local x coordinates of the pointer when the event occured
  75400. * @param localY Defines the local y coordinates of the pointer when the event occured
  75401. */
  75402. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75403. }
  75404. /**
  75405. * This type contains all the data related to a pointer event in Babylon.js.
  75406. * 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.
  75407. */
  75408. export class PointerInfo extends PointerInfoBase {
  75409. /**
  75410. * Defines the picking info associated to the info (if any)\
  75411. */
  75412. pickInfo: Nullable<PickingInfo>;
  75413. /**
  75414. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75415. * @param type Defines the type of event (PointerEventTypes)
  75416. * @param event Defines the related dom event
  75417. * @param pickInfo Defines the picking info associated to the info (if any)\
  75418. */
  75419. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75420. /**
  75421. * Defines the picking info associated to the info (if any)\
  75422. */
  75423. pickInfo: Nullable<PickingInfo>);
  75424. }
  75425. /**
  75426. * Data relating to a touch event on the screen.
  75427. */
  75428. export interface PointerTouch {
  75429. /**
  75430. * X coordinate of touch.
  75431. */
  75432. x: number;
  75433. /**
  75434. * Y coordinate of touch.
  75435. */
  75436. y: number;
  75437. /**
  75438. * Id of touch. Unique for each finger.
  75439. */
  75440. pointerId: number;
  75441. /**
  75442. * Event type passed from DOM.
  75443. */
  75444. type: any;
  75445. }
  75446. }
  75447. declare module BABYLON {
  75448. /**
  75449. * Manage the mouse inputs to control the movement of a free camera.
  75450. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75451. */
  75452. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75453. /**
  75454. * Define if touch is enabled in the mouse input
  75455. */
  75456. touchEnabled: boolean;
  75457. /**
  75458. * Defines the camera the input is attached to.
  75459. */
  75460. camera: FreeCamera;
  75461. /**
  75462. * Defines the buttons associated with the input to handle camera move.
  75463. */
  75464. buttons: number[];
  75465. /**
  75466. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75467. */
  75468. angularSensibility: number;
  75469. private _pointerInput;
  75470. private _onMouseMove;
  75471. private _observer;
  75472. private previousPosition;
  75473. /**
  75474. * Observable for when a pointer move event occurs containing the move offset
  75475. */
  75476. onPointerMovedObservable: Observable<{
  75477. offsetX: number;
  75478. offsetY: number;
  75479. }>;
  75480. /**
  75481. * @hidden
  75482. * If the camera should be rotated automatically based on pointer movement
  75483. */
  75484. _allowCameraRotation: boolean;
  75485. /**
  75486. * Manage the mouse inputs to control the movement of a free camera.
  75487. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75488. * @param touchEnabled Defines if touch is enabled or not
  75489. */
  75490. constructor(
  75491. /**
  75492. * Define if touch is enabled in the mouse input
  75493. */
  75494. touchEnabled?: boolean);
  75495. /**
  75496. * Attach the input controls to a specific dom element to get the input from.
  75497. * @param element Defines the element the controls should be listened from
  75498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75499. */
  75500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75501. /**
  75502. * Called on JS contextmenu event.
  75503. * Override this method to provide functionality.
  75504. */
  75505. protected onContextMenu(evt: PointerEvent): void;
  75506. /**
  75507. * Detach the current controls from the specified dom element.
  75508. * @param element Defines the element to stop listening the inputs from
  75509. */
  75510. detachControl(element: Nullable<HTMLElement>): void;
  75511. /**
  75512. * Gets the class name of the current intput.
  75513. * @returns the class name
  75514. */
  75515. getClassName(): string;
  75516. /**
  75517. * Get the friendly name associated with the input class.
  75518. * @returns the input friendly name
  75519. */
  75520. getSimpleName(): string;
  75521. }
  75522. }
  75523. declare module BABYLON {
  75524. /**
  75525. * Manage the touch inputs to control the movement of a free camera.
  75526. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75527. */
  75528. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75529. /**
  75530. * Defines the camera the input is attached to.
  75531. */
  75532. camera: FreeCamera;
  75533. /**
  75534. * Defines the touch sensibility for rotation.
  75535. * The higher the faster.
  75536. */
  75537. touchAngularSensibility: number;
  75538. /**
  75539. * Defines the touch sensibility for move.
  75540. * The higher the faster.
  75541. */
  75542. touchMoveSensibility: number;
  75543. private _offsetX;
  75544. private _offsetY;
  75545. private _pointerPressed;
  75546. private _pointerInput;
  75547. private _observer;
  75548. private _onLostFocus;
  75549. /**
  75550. * Attach the input controls to a specific dom element to get the input from.
  75551. * @param element Defines the element the controls should be listened from
  75552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75553. */
  75554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75555. /**
  75556. * Detach the current controls from the specified dom element.
  75557. * @param element Defines the element to stop listening the inputs from
  75558. */
  75559. detachControl(element: Nullable<HTMLElement>): void;
  75560. /**
  75561. * Update the current camera state depending on the inputs that have been used this frame.
  75562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75563. */
  75564. checkInputs(): void;
  75565. /**
  75566. * Gets the class name of the current intput.
  75567. * @returns the class name
  75568. */
  75569. getClassName(): string;
  75570. /**
  75571. * Get the friendly name associated with the input class.
  75572. * @returns the input friendly name
  75573. */
  75574. getSimpleName(): string;
  75575. }
  75576. }
  75577. declare module BABYLON {
  75578. /**
  75579. * Default Inputs manager for the FreeCamera.
  75580. * It groups all the default supported inputs for ease of use.
  75581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75582. */
  75583. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75584. /**
  75585. * @hidden
  75586. */
  75587. _mouseInput: Nullable<FreeCameraMouseInput>;
  75588. /**
  75589. * Instantiates a new FreeCameraInputsManager.
  75590. * @param camera Defines the camera the inputs belong to
  75591. */
  75592. constructor(camera: FreeCamera);
  75593. /**
  75594. * Add keyboard input support to the input manager.
  75595. * @returns the current input manager
  75596. */
  75597. addKeyboard(): FreeCameraInputsManager;
  75598. /**
  75599. * Add mouse input support to the input manager.
  75600. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75601. * @returns the current input manager
  75602. */
  75603. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75604. /**
  75605. * Removes the mouse input support from the manager
  75606. * @returns the current input manager
  75607. */
  75608. removeMouse(): FreeCameraInputsManager;
  75609. /**
  75610. * Add touch input support to the input manager.
  75611. * @returns the current input manager
  75612. */
  75613. addTouch(): FreeCameraInputsManager;
  75614. /**
  75615. * Remove all attached input methods from a camera
  75616. */
  75617. clear(): void;
  75618. }
  75619. }
  75620. declare module BABYLON {
  75621. /**
  75622. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75623. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75624. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75625. */
  75626. export class FreeCamera extends TargetCamera {
  75627. /**
  75628. * Define the collision ellipsoid of the camera.
  75629. * This is helpful to simulate a camera body like the player body around the camera
  75630. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75631. */
  75632. ellipsoid: Vector3;
  75633. /**
  75634. * Define an offset for the position of the ellipsoid around the camera.
  75635. * This can be helpful to determine the center of the body near the gravity center of the body
  75636. * instead of its head.
  75637. */
  75638. ellipsoidOffset: Vector3;
  75639. /**
  75640. * Enable or disable collisions of the camera with the rest of the scene objects.
  75641. */
  75642. checkCollisions: boolean;
  75643. /**
  75644. * Enable or disable gravity on the camera.
  75645. */
  75646. applyGravity: boolean;
  75647. /**
  75648. * Define the input manager associated to the camera.
  75649. */
  75650. inputs: FreeCameraInputsManager;
  75651. /**
  75652. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75653. * Higher values reduce sensitivity.
  75654. */
  75655. /**
  75656. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75657. * Higher values reduce sensitivity.
  75658. */
  75659. angularSensibility: number;
  75660. /**
  75661. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75662. */
  75663. keysUp: number[];
  75664. /**
  75665. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75666. */
  75667. keysDown: number[];
  75668. /**
  75669. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75670. */
  75671. keysLeft: number[];
  75672. /**
  75673. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75674. */
  75675. keysRight: number[];
  75676. /**
  75677. * Event raised when the camera collide with a mesh in the scene.
  75678. */
  75679. onCollide: (collidedMesh: AbstractMesh) => void;
  75680. private _collider;
  75681. private _needMoveForGravity;
  75682. private _oldPosition;
  75683. private _diffPosition;
  75684. private _newPosition;
  75685. /** @hidden */
  75686. _localDirection: Vector3;
  75687. /** @hidden */
  75688. _transformedDirection: Vector3;
  75689. /**
  75690. * Instantiates a Free Camera.
  75691. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75692. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75693. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75694. * @param name Define the name of the camera in the scene
  75695. * @param position Define the start position of the camera in the scene
  75696. * @param scene Define the scene the camera belongs to
  75697. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75698. */
  75699. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75700. /**
  75701. * Attached controls to the current camera.
  75702. * @param element Defines the element the controls should be listened from
  75703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75704. */
  75705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75706. /**
  75707. * Detach the current controls from the camera.
  75708. * The camera will stop reacting to inputs.
  75709. * @param element Defines the element to stop listening the inputs from
  75710. */
  75711. detachControl(element: HTMLElement): void;
  75712. private _collisionMask;
  75713. /**
  75714. * Define a collision mask to limit the list of object the camera can collide with
  75715. */
  75716. collisionMask: number;
  75717. /** @hidden */
  75718. _collideWithWorld(displacement: Vector3): void;
  75719. private _onCollisionPositionChange;
  75720. /** @hidden */
  75721. _checkInputs(): void;
  75722. /** @hidden */
  75723. _decideIfNeedsToMove(): boolean;
  75724. /** @hidden */
  75725. _updatePosition(): void;
  75726. /**
  75727. * Destroy the camera and release the current resources hold by it.
  75728. */
  75729. dispose(): void;
  75730. /**
  75731. * Gets the current object class name.
  75732. * @return the class name
  75733. */
  75734. getClassName(): string;
  75735. }
  75736. }
  75737. declare module BABYLON {
  75738. /**
  75739. * Represents a gamepad control stick position
  75740. */
  75741. export class StickValues {
  75742. /**
  75743. * The x component of the control stick
  75744. */
  75745. x: number;
  75746. /**
  75747. * The y component of the control stick
  75748. */
  75749. y: number;
  75750. /**
  75751. * Initializes the gamepad x and y control stick values
  75752. * @param x The x component of the gamepad control stick value
  75753. * @param y The y component of the gamepad control stick value
  75754. */
  75755. constructor(
  75756. /**
  75757. * The x component of the control stick
  75758. */
  75759. x: number,
  75760. /**
  75761. * The y component of the control stick
  75762. */
  75763. y: number);
  75764. }
  75765. /**
  75766. * An interface which manages callbacks for gamepad button changes
  75767. */
  75768. export interface GamepadButtonChanges {
  75769. /**
  75770. * Called when a gamepad has been changed
  75771. */
  75772. changed: boolean;
  75773. /**
  75774. * Called when a gamepad press event has been triggered
  75775. */
  75776. pressChanged: boolean;
  75777. /**
  75778. * Called when a touch event has been triggered
  75779. */
  75780. touchChanged: boolean;
  75781. /**
  75782. * Called when a value has changed
  75783. */
  75784. valueChanged: boolean;
  75785. }
  75786. /**
  75787. * Represents a gamepad
  75788. */
  75789. export class Gamepad {
  75790. /**
  75791. * The id of the gamepad
  75792. */
  75793. id: string;
  75794. /**
  75795. * The index of the gamepad
  75796. */
  75797. index: number;
  75798. /**
  75799. * The browser gamepad
  75800. */
  75801. browserGamepad: any;
  75802. /**
  75803. * Specifies what type of gamepad this represents
  75804. */
  75805. type: number;
  75806. private _leftStick;
  75807. private _rightStick;
  75808. /** @hidden */
  75809. _isConnected: boolean;
  75810. private _leftStickAxisX;
  75811. private _leftStickAxisY;
  75812. private _rightStickAxisX;
  75813. private _rightStickAxisY;
  75814. /**
  75815. * Triggered when the left control stick has been changed
  75816. */
  75817. private _onleftstickchanged;
  75818. /**
  75819. * Triggered when the right control stick has been changed
  75820. */
  75821. private _onrightstickchanged;
  75822. /**
  75823. * Represents a gamepad controller
  75824. */
  75825. static GAMEPAD: number;
  75826. /**
  75827. * Represents a generic controller
  75828. */
  75829. static GENERIC: number;
  75830. /**
  75831. * Represents an XBox controller
  75832. */
  75833. static XBOX: number;
  75834. /**
  75835. * Represents a pose-enabled controller
  75836. */
  75837. static POSE_ENABLED: number;
  75838. /**
  75839. * Specifies whether the left control stick should be Y-inverted
  75840. */
  75841. protected _invertLeftStickY: boolean;
  75842. /**
  75843. * Specifies if the gamepad has been connected
  75844. */
  75845. readonly isConnected: boolean;
  75846. /**
  75847. * Initializes the gamepad
  75848. * @param id The id of the gamepad
  75849. * @param index The index of the gamepad
  75850. * @param browserGamepad The browser gamepad
  75851. * @param leftStickX The x component of the left joystick
  75852. * @param leftStickY The y component of the left joystick
  75853. * @param rightStickX The x component of the right joystick
  75854. * @param rightStickY The y component of the right joystick
  75855. */
  75856. constructor(
  75857. /**
  75858. * The id of the gamepad
  75859. */
  75860. id: string,
  75861. /**
  75862. * The index of the gamepad
  75863. */
  75864. index: number,
  75865. /**
  75866. * The browser gamepad
  75867. */
  75868. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75869. /**
  75870. * Callback triggered when the left joystick has changed
  75871. * @param callback
  75872. */
  75873. onleftstickchanged(callback: (values: StickValues) => void): void;
  75874. /**
  75875. * Callback triggered when the right joystick has changed
  75876. * @param callback
  75877. */
  75878. onrightstickchanged(callback: (values: StickValues) => void): void;
  75879. /**
  75880. * Gets the left joystick
  75881. */
  75882. /**
  75883. * Sets the left joystick values
  75884. */
  75885. leftStick: StickValues;
  75886. /**
  75887. * Gets the right joystick
  75888. */
  75889. /**
  75890. * Sets the right joystick value
  75891. */
  75892. rightStick: StickValues;
  75893. /**
  75894. * Updates the gamepad joystick positions
  75895. */
  75896. update(): void;
  75897. /**
  75898. * Disposes the gamepad
  75899. */
  75900. dispose(): void;
  75901. }
  75902. /**
  75903. * Represents a generic gamepad
  75904. */
  75905. export class GenericPad extends Gamepad {
  75906. private _buttons;
  75907. private _onbuttondown;
  75908. private _onbuttonup;
  75909. /**
  75910. * Observable triggered when a button has been pressed
  75911. */
  75912. onButtonDownObservable: Observable<number>;
  75913. /**
  75914. * Observable triggered when a button has been released
  75915. */
  75916. onButtonUpObservable: Observable<number>;
  75917. /**
  75918. * Callback triggered when a button has been pressed
  75919. * @param callback Called when a button has been pressed
  75920. */
  75921. onbuttondown(callback: (buttonPressed: number) => void): void;
  75922. /**
  75923. * Callback triggered when a button has been released
  75924. * @param callback Called when a button has been released
  75925. */
  75926. onbuttonup(callback: (buttonReleased: number) => void): void;
  75927. /**
  75928. * Initializes the generic gamepad
  75929. * @param id The id of the generic gamepad
  75930. * @param index The index of the generic gamepad
  75931. * @param browserGamepad The browser gamepad
  75932. */
  75933. constructor(id: string, index: number, browserGamepad: any);
  75934. private _setButtonValue;
  75935. /**
  75936. * Updates the generic gamepad
  75937. */
  75938. update(): void;
  75939. /**
  75940. * Disposes the generic gamepad
  75941. */
  75942. dispose(): void;
  75943. }
  75944. }
  75945. declare module BABYLON {
  75946. interface Engine {
  75947. /**
  75948. * Creates a raw texture
  75949. * @param data defines the data to store in the texture
  75950. * @param width defines the width of the texture
  75951. * @param height defines the height of the texture
  75952. * @param format defines the format of the data
  75953. * @param generateMipMaps defines if the engine should generate the mip levels
  75954. * @param invertY defines if data must be stored with Y axis inverted
  75955. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75956. * @param compression defines the compression used (null by default)
  75957. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75958. * @returns the raw texture inside an InternalTexture
  75959. */
  75960. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  75961. /**
  75962. * Update a raw texture
  75963. * @param texture defines the texture to update
  75964. * @param data defines the data to store in the texture
  75965. * @param format defines the format of the data
  75966. * @param invertY defines if data must be stored with Y axis inverted
  75967. */
  75968. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75969. /**
  75970. * Update a raw texture
  75971. * @param texture defines the texture to update
  75972. * @param data defines the data to store in the texture
  75973. * @param format defines the format of the data
  75974. * @param invertY defines if data must be stored with Y axis inverted
  75975. * @param compression defines the compression used (null by default)
  75976. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75977. */
  75978. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  75979. /**
  75980. * Creates a new raw cube texture
  75981. * @param data defines the array of data to use to create each face
  75982. * @param size defines the size of the textures
  75983. * @param format defines the format of the data
  75984. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75985. * @param generateMipMaps defines if the engine should generate the mip levels
  75986. * @param invertY defines if data must be stored with Y axis inverted
  75987. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75988. * @param compression defines the compression used (null by default)
  75989. * @returns the cube texture as an InternalTexture
  75990. */
  75991. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  75992. /**
  75993. * Update a raw cube texture
  75994. * @param texture defines the texture to udpdate
  75995. * @param data defines the data to store
  75996. * @param format defines the data format
  75997. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75998. * @param invertY defines if data must be stored with Y axis inverted
  75999. */
  76000. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  76001. /**
  76002. * Update a raw cube texture
  76003. * @param texture defines the texture to udpdate
  76004. * @param data defines the data to store
  76005. * @param format defines the data format
  76006. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76007. * @param invertY defines if data must be stored with Y axis inverted
  76008. * @param compression defines the compression used (null by default)
  76009. */
  76010. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  76011. /**
  76012. * Update a raw cube texture
  76013. * @param texture defines the texture to udpdate
  76014. * @param data defines the data to store
  76015. * @param format defines the data format
  76016. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76017. * @param invertY defines if data must be stored with Y axis inverted
  76018. * @param compression defines the compression used (null by default)
  76019. * @param level defines which level of the texture to update
  76020. */
  76021. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76022. /**
  76023. * Creates a new raw cube texture from a specified url
  76024. * @param url defines the url where the data is located
  76025. * @param scene defines the current scene
  76026. * @param size defines the size of the textures
  76027. * @param format defines the format of the data
  76028. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76029. * @param noMipmap defines if the engine should avoid generating the mip levels
  76030. * @param callback defines a callback used to extract texture data from loaded data
  76031. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76032. * @param onLoad defines a callback called when texture is loaded
  76033. * @param onError defines a callback called if there is an error
  76034. * @returns the cube texture as an InternalTexture
  76035. */
  76036. 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;
  76037. /**
  76038. * Creates a new raw cube texture from a specified url
  76039. * @param url defines the url where the data is located
  76040. * @param scene defines the current scene
  76041. * @param size defines the size of the textures
  76042. * @param format defines the format of the data
  76043. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76044. * @param noMipmap defines if the engine should avoid generating the mip levels
  76045. * @param callback defines a callback used to extract texture data from loaded data
  76046. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76047. * @param onLoad defines a callback called when texture is loaded
  76048. * @param onError defines a callback called if there is an error
  76049. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76050. * @param invertY defines if data must be stored with Y axis inverted
  76051. * @returns the cube texture as an InternalTexture
  76052. */
  76053. 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;
  76054. /**
  76055. * Creates a new raw 3D texture
  76056. * @param data defines the data used to create the texture
  76057. * @param width defines the width of the texture
  76058. * @param height defines the height of the texture
  76059. * @param depth defines the depth of the texture
  76060. * @param format defines the format of the texture
  76061. * @param generateMipMaps defines if the engine must generate mip levels
  76062. * @param invertY defines if data must be stored with Y axis inverted
  76063. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76064. * @param compression defines the compressed used (can be null)
  76065. * @param textureType defines the compressed used (can be null)
  76066. * @returns a new raw 3D texture (stored in an InternalTexture)
  76067. */
  76068. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76069. /**
  76070. * Update a raw 3D texture
  76071. * @param texture defines the texture to update
  76072. * @param data defines the data to store
  76073. * @param format defines the data format
  76074. * @param invertY defines if data must be stored with Y axis inverted
  76075. */
  76076. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76077. /**
  76078. * Update a raw 3D texture
  76079. * @param texture defines the texture to update
  76080. * @param data defines the data to store
  76081. * @param format defines the data format
  76082. * @param invertY defines if data must be stored with Y axis inverted
  76083. * @param compression defines the used compression (can be null)
  76084. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76085. */
  76086. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76087. }
  76088. }
  76089. declare module BABYLON {
  76090. /**
  76091. * Raw texture can help creating a texture directly from an array of data.
  76092. * This can be super useful if you either get the data from an uncompressed source or
  76093. * if you wish to create your texture pixel by pixel.
  76094. */
  76095. export class RawTexture extends Texture {
  76096. /**
  76097. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76098. */
  76099. format: number;
  76100. private _engine;
  76101. /**
  76102. * Instantiates a new RawTexture.
  76103. * Raw texture can help creating a texture directly from an array of data.
  76104. * This can be super useful if you either get the data from an uncompressed source or
  76105. * if you wish to create your texture pixel by pixel.
  76106. * @param data define the array of data to use to create the texture
  76107. * @param width define the width of the texture
  76108. * @param height define the height of the texture
  76109. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76110. * @param scene define the scene the texture belongs to
  76111. * @param generateMipMaps define whether mip maps should be generated or not
  76112. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76113. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76114. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76115. */
  76116. constructor(data: ArrayBufferView, width: number, height: number,
  76117. /**
  76118. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76119. */
  76120. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76121. /**
  76122. * Updates the texture underlying data.
  76123. * @param data Define the new data of the texture
  76124. */
  76125. update(data: ArrayBufferView): void;
  76126. /**
  76127. * Creates a luminance texture from some data.
  76128. * @param data Define the texture data
  76129. * @param width Define the width of the texture
  76130. * @param height Define the height of the texture
  76131. * @param scene Define the scene the texture belongs to
  76132. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76133. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76134. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76135. * @returns the luminance texture
  76136. */
  76137. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76138. /**
  76139. * Creates a luminance alpha texture from some data.
  76140. * @param data Define the texture data
  76141. * @param width Define the width of the texture
  76142. * @param height Define the height of the texture
  76143. * @param scene Define the scene the texture belongs to
  76144. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76145. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76146. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76147. * @returns the luminance alpha texture
  76148. */
  76149. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76150. /**
  76151. * Creates an alpha texture from some data.
  76152. * @param data Define the texture data
  76153. * @param width Define the width of the texture
  76154. * @param height Define the height of the texture
  76155. * @param scene Define the scene the texture belongs to
  76156. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76157. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76158. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76159. * @returns the alpha texture
  76160. */
  76161. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76162. /**
  76163. * Creates a RGB texture from some data.
  76164. * @param data Define the texture data
  76165. * @param width Define the width of the texture
  76166. * @param height Define the height of the texture
  76167. * @param scene Define the scene the texture belongs to
  76168. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76169. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76170. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76171. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76172. * @returns the RGB alpha texture
  76173. */
  76174. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76175. /**
  76176. * Creates a RGBA texture from some data.
  76177. * @param data Define the texture data
  76178. * @param width Define the width of the texture
  76179. * @param height Define the height of the texture
  76180. * @param scene Define the scene the texture belongs to
  76181. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76182. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76183. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76184. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76185. * @returns the RGBA texture
  76186. */
  76187. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76188. /**
  76189. * Creates a R texture from some data.
  76190. * @param data Define the texture data
  76191. * @param width Define the width of the texture
  76192. * @param height Define the height of the texture
  76193. * @param scene Define the scene the texture belongs to
  76194. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76195. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76196. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76197. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76198. * @returns the R texture
  76199. */
  76200. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76201. }
  76202. }
  76203. declare module BABYLON {
  76204. /**
  76205. * Interface for the size containing width and height
  76206. */
  76207. export interface ISize {
  76208. /**
  76209. * Width
  76210. */
  76211. width: number;
  76212. /**
  76213. * Heighht
  76214. */
  76215. height: number;
  76216. }
  76217. /**
  76218. * Size containing widht and height
  76219. */
  76220. export class Size implements ISize {
  76221. /**
  76222. * Width
  76223. */
  76224. width: number;
  76225. /**
  76226. * Height
  76227. */
  76228. height: number;
  76229. /**
  76230. * Creates a Size object from the given width and height (floats).
  76231. * @param width width of the new size
  76232. * @param height height of the new size
  76233. */
  76234. constructor(width: number, height: number);
  76235. /**
  76236. * Returns a string with the Size width and height
  76237. * @returns a string with the Size width and height
  76238. */
  76239. toString(): string;
  76240. /**
  76241. * "Size"
  76242. * @returns the string "Size"
  76243. */
  76244. getClassName(): string;
  76245. /**
  76246. * Returns the Size hash code.
  76247. * @returns a hash code for a unique width and height
  76248. */
  76249. getHashCode(): number;
  76250. /**
  76251. * Updates the current size from the given one.
  76252. * @param src the given size
  76253. */
  76254. copyFrom(src: Size): void;
  76255. /**
  76256. * Updates in place the current Size from the given floats.
  76257. * @param width width of the new size
  76258. * @param height height of the new size
  76259. * @returns the updated Size.
  76260. */
  76261. copyFromFloats(width: number, height: number): Size;
  76262. /**
  76263. * Updates in place the current Size from the given floats.
  76264. * @param width width to set
  76265. * @param height height to set
  76266. * @returns the updated Size.
  76267. */
  76268. set(width: number, height: number): Size;
  76269. /**
  76270. * Multiplies the width and height by numbers
  76271. * @param w factor to multiple the width by
  76272. * @param h factor to multiple the height by
  76273. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76274. */
  76275. multiplyByFloats(w: number, h: number): Size;
  76276. /**
  76277. * Clones the size
  76278. * @returns a new Size copied from the given one.
  76279. */
  76280. clone(): Size;
  76281. /**
  76282. * True if the current Size and the given one width and height are strictly equal.
  76283. * @param other the other size to compare against
  76284. * @returns True if the current Size and the given one width and height are strictly equal.
  76285. */
  76286. equals(other: Size): boolean;
  76287. /**
  76288. * The surface of the Size : width * height (float).
  76289. */
  76290. readonly surface: number;
  76291. /**
  76292. * Create a new size of zero
  76293. * @returns a new Size set to (0.0, 0.0)
  76294. */
  76295. static Zero(): Size;
  76296. /**
  76297. * Sums the width and height of two sizes
  76298. * @param otherSize size to add to this size
  76299. * @returns a new Size set as the addition result of the current Size and the given one.
  76300. */
  76301. add(otherSize: Size): Size;
  76302. /**
  76303. * Subtracts the width and height of two
  76304. * @param otherSize size to subtract to this size
  76305. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76306. */
  76307. subtract(otherSize: Size): Size;
  76308. /**
  76309. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76310. * @param start starting size to lerp between
  76311. * @param end end size to lerp between
  76312. * @param amount amount to lerp between the start and end values
  76313. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76314. */
  76315. static Lerp(start: Size, end: Size, amount: number): Size;
  76316. }
  76317. }
  76318. declare module BABYLON {
  76319. /**
  76320. * Defines a runtime animation
  76321. */
  76322. export class RuntimeAnimation {
  76323. private _events;
  76324. /**
  76325. * The current frame of the runtime animation
  76326. */
  76327. private _currentFrame;
  76328. /**
  76329. * The animation used by the runtime animation
  76330. */
  76331. private _animation;
  76332. /**
  76333. * The target of the runtime animation
  76334. */
  76335. private _target;
  76336. /**
  76337. * The initiating animatable
  76338. */
  76339. private _host;
  76340. /**
  76341. * The original value of the runtime animation
  76342. */
  76343. private _originalValue;
  76344. /**
  76345. * The original blend value of the runtime animation
  76346. */
  76347. private _originalBlendValue;
  76348. /**
  76349. * The offsets cache of the runtime animation
  76350. */
  76351. private _offsetsCache;
  76352. /**
  76353. * The high limits cache of the runtime animation
  76354. */
  76355. private _highLimitsCache;
  76356. /**
  76357. * Specifies if the runtime animation has been stopped
  76358. */
  76359. private _stopped;
  76360. /**
  76361. * The blending factor of the runtime animation
  76362. */
  76363. private _blendingFactor;
  76364. /**
  76365. * The BabylonJS scene
  76366. */
  76367. private _scene;
  76368. /**
  76369. * The current value of the runtime animation
  76370. */
  76371. private _currentValue;
  76372. /** @hidden */
  76373. _animationState: _IAnimationState;
  76374. /**
  76375. * The active target of the runtime animation
  76376. */
  76377. private _activeTargets;
  76378. private _currentActiveTarget;
  76379. private _directTarget;
  76380. /**
  76381. * The target path of the runtime animation
  76382. */
  76383. private _targetPath;
  76384. /**
  76385. * The weight of the runtime animation
  76386. */
  76387. private _weight;
  76388. /**
  76389. * The ratio offset of the runtime animation
  76390. */
  76391. private _ratioOffset;
  76392. /**
  76393. * The previous delay of the runtime animation
  76394. */
  76395. private _previousDelay;
  76396. /**
  76397. * The previous ratio of the runtime animation
  76398. */
  76399. private _previousRatio;
  76400. private _enableBlending;
  76401. private _keys;
  76402. private _minFrame;
  76403. private _maxFrame;
  76404. private _minValue;
  76405. private _maxValue;
  76406. private _targetIsArray;
  76407. /**
  76408. * Gets the current frame of the runtime animation
  76409. */
  76410. readonly currentFrame: number;
  76411. /**
  76412. * Gets the weight of the runtime animation
  76413. */
  76414. readonly weight: number;
  76415. /**
  76416. * Gets the current value of the runtime animation
  76417. */
  76418. readonly currentValue: any;
  76419. /**
  76420. * Gets the target path of the runtime animation
  76421. */
  76422. readonly targetPath: string;
  76423. /**
  76424. * Gets the actual target of the runtime animation
  76425. */
  76426. readonly target: any;
  76427. /** @hidden */
  76428. _onLoop: () => void;
  76429. /**
  76430. * Create a new RuntimeAnimation object
  76431. * @param target defines the target of the animation
  76432. * @param animation defines the source animation object
  76433. * @param scene defines the hosting scene
  76434. * @param host defines the initiating Animatable
  76435. */
  76436. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76437. private _preparePath;
  76438. /**
  76439. * Gets the animation from the runtime animation
  76440. */
  76441. readonly animation: Animation;
  76442. /**
  76443. * Resets the runtime animation to the beginning
  76444. * @param restoreOriginal defines whether to restore the target property to the original value
  76445. */
  76446. reset(restoreOriginal?: boolean): void;
  76447. /**
  76448. * Specifies if the runtime animation is stopped
  76449. * @returns Boolean specifying if the runtime animation is stopped
  76450. */
  76451. isStopped(): boolean;
  76452. /**
  76453. * Disposes of the runtime animation
  76454. */
  76455. dispose(): void;
  76456. /**
  76457. * Apply the interpolated value to the target
  76458. * @param currentValue defines the value computed by the animation
  76459. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76460. */
  76461. setValue(currentValue: any, weight: number): void;
  76462. private _getOriginalValues;
  76463. private _setValue;
  76464. /**
  76465. * Gets the loop pmode of the runtime animation
  76466. * @returns Loop Mode
  76467. */
  76468. private _getCorrectLoopMode;
  76469. /**
  76470. * Move the current animation to a given frame
  76471. * @param frame defines the frame to move to
  76472. */
  76473. goToFrame(frame: number): void;
  76474. /**
  76475. * @hidden Internal use only
  76476. */
  76477. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76478. /**
  76479. * Execute the current animation
  76480. * @param delay defines the delay to add to the current frame
  76481. * @param from defines the lower bound of the animation range
  76482. * @param to defines the upper bound of the animation range
  76483. * @param loop defines if the current animation must loop
  76484. * @param speedRatio defines the current speed ratio
  76485. * @param weight defines the weight of the animation (default is -1 so no weight)
  76486. * @param onLoop optional callback called when animation loops
  76487. * @returns a boolean indicating if the animation is running
  76488. */
  76489. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76490. }
  76491. }
  76492. declare module BABYLON {
  76493. /**
  76494. * Class used to store an actual running animation
  76495. */
  76496. export class Animatable {
  76497. /** defines the target object */
  76498. target: any;
  76499. /** defines the starting frame number (default is 0) */
  76500. fromFrame: number;
  76501. /** defines the ending frame number (default is 100) */
  76502. toFrame: number;
  76503. /** defines if the animation must loop (default is false) */
  76504. loopAnimation: boolean;
  76505. /** defines a callback to call when animation ends if it is not looping */
  76506. onAnimationEnd?: (() => void) | null | undefined;
  76507. /** defines a callback to call when animation loops */
  76508. onAnimationLoop?: (() => void) | null | undefined;
  76509. private _localDelayOffset;
  76510. private _pausedDelay;
  76511. private _runtimeAnimations;
  76512. private _paused;
  76513. private _scene;
  76514. private _speedRatio;
  76515. private _weight;
  76516. private _syncRoot;
  76517. /**
  76518. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76519. * This will only apply for non looping animation (default is true)
  76520. */
  76521. disposeOnEnd: boolean;
  76522. /**
  76523. * Gets a boolean indicating if the animation has started
  76524. */
  76525. animationStarted: boolean;
  76526. /**
  76527. * Observer raised when the animation ends
  76528. */
  76529. onAnimationEndObservable: Observable<Animatable>;
  76530. /**
  76531. * Observer raised when the animation loops
  76532. */
  76533. onAnimationLoopObservable: Observable<Animatable>;
  76534. /**
  76535. * Gets the root Animatable used to synchronize and normalize animations
  76536. */
  76537. readonly syncRoot: Nullable<Animatable>;
  76538. /**
  76539. * Gets the current frame of the first RuntimeAnimation
  76540. * Used to synchronize Animatables
  76541. */
  76542. readonly masterFrame: number;
  76543. /**
  76544. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76545. */
  76546. weight: number;
  76547. /**
  76548. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76549. */
  76550. speedRatio: number;
  76551. /**
  76552. * Creates a new Animatable
  76553. * @param scene defines the hosting scene
  76554. * @param target defines the target object
  76555. * @param fromFrame defines the starting frame number (default is 0)
  76556. * @param toFrame defines the ending frame number (default is 100)
  76557. * @param loopAnimation defines if the animation must loop (default is false)
  76558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76560. * @param animations defines a group of animation to add to the new Animatable
  76561. * @param onAnimationLoop defines a callback to call when animation loops
  76562. */
  76563. constructor(scene: Scene,
  76564. /** defines the target object */
  76565. target: any,
  76566. /** defines the starting frame number (default is 0) */
  76567. fromFrame?: number,
  76568. /** defines the ending frame number (default is 100) */
  76569. toFrame?: number,
  76570. /** defines if the animation must loop (default is false) */
  76571. loopAnimation?: boolean, speedRatio?: number,
  76572. /** defines a callback to call when animation ends if it is not looping */
  76573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76574. /** defines a callback to call when animation loops */
  76575. onAnimationLoop?: (() => void) | null | undefined);
  76576. /**
  76577. * Synchronize and normalize current Animatable with a source Animatable
  76578. * This is useful when using animation weights and when animations are not of the same length
  76579. * @param root defines the root Animatable to synchronize with
  76580. * @returns the current Animatable
  76581. */
  76582. syncWith(root: Animatable): Animatable;
  76583. /**
  76584. * Gets the list of runtime animations
  76585. * @returns an array of RuntimeAnimation
  76586. */
  76587. getAnimations(): RuntimeAnimation[];
  76588. /**
  76589. * Adds more animations to the current animatable
  76590. * @param target defines the target of the animations
  76591. * @param animations defines the new animations to add
  76592. */
  76593. appendAnimations(target: any, animations: Animation[]): void;
  76594. /**
  76595. * Gets the source animation for a specific property
  76596. * @param property defines the propertyu to look for
  76597. * @returns null or the source animation for the given property
  76598. */
  76599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76600. /**
  76601. * Gets the runtime animation for a specific property
  76602. * @param property defines the propertyu to look for
  76603. * @returns null or the runtime animation for the given property
  76604. */
  76605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76606. /**
  76607. * Resets the animatable to its original state
  76608. */
  76609. reset(): void;
  76610. /**
  76611. * Allows the animatable to blend with current running animations
  76612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76613. * @param blendingSpeed defines the blending speed to use
  76614. */
  76615. enableBlending(blendingSpeed: number): void;
  76616. /**
  76617. * Disable animation blending
  76618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76619. */
  76620. disableBlending(): void;
  76621. /**
  76622. * Jump directly to a given frame
  76623. * @param frame defines the frame to jump to
  76624. */
  76625. goToFrame(frame: number): void;
  76626. /**
  76627. * Pause the animation
  76628. */
  76629. pause(): void;
  76630. /**
  76631. * Restart the animation
  76632. */
  76633. restart(): void;
  76634. private _raiseOnAnimationEnd;
  76635. /**
  76636. * Stop and delete the current animation
  76637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76638. * @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)
  76639. */
  76640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76641. /**
  76642. * Wait asynchronously for the animation to end
  76643. * @returns a promise which will be fullfilled when the animation ends
  76644. */
  76645. waitAsync(): Promise<Animatable>;
  76646. /** @hidden */
  76647. _animate(delay: number): boolean;
  76648. }
  76649. interface Scene {
  76650. /** @hidden */
  76651. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76652. /** @hidden */
  76653. _processLateAnimationBindingsForMatrices(holder: {
  76654. totalWeight: number;
  76655. animations: RuntimeAnimation[];
  76656. originalValue: Matrix;
  76657. }): any;
  76658. /** @hidden */
  76659. _processLateAnimationBindingsForQuaternions(holder: {
  76660. totalWeight: number;
  76661. animations: RuntimeAnimation[];
  76662. originalValue: Quaternion;
  76663. }, refQuaternion: Quaternion): Quaternion;
  76664. /** @hidden */
  76665. _processLateAnimationBindings(): void;
  76666. /**
  76667. * Will start the animation sequence of a given target
  76668. * @param target defines the target
  76669. * @param from defines from which frame should animation start
  76670. * @param to defines until which frame should animation run.
  76671. * @param weight defines the weight to apply to the animation (1.0 by default)
  76672. * @param loop defines if the animation loops
  76673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76674. * @param onAnimationEnd defines the function to be executed when the animation ends
  76675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76676. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76677. * @param onAnimationLoop defines the callback to call when an animation loops
  76678. * @returns the animatable object created for this animation
  76679. */
  76680. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76681. /**
  76682. * Will start the animation sequence of a given target
  76683. * @param target defines the target
  76684. * @param from defines from which frame should animation start
  76685. * @param to defines until which frame should animation run.
  76686. * @param loop defines if the animation loops
  76687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76688. * @param onAnimationEnd defines the function to be executed when the animation ends
  76689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76691. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76692. * @param onAnimationLoop defines the callback to call when an animation loops
  76693. * @returns the animatable object created for this animation
  76694. */
  76695. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76696. /**
  76697. * Will start the animation sequence of a given target and its hierarchy
  76698. * @param target defines the target
  76699. * @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.
  76700. * @param from defines from which frame should animation start
  76701. * @param to defines until which frame should animation run.
  76702. * @param loop defines if the animation loops
  76703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76704. * @param onAnimationEnd defines the function to be executed when the animation ends
  76705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76708. * @param onAnimationLoop defines the callback to call when an animation loops
  76709. * @returns the list of created animatables
  76710. */
  76711. 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[];
  76712. /**
  76713. * Begin a new animation on a given node
  76714. * @param target defines the target where the animation will take place
  76715. * @param animations defines the list of animations to start
  76716. * @param from defines the initial value
  76717. * @param to defines the final value
  76718. * @param loop defines if you want animation to loop (off by default)
  76719. * @param speedRatio defines the speed ratio to apply to all animations
  76720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76721. * @param onAnimationLoop defines the callback to call when an animation loops
  76722. * @returns the list of created animatables
  76723. */
  76724. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76725. /**
  76726. * Begin a new animation on a given node and its hierarchy
  76727. * @param target defines the root node where the animation will take place
  76728. * @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.
  76729. * @param animations defines the list of animations to start
  76730. * @param from defines the initial value
  76731. * @param to defines the final value
  76732. * @param loop defines if you want animation to loop (off by default)
  76733. * @param speedRatio defines the speed ratio to apply to all animations
  76734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76735. * @param onAnimationLoop defines the callback to call when an animation loops
  76736. * @returns the list of animatables created for all nodes
  76737. */
  76738. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76739. /**
  76740. * Gets the animatable associated with a specific target
  76741. * @param target defines the target of the animatable
  76742. * @returns the required animatable if found
  76743. */
  76744. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76745. /**
  76746. * Gets all animatables associated with a given target
  76747. * @param target defines the target to look animatables for
  76748. * @returns an array of Animatables
  76749. */
  76750. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76751. /**
  76752. * Stops and removes all animations that have been applied to the scene
  76753. */
  76754. stopAllAnimations(): void;
  76755. }
  76756. interface Bone {
  76757. /**
  76758. * Copy an animation range from another bone
  76759. * @param source defines the source bone
  76760. * @param rangeName defines the range name to copy
  76761. * @param frameOffset defines the frame offset
  76762. * @param rescaleAsRequired defines if rescaling must be applied if required
  76763. * @param skelDimensionsRatio defines the scaling ratio
  76764. * @returns true if operation was successful
  76765. */
  76766. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76767. }
  76768. }
  76769. declare module BABYLON {
  76770. /**
  76771. * Class used to override all child animations of a given target
  76772. */
  76773. export class AnimationPropertiesOverride {
  76774. /**
  76775. * Gets or sets a value indicating if animation blending must be used
  76776. */
  76777. enableBlending: boolean;
  76778. /**
  76779. * Gets or sets the blending speed to use when enableBlending is true
  76780. */
  76781. blendingSpeed: number;
  76782. /**
  76783. * Gets or sets the default loop mode to use
  76784. */
  76785. loopMode: number;
  76786. }
  76787. }
  76788. declare module BABYLON {
  76789. /**
  76790. * Class used to handle skinning animations
  76791. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76792. */
  76793. export class Skeleton implements IAnimatable {
  76794. /** defines the skeleton name */
  76795. name: string;
  76796. /** defines the skeleton Id */
  76797. id: string;
  76798. /**
  76799. * Defines the list of child bones
  76800. */
  76801. bones: Bone[];
  76802. /**
  76803. * Defines an estimate of the dimension of the skeleton at rest
  76804. */
  76805. dimensionsAtRest: Vector3;
  76806. /**
  76807. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76808. */
  76809. needInitialSkinMatrix: boolean;
  76810. /**
  76811. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76812. */
  76813. overrideMesh: Nullable<AbstractMesh>;
  76814. /**
  76815. * Gets the list of animations attached to this skeleton
  76816. */
  76817. animations: Array<Animation>;
  76818. private _scene;
  76819. private _isDirty;
  76820. private _transformMatrices;
  76821. private _transformMatrixTexture;
  76822. private _meshesWithPoseMatrix;
  76823. private _animatables;
  76824. private _identity;
  76825. private _synchronizedWithMesh;
  76826. private _ranges;
  76827. private _lastAbsoluteTransformsUpdateId;
  76828. private _canUseTextureForBones;
  76829. private _uniqueId;
  76830. /** @hidden */
  76831. _numBonesWithLinkedTransformNode: number;
  76832. /** @hidden */
  76833. _hasWaitingData: Nullable<boolean>;
  76834. /**
  76835. * Specifies if the skeleton should be serialized
  76836. */
  76837. doNotSerialize: boolean;
  76838. private _useTextureToStoreBoneMatrices;
  76839. /**
  76840. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76841. * Please note that this option is not available if the hardware does not support it
  76842. */
  76843. useTextureToStoreBoneMatrices: boolean;
  76844. private _animationPropertiesOverride;
  76845. /**
  76846. * Gets or sets the animation properties override
  76847. */
  76848. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76849. /**
  76850. * List of inspectable custom properties (used by the Inspector)
  76851. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76852. */
  76853. inspectableCustomProperties: IInspectable[];
  76854. /**
  76855. * An observable triggered before computing the skeleton's matrices
  76856. */
  76857. onBeforeComputeObservable: Observable<Skeleton>;
  76858. /**
  76859. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76860. */
  76861. readonly isUsingTextureForMatrices: boolean;
  76862. /**
  76863. * Gets the unique ID of this skeleton
  76864. */
  76865. readonly uniqueId: number;
  76866. /**
  76867. * Creates a new skeleton
  76868. * @param name defines the skeleton name
  76869. * @param id defines the skeleton Id
  76870. * @param scene defines the hosting scene
  76871. */
  76872. constructor(
  76873. /** defines the skeleton name */
  76874. name: string,
  76875. /** defines the skeleton Id */
  76876. id: string, scene: Scene);
  76877. /**
  76878. * Gets the current object class name.
  76879. * @return the class name
  76880. */
  76881. getClassName(): string;
  76882. /**
  76883. * Returns an array containing the root bones
  76884. * @returns an array containing the root bones
  76885. */
  76886. getChildren(): Array<Bone>;
  76887. /**
  76888. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76889. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76890. * @returns a Float32Array containing matrices data
  76891. */
  76892. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76893. /**
  76894. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76895. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76896. * @returns a raw texture containing the data
  76897. */
  76898. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  76899. /**
  76900. * Gets the current hosting scene
  76901. * @returns a scene object
  76902. */
  76903. getScene(): Scene;
  76904. /**
  76905. * Gets a string representing the current skeleton data
  76906. * @param fullDetails defines a boolean indicating if we want a verbose version
  76907. * @returns a string representing the current skeleton data
  76908. */
  76909. toString(fullDetails?: boolean): string;
  76910. /**
  76911. * Get bone's index searching by name
  76912. * @param name defines bone's name to search for
  76913. * @return the indice of the bone. Returns -1 if not found
  76914. */
  76915. getBoneIndexByName(name: string): number;
  76916. /**
  76917. * Creater a new animation range
  76918. * @param name defines the name of the range
  76919. * @param from defines the start key
  76920. * @param to defines the end key
  76921. */
  76922. createAnimationRange(name: string, from: number, to: number): void;
  76923. /**
  76924. * Delete a specific animation range
  76925. * @param name defines the name of the range
  76926. * @param deleteFrames defines if frames must be removed as well
  76927. */
  76928. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76929. /**
  76930. * Gets a specific animation range
  76931. * @param name defines the name of the range to look for
  76932. * @returns the requested animation range or null if not found
  76933. */
  76934. getAnimationRange(name: string): Nullable<AnimationRange>;
  76935. /**
  76936. * Gets the list of all animation ranges defined on this skeleton
  76937. * @returns an array
  76938. */
  76939. getAnimationRanges(): Nullable<AnimationRange>[];
  76940. /**
  76941. * Copy animation range from a source skeleton.
  76942. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76943. * @param source defines the source skeleton
  76944. * @param name defines the name of the range to copy
  76945. * @param rescaleAsRequired defines if rescaling must be applied if required
  76946. * @returns true if operation was successful
  76947. */
  76948. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76949. /**
  76950. * Forces the skeleton to go to rest pose
  76951. */
  76952. returnToRest(): void;
  76953. private _getHighestAnimationFrame;
  76954. /**
  76955. * Begin a specific animation range
  76956. * @param name defines the name of the range to start
  76957. * @param loop defines if looping must be turned on (false by default)
  76958. * @param speedRatio defines the speed ratio to apply (1 by default)
  76959. * @param onAnimationEnd defines a callback which will be called when animation will end
  76960. * @returns a new animatable
  76961. */
  76962. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76963. /** @hidden */
  76964. _markAsDirty(): void;
  76965. /** @hidden */
  76966. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76967. /** @hidden */
  76968. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76969. private _computeTransformMatrices;
  76970. /**
  76971. * Build all resources required to render a skeleton
  76972. */
  76973. prepare(): void;
  76974. /**
  76975. * Gets the list of animatables currently running for this skeleton
  76976. * @returns an array of animatables
  76977. */
  76978. getAnimatables(): IAnimatable[];
  76979. /**
  76980. * Clone the current skeleton
  76981. * @param name defines the name of the new skeleton
  76982. * @param id defines the id of the new skeleton
  76983. * @returns the new skeleton
  76984. */
  76985. clone(name: string, id: string): Skeleton;
  76986. /**
  76987. * Enable animation blending for this skeleton
  76988. * @param blendingSpeed defines the blending speed to apply
  76989. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76990. */
  76991. enableBlending(blendingSpeed?: number): void;
  76992. /**
  76993. * Releases all resources associated with the current skeleton
  76994. */
  76995. dispose(): void;
  76996. /**
  76997. * Serialize the skeleton in a JSON object
  76998. * @returns a JSON object
  76999. */
  77000. serialize(): any;
  77001. /**
  77002. * Creates a new skeleton from serialized data
  77003. * @param parsedSkeleton defines the serialized data
  77004. * @param scene defines the hosting scene
  77005. * @returns a new skeleton
  77006. */
  77007. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  77008. /**
  77009. * Compute all node absolute transforms
  77010. * @param forceUpdate defines if computation must be done even if cache is up to date
  77011. */
  77012. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  77013. /**
  77014. * Gets the root pose matrix
  77015. * @returns a matrix
  77016. */
  77017. getPoseMatrix(): Nullable<Matrix>;
  77018. /**
  77019. * Sorts bones per internal index
  77020. */
  77021. sortBones(): void;
  77022. private _sortBones;
  77023. }
  77024. }
  77025. declare module BABYLON {
  77026. /**
  77027. * Class used to store bone information
  77028. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77029. */
  77030. export class Bone extends Node {
  77031. /**
  77032. * defines the bone name
  77033. */
  77034. name: string;
  77035. private static _tmpVecs;
  77036. private static _tmpQuat;
  77037. private static _tmpMats;
  77038. /**
  77039. * Gets the list of child bones
  77040. */
  77041. children: Bone[];
  77042. /** Gets the animations associated with this bone */
  77043. animations: Animation[];
  77044. /**
  77045. * Gets or sets bone length
  77046. */
  77047. length: number;
  77048. /**
  77049. * @hidden Internal only
  77050. * Set this value to map this bone to a different index in the transform matrices
  77051. * Set this value to -1 to exclude the bone from the transform matrices
  77052. */
  77053. _index: Nullable<number>;
  77054. private _skeleton;
  77055. private _localMatrix;
  77056. private _restPose;
  77057. private _baseMatrix;
  77058. private _absoluteTransform;
  77059. private _invertedAbsoluteTransform;
  77060. private _parent;
  77061. private _scalingDeterminant;
  77062. private _worldTransform;
  77063. private _localScaling;
  77064. private _localRotation;
  77065. private _localPosition;
  77066. private _needToDecompose;
  77067. private _needToCompose;
  77068. /** @hidden */
  77069. _linkedTransformNode: Nullable<TransformNode>;
  77070. /** @hidden */
  77071. _waitingTransformNodeId: Nullable<string>;
  77072. /** @hidden */
  77073. /** @hidden */
  77074. _matrix: Matrix;
  77075. /**
  77076. * Create a new bone
  77077. * @param name defines the bone name
  77078. * @param skeleton defines the parent skeleton
  77079. * @param parentBone defines the parent (can be null if the bone is the root)
  77080. * @param localMatrix defines the local matrix
  77081. * @param restPose defines the rest pose matrix
  77082. * @param baseMatrix defines the base matrix
  77083. * @param index defines index of the bone in the hiearchy
  77084. */
  77085. constructor(
  77086. /**
  77087. * defines the bone name
  77088. */
  77089. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77090. /**
  77091. * Gets the current object class name.
  77092. * @return the class name
  77093. */
  77094. getClassName(): string;
  77095. /**
  77096. * Gets the parent skeleton
  77097. * @returns a skeleton
  77098. */
  77099. getSkeleton(): Skeleton;
  77100. /**
  77101. * Gets parent bone
  77102. * @returns a bone or null if the bone is the root of the bone hierarchy
  77103. */
  77104. getParent(): Nullable<Bone>;
  77105. /**
  77106. * Returns an array containing the root bones
  77107. * @returns an array containing the root bones
  77108. */
  77109. getChildren(): Array<Bone>;
  77110. /**
  77111. * Sets the parent bone
  77112. * @param parent defines the parent (can be null if the bone is the root)
  77113. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77114. */
  77115. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77116. /**
  77117. * Gets the local matrix
  77118. * @returns a matrix
  77119. */
  77120. getLocalMatrix(): Matrix;
  77121. /**
  77122. * Gets the base matrix (initial matrix which remains unchanged)
  77123. * @returns a matrix
  77124. */
  77125. getBaseMatrix(): Matrix;
  77126. /**
  77127. * Gets the rest pose matrix
  77128. * @returns a matrix
  77129. */
  77130. getRestPose(): Matrix;
  77131. /**
  77132. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77133. */
  77134. getWorldMatrix(): Matrix;
  77135. /**
  77136. * Sets the local matrix to rest pose matrix
  77137. */
  77138. returnToRest(): void;
  77139. /**
  77140. * Gets the inverse of the absolute transform matrix.
  77141. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77142. * @returns a matrix
  77143. */
  77144. getInvertedAbsoluteTransform(): Matrix;
  77145. /**
  77146. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77147. * @returns a matrix
  77148. */
  77149. getAbsoluteTransform(): Matrix;
  77150. /**
  77151. * Links with the given transform node.
  77152. * The local matrix of this bone is copied from the transform node every frame.
  77153. * @param transformNode defines the transform node to link to
  77154. */
  77155. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77156. /**
  77157. * Gets the node used to drive the bone's transformation
  77158. * @returns a transform node or null
  77159. */
  77160. getTransformNode(): Nullable<TransformNode>;
  77161. /** Gets or sets current position (in local space) */
  77162. position: Vector3;
  77163. /** Gets or sets current rotation (in local space) */
  77164. rotation: Vector3;
  77165. /** Gets or sets current rotation quaternion (in local space) */
  77166. rotationQuaternion: Quaternion;
  77167. /** Gets or sets current scaling (in local space) */
  77168. scaling: Vector3;
  77169. /**
  77170. * Gets the animation properties override
  77171. */
  77172. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77173. private _decompose;
  77174. private _compose;
  77175. /**
  77176. * Update the base and local matrices
  77177. * @param matrix defines the new base or local matrix
  77178. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77179. * @param updateLocalMatrix defines if the local matrix should be updated
  77180. */
  77181. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77182. /** @hidden */
  77183. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77184. /**
  77185. * Flag the bone as dirty (Forcing it to update everything)
  77186. */
  77187. markAsDirty(): void;
  77188. /** @hidden */
  77189. _markAsDirtyAndCompose(): void;
  77190. private _markAsDirtyAndDecompose;
  77191. /**
  77192. * Translate the bone in local or world space
  77193. * @param vec The amount to translate the bone
  77194. * @param space The space that the translation is in
  77195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77196. */
  77197. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77198. /**
  77199. * Set the postion of the bone in local or world space
  77200. * @param position The position to set the bone
  77201. * @param space The space that the position is in
  77202. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77203. */
  77204. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77205. /**
  77206. * Set the absolute position of the bone (world space)
  77207. * @param position The position to set the bone
  77208. * @param mesh The mesh that this bone is attached to
  77209. */
  77210. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77211. /**
  77212. * Scale the bone on the x, y and z axes (in local space)
  77213. * @param x The amount to scale the bone on the x axis
  77214. * @param y The amount to scale the bone on the y axis
  77215. * @param z The amount to scale the bone on the z axis
  77216. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77217. */
  77218. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77219. /**
  77220. * Set the bone scaling in local space
  77221. * @param scale defines the scaling vector
  77222. */
  77223. setScale(scale: Vector3): void;
  77224. /**
  77225. * Gets the current scaling in local space
  77226. * @returns the current scaling vector
  77227. */
  77228. getScale(): Vector3;
  77229. /**
  77230. * Gets the current scaling in local space and stores it in a target vector
  77231. * @param result defines the target vector
  77232. */
  77233. getScaleToRef(result: Vector3): void;
  77234. /**
  77235. * Set the yaw, pitch, and roll of the bone in local or world space
  77236. * @param yaw The rotation of the bone on the y axis
  77237. * @param pitch The rotation of the bone on the x axis
  77238. * @param roll The rotation of the bone on the z axis
  77239. * @param space The space that the axes of rotation are in
  77240. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77241. */
  77242. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77243. /**
  77244. * Add a rotation to the bone on an axis in local or world space
  77245. * @param axis The axis to rotate the bone on
  77246. * @param amount The amount to rotate the bone
  77247. * @param space The space that the axis is in
  77248. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77249. */
  77250. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77251. /**
  77252. * Set the rotation of the bone to a particular axis angle in local or world space
  77253. * @param axis The axis to rotate the bone on
  77254. * @param angle The angle that the bone should be rotated to
  77255. * @param space The space that the axis is in
  77256. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77257. */
  77258. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77259. /**
  77260. * Set the euler rotation of the bone in local of world space
  77261. * @param rotation The euler rotation that the bone should be set to
  77262. * @param space The space that the rotation is in
  77263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77264. */
  77265. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77266. /**
  77267. * Set the quaternion rotation of the bone in local of world space
  77268. * @param quat The quaternion rotation that the bone should be set to
  77269. * @param space The space that the rotation is in
  77270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77271. */
  77272. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77273. /**
  77274. * Set the rotation matrix of the bone in local of world space
  77275. * @param rotMat The rotation matrix that the bone should be set to
  77276. * @param space The space that the rotation is in
  77277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77278. */
  77279. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77280. private _rotateWithMatrix;
  77281. private _getNegativeRotationToRef;
  77282. /**
  77283. * Get the position of the bone in local or world space
  77284. * @param space The space that the returned position is in
  77285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77286. * @returns The position of the bone
  77287. */
  77288. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77289. /**
  77290. * Copy the position of the bone to a vector3 in local or world space
  77291. * @param space The space that the returned position is in
  77292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77293. * @param result The vector3 to copy the position to
  77294. */
  77295. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77296. /**
  77297. * Get the absolute position of the bone (world space)
  77298. * @param mesh The mesh that this bone is attached to
  77299. * @returns The absolute position of the bone
  77300. */
  77301. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77302. /**
  77303. * Copy the absolute position of the bone (world space) to the result param
  77304. * @param mesh The mesh that this bone is attached to
  77305. * @param result The vector3 to copy the absolute position to
  77306. */
  77307. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77308. /**
  77309. * Compute the absolute transforms of this bone and its children
  77310. */
  77311. computeAbsoluteTransforms(): void;
  77312. /**
  77313. * Get the world direction from an axis that is in the local space of the bone
  77314. * @param localAxis The local direction that is used to compute the world direction
  77315. * @param mesh The mesh that this bone is attached to
  77316. * @returns The world direction
  77317. */
  77318. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77319. /**
  77320. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77321. * @param localAxis The local direction that is used to compute the world direction
  77322. * @param mesh The mesh that this bone is attached to
  77323. * @param result The vector3 that the world direction will be copied to
  77324. */
  77325. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77326. /**
  77327. * Get the euler rotation of the bone in local or world space
  77328. * @param space The space that the rotation should be in
  77329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77330. * @returns The euler rotation
  77331. */
  77332. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77333. /**
  77334. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77335. * @param space The space that the rotation should be in
  77336. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77337. * @param result The vector3 that the rotation should be copied to
  77338. */
  77339. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77340. /**
  77341. * Get the quaternion rotation of the bone in either local or world space
  77342. * @param space The space that the rotation should be in
  77343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77344. * @returns The quaternion rotation
  77345. */
  77346. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77347. /**
  77348. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77349. * @param space The space that the rotation should be in
  77350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77351. * @param result The quaternion that the rotation should be copied to
  77352. */
  77353. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77354. /**
  77355. * Get the rotation matrix of the bone in local or world space
  77356. * @param space The space that the rotation should be in
  77357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77358. * @returns The rotation matrix
  77359. */
  77360. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77361. /**
  77362. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77363. * @param space The space that the rotation should be in
  77364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77365. * @param result The quaternion that the rotation should be copied to
  77366. */
  77367. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77368. /**
  77369. * Get the world position of a point that is in the local space of the bone
  77370. * @param position The local position
  77371. * @param mesh The mesh that this bone is attached to
  77372. * @returns The world position
  77373. */
  77374. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77375. /**
  77376. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77377. * @param position The local position
  77378. * @param mesh The mesh that this bone is attached to
  77379. * @param result The vector3 that the world position should be copied to
  77380. */
  77381. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77382. /**
  77383. * Get the local position of a point that is in world space
  77384. * @param position The world position
  77385. * @param mesh The mesh that this bone is attached to
  77386. * @returns The local position
  77387. */
  77388. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77389. /**
  77390. * Get the local position of a point that is in world space and copy it to the result param
  77391. * @param position The world position
  77392. * @param mesh The mesh that this bone is attached to
  77393. * @param result The vector3 that the local position should be copied to
  77394. */
  77395. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77396. }
  77397. }
  77398. declare module BABYLON {
  77399. /**
  77400. * 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.
  77401. * @see https://doc.babylonjs.com/how_to/transformnode
  77402. */
  77403. export class TransformNode extends Node {
  77404. /**
  77405. * Object will not rotate to face the camera
  77406. */
  77407. static BILLBOARDMODE_NONE: number;
  77408. /**
  77409. * Object will rotate to face the camera but only on the x axis
  77410. */
  77411. static BILLBOARDMODE_X: number;
  77412. /**
  77413. * Object will rotate to face the camera but only on the y axis
  77414. */
  77415. static BILLBOARDMODE_Y: number;
  77416. /**
  77417. * Object will rotate to face the camera but only on the z axis
  77418. */
  77419. static BILLBOARDMODE_Z: number;
  77420. /**
  77421. * Object will rotate to face the camera
  77422. */
  77423. static BILLBOARDMODE_ALL: number;
  77424. private _forward;
  77425. private _forwardInverted;
  77426. private _up;
  77427. private _right;
  77428. private _rightInverted;
  77429. private _position;
  77430. private _rotation;
  77431. private _rotationQuaternion;
  77432. protected _scaling: Vector3;
  77433. protected _isDirty: boolean;
  77434. private _transformToBoneReferal;
  77435. private _isAbsoluteSynced;
  77436. private _billboardMode;
  77437. /**
  77438. * Gets or sets the billboard mode. Default is 0.
  77439. *
  77440. * | Value | Type | Description |
  77441. * | --- | --- | --- |
  77442. * | 0 | BILLBOARDMODE_NONE | |
  77443. * | 1 | BILLBOARDMODE_X | |
  77444. * | 2 | BILLBOARDMODE_Y | |
  77445. * | 4 | BILLBOARDMODE_Z | |
  77446. * | 7 | BILLBOARDMODE_ALL | |
  77447. *
  77448. */
  77449. billboardMode: number;
  77450. private _preserveParentRotationForBillboard;
  77451. /**
  77452. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77453. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77454. */
  77455. preserveParentRotationForBillboard: boolean;
  77456. /**
  77457. * 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
  77458. */
  77459. scalingDeterminant: number;
  77460. private _infiniteDistance;
  77461. /**
  77462. * Gets or sets the distance of the object to max, often used by skybox
  77463. */
  77464. infiniteDistance: boolean;
  77465. /**
  77466. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77467. * By default the system will update normals to compensate
  77468. */
  77469. ignoreNonUniformScaling: boolean;
  77470. /**
  77471. * 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
  77472. */
  77473. reIntegrateRotationIntoRotationQuaternion: boolean;
  77474. /** @hidden */
  77475. _poseMatrix: Nullable<Matrix>;
  77476. /** @hidden */
  77477. _localMatrix: Matrix;
  77478. private _usePivotMatrix;
  77479. private _absolutePosition;
  77480. private _absoluteScaling;
  77481. private _absoluteRotationQuaternion;
  77482. private _pivotMatrix;
  77483. private _pivotMatrixInverse;
  77484. protected _postMultiplyPivotMatrix: boolean;
  77485. protected _isWorldMatrixFrozen: boolean;
  77486. /** @hidden */
  77487. _indexInSceneTransformNodesArray: number;
  77488. /**
  77489. * An event triggered after the world matrix is updated
  77490. */
  77491. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77492. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77493. /**
  77494. * Gets a string identifying the name of the class
  77495. * @returns "TransformNode" string
  77496. */
  77497. getClassName(): string;
  77498. /**
  77499. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77500. */
  77501. position: Vector3;
  77502. /**
  77503. * 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)).
  77504. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77505. */
  77506. rotation: Vector3;
  77507. /**
  77508. * 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)).
  77509. */
  77510. scaling: Vector3;
  77511. /**
  77512. * 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).
  77513. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77514. */
  77515. rotationQuaternion: Nullable<Quaternion>;
  77516. /**
  77517. * The forward direction of that transform in world space.
  77518. */
  77519. readonly forward: Vector3;
  77520. /**
  77521. * The up direction of that transform in world space.
  77522. */
  77523. readonly up: Vector3;
  77524. /**
  77525. * The right direction of that transform in world space.
  77526. */
  77527. readonly right: Vector3;
  77528. /**
  77529. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77530. * @param matrix the matrix to copy the pose from
  77531. * @returns this TransformNode.
  77532. */
  77533. updatePoseMatrix(matrix: Matrix): TransformNode;
  77534. /**
  77535. * Returns the mesh Pose matrix.
  77536. * @returns the pose matrix
  77537. */
  77538. getPoseMatrix(): Matrix;
  77539. /** @hidden */
  77540. _isSynchronized(): boolean;
  77541. /** @hidden */
  77542. _initCache(): void;
  77543. /**
  77544. * Flag the transform node as dirty (Forcing it to update everything)
  77545. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77546. * @returns this transform node
  77547. */
  77548. markAsDirty(property: string): TransformNode;
  77549. /**
  77550. * Returns the current mesh absolute position.
  77551. * Returns a Vector3.
  77552. */
  77553. readonly absolutePosition: Vector3;
  77554. /**
  77555. * Returns the current mesh absolute scaling.
  77556. * Returns a Vector3.
  77557. */
  77558. readonly absoluteScaling: Vector3;
  77559. /**
  77560. * Returns the current mesh absolute rotation.
  77561. * Returns a Quaternion.
  77562. */
  77563. readonly absoluteRotationQuaternion: Quaternion;
  77564. /**
  77565. * Sets a new matrix to apply before all other transformation
  77566. * @param matrix defines the transform matrix
  77567. * @returns the current TransformNode
  77568. */
  77569. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77570. /**
  77571. * Sets a new pivot matrix to the current node
  77572. * @param matrix defines the new pivot matrix to use
  77573. * @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
  77574. * @returns the current TransformNode
  77575. */
  77576. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77577. /**
  77578. * Returns the mesh pivot matrix.
  77579. * Default : Identity.
  77580. * @returns the matrix
  77581. */
  77582. getPivotMatrix(): Matrix;
  77583. /**
  77584. * Prevents the World matrix to be computed any longer.
  77585. * @returns the TransformNode.
  77586. */
  77587. freezeWorldMatrix(): TransformNode;
  77588. /**
  77589. * Allows back the World matrix computation.
  77590. * @returns the TransformNode.
  77591. */
  77592. unfreezeWorldMatrix(): this;
  77593. /**
  77594. * True if the World matrix has been frozen.
  77595. */
  77596. readonly isWorldMatrixFrozen: boolean;
  77597. /**
  77598. * Retuns the mesh absolute position in the World.
  77599. * @returns a Vector3.
  77600. */
  77601. getAbsolutePosition(): Vector3;
  77602. /**
  77603. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77604. * @param absolutePosition the absolute position to set
  77605. * @returns the TransformNode.
  77606. */
  77607. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77608. /**
  77609. * Sets the mesh position in its local space.
  77610. * @param vector3 the position to set in localspace
  77611. * @returns the TransformNode.
  77612. */
  77613. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77614. /**
  77615. * Returns the mesh position in the local space from the current World matrix values.
  77616. * @returns a new Vector3.
  77617. */
  77618. getPositionExpressedInLocalSpace(): Vector3;
  77619. /**
  77620. * Translates the mesh along the passed Vector3 in its local space.
  77621. * @param vector3 the distance to translate in localspace
  77622. * @returns the TransformNode.
  77623. */
  77624. locallyTranslate(vector3: Vector3): TransformNode;
  77625. private static _lookAtVectorCache;
  77626. /**
  77627. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77628. * @param targetPoint the position (must be in same space as current mesh) to look at
  77629. * @param yawCor optional yaw (y-axis) correction in radians
  77630. * @param pitchCor optional pitch (x-axis) correction in radians
  77631. * @param rollCor optional roll (z-axis) correction in radians
  77632. * @param space the choosen space of the target
  77633. * @returns the TransformNode.
  77634. */
  77635. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77636. /**
  77637. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77638. * This Vector3 is expressed in the World space.
  77639. * @param localAxis axis to rotate
  77640. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77641. */
  77642. getDirection(localAxis: Vector3): Vector3;
  77643. /**
  77644. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77645. * localAxis is expressed in the mesh local space.
  77646. * result is computed in the Wordl space from the mesh World matrix.
  77647. * @param localAxis axis to rotate
  77648. * @param result the resulting transformnode
  77649. * @returns this TransformNode.
  77650. */
  77651. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77652. /**
  77653. * Sets this transform node rotation to the given local axis.
  77654. * @param localAxis the axis in local space
  77655. * @param yawCor optional yaw (y-axis) correction in radians
  77656. * @param pitchCor optional pitch (x-axis) correction in radians
  77657. * @param rollCor optional roll (z-axis) correction in radians
  77658. * @returns this TransformNode
  77659. */
  77660. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77661. /**
  77662. * Sets a new pivot point to the current node
  77663. * @param point defines the new pivot point to use
  77664. * @param space defines if the point is in world or local space (local by default)
  77665. * @returns the current TransformNode
  77666. */
  77667. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77668. /**
  77669. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77670. * @returns the pivot point
  77671. */
  77672. getPivotPoint(): Vector3;
  77673. /**
  77674. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77675. * @param result the vector3 to store the result
  77676. * @returns this TransformNode.
  77677. */
  77678. getPivotPointToRef(result: Vector3): TransformNode;
  77679. /**
  77680. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77681. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77682. */
  77683. getAbsolutePivotPoint(): Vector3;
  77684. /**
  77685. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77686. * @param result vector3 to store the result
  77687. * @returns this TransformNode.
  77688. */
  77689. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77690. /**
  77691. * Defines the passed node as the parent of the current node.
  77692. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77693. * @see https://doc.babylonjs.com/how_to/parenting
  77694. * @param node the node ot set as the parent
  77695. * @returns this TransformNode.
  77696. */
  77697. setParent(node: Nullable<Node>): TransformNode;
  77698. private _nonUniformScaling;
  77699. /**
  77700. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77701. */
  77702. readonly nonUniformScaling: boolean;
  77703. /** @hidden */
  77704. _updateNonUniformScalingState(value: boolean): boolean;
  77705. /**
  77706. * Attach the current TransformNode to another TransformNode associated with a bone
  77707. * @param bone Bone affecting the TransformNode
  77708. * @param affectedTransformNode TransformNode associated with the bone
  77709. * @returns this object
  77710. */
  77711. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77712. /**
  77713. * Detach the transform node if its associated with a bone
  77714. * @returns this object
  77715. */
  77716. detachFromBone(): TransformNode;
  77717. private static _rotationAxisCache;
  77718. /**
  77719. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77720. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77721. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77722. * The passed axis is also normalized.
  77723. * @param axis the axis to rotate around
  77724. * @param amount the amount to rotate in radians
  77725. * @param space Space to rotate in (Default: local)
  77726. * @returns the TransformNode.
  77727. */
  77728. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77729. /**
  77730. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77731. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77732. * The passed axis is also normalized. .
  77733. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77734. * @param point the point to rotate around
  77735. * @param axis the axis to rotate around
  77736. * @param amount the amount to rotate in radians
  77737. * @returns the TransformNode
  77738. */
  77739. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77740. /**
  77741. * Translates the mesh along the axis vector for the passed distance in the given space.
  77742. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77743. * @param axis the axis to translate in
  77744. * @param distance the distance to translate
  77745. * @param space Space to rotate in (Default: local)
  77746. * @returns the TransformNode.
  77747. */
  77748. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77749. /**
  77750. * Adds a rotation step to the mesh current rotation.
  77751. * x, y, z are Euler angles expressed in radians.
  77752. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77753. * This means this rotation is made in the mesh local space only.
  77754. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77755. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77756. * ```javascript
  77757. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77758. * ```
  77759. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77760. * 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.
  77761. * @param x Rotation to add
  77762. * @param y Rotation to add
  77763. * @param z Rotation to add
  77764. * @returns the TransformNode.
  77765. */
  77766. addRotation(x: number, y: number, z: number): TransformNode;
  77767. /**
  77768. * @hidden
  77769. */
  77770. protected _getEffectiveParent(): Nullable<Node>;
  77771. /**
  77772. * Computes the world matrix of the node
  77773. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77774. * @returns the world matrix
  77775. */
  77776. computeWorldMatrix(force?: boolean): Matrix;
  77777. protected _afterComputeWorldMatrix(): void;
  77778. /**
  77779. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77780. * @param func callback function to add
  77781. *
  77782. * @returns the TransformNode.
  77783. */
  77784. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77785. /**
  77786. * Removes a registered callback function.
  77787. * @param func callback function to remove
  77788. * @returns the TransformNode.
  77789. */
  77790. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77791. /**
  77792. * Gets the position of the current mesh in camera space
  77793. * @param camera defines the camera to use
  77794. * @returns a position
  77795. */
  77796. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77797. /**
  77798. * Returns the distance from the mesh to the active camera
  77799. * @param camera defines the camera to use
  77800. * @returns the distance
  77801. */
  77802. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77803. /**
  77804. * Clone the current transform node
  77805. * @param name Name of the new clone
  77806. * @param newParent New parent for the clone
  77807. * @param doNotCloneChildren Do not clone children hierarchy
  77808. * @returns the new transform node
  77809. */
  77810. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77811. /**
  77812. * Serializes the objects information.
  77813. * @param currentSerializationObject defines the object to serialize in
  77814. * @returns the serialized object
  77815. */
  77816. serialize(currentSerializationObject?: any): any;
  77817. /**
  77818. * Returns a new TransformNode object parsed from the source provided.
  77819. * @param parsedTransformNode is the source.
  77820. * @param scene the scne the object belongs to
  77821. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77822. * @returns a new TransformNode object parsed from the source provided.
  77823. */
  77824. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77825. /**
  77826. * Get all child-transformNodes of this node
  77827. * @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
  77828. * @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
  77829. * @returns an array of TransformNode
  77830. */
  77831. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77832. /**
  77833. * Releases resources associated with this transform node.
  77834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77836. */
  77837. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77838. /**
  77839. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77840. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77841. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  77842. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  77843. * @returns the current mesh
  77844. */
  77845. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  77846. private _syncAbsoluteScalingAndRotation;
  77847. }
  77848. }
  77849. declare module BABYLON {
  77850. /**
  77851. * Defines the types of pose enabled controllers that are supported
  77852. */
  77853. export enum PoseEnabledControllerType {
  77854. /**
  77855. * HTC Vive
  77856. */
  77857. VIVE = 0,
  77858. /**
  77859. * Oculus Rift
  77860. */
  77861. OCULUS = 1,
  77862. /**
  77863. * Windows mixed reality
  77864. */
  77865. WINDOWS = 2,
  77866. /**
  77867. * Samsung gear VR
  77868. */
  77869. GEAR_VR = 3,
  77870. /**
  77871. * Google Daydream
  77872. */
  77873. DAYDREAM = 4,
  77874. /**
  77875. * Generic
  77876. */
  77877. GENERIC = 5
  77878. }
  77879. /**
  77880. * Defines the MutableGamepadButton interface for the state of a gamepad button
  77881. */
  77882. export interface MutableGamepadButton {
  77883. /**
  77884. * Value of the button/trigger
  77885. */
  77886. value: number;
  77887. /**
  77888. * If the button/trigger is currently touched
  77889. */
  77890. touched: boolean;
  77891. /**
  77892. * If the button/trigger is currently pressed
  77893. */
  77894. pressed: boolean;
  77895. }
  77896. /**
  77897. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  77898. * @hidden
  77899. */
  77900. export interface ExtendedGamepadButton extends GamepadButton {
  77901. /**
  77902. * If the button/trigger is currently pressed
  77903. */
  77904. readonly pressed: boolean;
  77905. /**
  77906. * If the button/trigger is currently touched
  77907. */
  77908. readonly touched: boolean;
  77909. /**
  77910. * Value of the button/trigger
  77911. */
  77912. readonly value: number;
  77913. }
  77914. /** @hidden */
  77915. export interface _GamePadFactory {
  77916. /**
  77917. * Returns wether or not the current gamepad can be created for this type of controller.
  77918. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77919. * @returns true if it can be created, otherwise false
  77920. */
  77921. canCreate(gamepadInfo: any): boolean;
  77922. /**
  77923. * Creates a new instance of the Gamepad.
  77924. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77925. * @returns the new gamepad instance
  77926. */
  77927. create(gamepadInfo: any): Gamepad;
  77928. }
  77929. /**
  77930. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77931. */
  77932. export class PoseEnabledControllerHelper {
  77933. /** @hidden */
  77934. static _ControllerFactories: _GamePadFactory[];
  77935. /** @hidden */
  77936. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  77937. /**
  77938. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77939. * @param vrGamepad the gamepad to initialized
  77940. * @returns a vr controller of the type the gamepad identified as
  77941. */
  77942. static InitiateController(vrGamepad: any): Gamepad;
  77943. }
  77944. /**
  77945. * Defines the PoseEnabledController object that contains state of a vr capable controller
  77946. */
  77947. export class PoseEnabledController extends Gamepad implements PoseControlled {
  77948. /**
  77949. * If the controller is used in a webXR session
  77950. */
  77951. isXR: boolean;
  77952. private _deviceRoomPosition;
  77953. private _deviceRoomRotationQuaternion;
  77954. /**
  77955. * The device position in babylon space
  77956. */
  77957. devicePosition: Vector3;
  77958. /**
  77959. * The device rotation in babylon space
  77960. */
  77961. deviceRotationQuaternion: Quaternion;
  77962. /**
  77963. * The scale factor of the device in babylon space
  77964. */
  77965. deviceScaleFactor: number;
  77966. /**
  77967. * (Likely devicePosition should be used instead) The device position in its room space
  77968. */
  77969. position: Vector3;
  77970. /**
  77971. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  77972. */
  77973. rotationQuaternion: Quaternion;
  77974. /**
  77975. * The type of controller (Eg. Windows mixed reality)
  77976. */
  77977. controllerType: PoseEnabledControllerType;
  77978. protected _calculatedPosition: Vector3;
  77979. private _calculatedRotation;
  77980. /**
  77981. * The raw pose from the device
  77982. */
  77983. rawPose: DevicePose;
  77984. private _trackPosition;
  77985. private _maxRotationDistFromHeadset;
  77986. private _draggedRoomRotation;
  77987. /**
  77988. * @hidden
  77989. */
  77990. _disableTrackPosition(fixedPosition: Vector3): void;
  77991. /**
  77992. * Internal, the mesh attached to the controller
  77993. * @hidden
  77994. */
  77995. _mesh: Nullable<AbstractMesh>;
  77996. private _poseControlledCamera;
  77997. private _leftHandSystemQuaternion;
  77998. /**
  77999. * Internal, matrix used to convert room space to babylon space
  78000. * @hidden
  78001. */
  78002. _deviceToWorld: Matrix;
  78003. /**
  78004. * Node to be used when casting a ray from the controller
  78005. * @hidden
  78006. */
  78007. _pointingPoseNode: Nullable<TransformNode>;
  78008. /**
  78009. * Name of the child mesh that can be used to cast a ray from the controller
  78010. */
  78011. static readonly POINTING_POSE: string;
  78012. /**
  78013. * Creates a new PoseEnabledController from a gamepad
  78014. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  78015. */
  78016. constructor(browserGamepad: any);
  78017. private _workingMatrix;
  78018. /**
  78019. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  78020. */
  78021. update(): void;
  78022. /**
  78023. * Updates only the pose device and mesh without doing any button event checking
  78024. */
  78025. protected _updatePoseAndMesh(): void;
  78026. /**
  78027. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  78028. * @param poseData raw pose fromthe device
  78029. */
  78030. updateFromDevice(poseData: DevicePose): void;
  78031. /**
  78032. * @hidden
  78033. */
  78034. _meshAttachedObservable: Observable<AbstractMesh>;
  78035. /**
  78036. * Attaches a mesh to the controller
  78037. * @param mesh the mesh to be attached
  78038. */
  78039. attachToMesh(mesh: AbstractMesh): void;
  78040. /**
  78041. * Attaches the controllers mesh to a camera
  78042. * @param camera the camera the mesh should be attached to
  78043. */
  78044. attachToPoseControlledCamera(camera: TargetCamera): void;
  78045. /**
  78046. * Disposes of the controller
  78047. */
  78048. dispose(): void;
  78049. /**
  78050. * The mesh that is attached to the controller
  78051. */
  78052. readonly mesh: Nullable<AbstractMesh>;
  78053. /**
  78054. * Gets the ray of the controller in the direction the controller is pointing
  78055. * @param length the length the resulting ray should be
  78056. * @returns a ray in the direction the controller is pointing
  78057. */
  78058. getForwardRay(length?: number): Ray;
  78059. }
  78060. }
  78061. declare module BABYLON {
  78062. /**
  78063. * Defines the WebVRController object that represents controllers tracked in 3D space
  78064. */
  78065. export abstract class WebVRController extends PoseEnabledController {
  78066. /**
  78067. * Internal, the default controller model for the controller
  78068. */
  78069. protected _defaultModel: AbstractMesh;
  78070. /**
  78071. * Fired when the trigger state has changed
  78072. */
  78073. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78074. /**
  78075. * Fired when the main button state has changed
  78076. */
  78077. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78078. /**
  78079. * Fired when the secondary button state has changed
  78080. */
  78081. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78082. /**
  78083. * Fired when the pad state has changed
  78084. */
  78085. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78086. /**
  78087. * Fired when controllers stick values have changed
  78088. */
  78089. onPadValuesChangedObservable: Observable<StickValues>;
  78090. /**
  78091. * Array of button availible on the controller
  78092. */
  78093. protected _buttons: Array<MutableGamepadButton>;
  78094. private _onButtonStateChange;
  78095. /**
  78096. * Fired when a controller button's state has changed
  78097. * @param callback the callback containing the button that was modified
  78098. */
  78099. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78100. /**
  78101. * X and Y axis corresponding to the controllers joystick
  78102. */
  78103. pad: StickValues;
  78104. /**
  78105. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78106. */
  78107. hand: string;
  78108. /**
  78109. * The default controller model for the controller
  78110. */
  78111. readonly defaultModel: AbstractMesh;
  78112. /**
  78113. * Creates a new WebVRController from a gamepad
  78114. * @param vrGamepad the gamepad that the WebVRController should be created from
  78115. */
  78116. constructor(vrGamepad: any);
  78117. /**
  78118. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78119. */
  78120. update(): void;
  78121. /**
  78122. * Function to be called when a button is modified
  78123. */
  78124. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78125. /**
  78126. * Loads a mesh and attaches it to the controller
  78127. * @param scene the scene the mesh should be added to
  78128. * @param meshLoaded callback for when the mesh has been loaded
  78129. */
  78130. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78131. private _setButtonValue;
  78132. private _changes;
  78133. private _checkChanges;
  78134. /**
  78135. * Disposes of th webVRCOntroller
  78136. */
  78137. dispose(): void;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. /**
  78142. * The HemisphericLight simulates the ambient environment light,
  78143. * so the passed direction is the light reflection direction, not the incoming direction.
  78144. */
  78145. export class HemisphericLight extends Light {
  78146. /**
  78147. * The groundColor is the light in the opposite direction to the one specified during creation.
  78148. * 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.
  78149. */
  78150. groundColor: Color3;
  78151. /**
  78152. * The light reflection direction, not the incoming direction.
  78153. */
  78154. direction: Vector3;
  78155. /**
  78156. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78157. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78158. * The HemisphericLight can't cast shadows.
  78159. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78160. * @param name The friendly name of the light
  78161. * @param direction The direction of the light reflection
  78162. * @param scene The scene the light belongs to
  78163. */
  78164. constructor(name: string, direction: Vector3, scene: Scene);
  78165. protected _buildUniformLayout(): void;
  78166. /**
  78167. * Returns the string "HemisphericLight".
  78168. * @return The class name
  78169. */
  78170. getClassName(): string;
  78171. /**
  78172. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78173. * Returns the updated direction.
  78174. * @param target The target the direction should point to
  78175. * @return The computed direction
  78176. */
  78177. setDirectionToTarget(target: Vector3): Vector3;
  78178. /**
  78179. * Returns the shadow generator associated to the light.
  78180. * @returns Always null for hemispheric lights because it does not support shadows.
  78181. */
  78182. getShadowGenerator(): Nullable<IShadowGenerator>;
  78183. /**
  78184. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78185. * @param effect The effect to update
  78186. * @param lightIndex The index of the light in the effect to update
  78187. * @returns The hemispheric light
  78188. */
  78189. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78190. /**
  78191. * Computes the world matrix of the node
  78192. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78193. * @param useWasUpdatedFlag defines a reserved property
  78194. * @returns the world matrix
  78195. */
  78196. computeWorldMatrix(): Matrix;
  78197. /**
  78198. * Returns the integer 3.
  78199. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78200. */
  78201. getTypeID(): number;
  78202. /**
  78203. * Prepares the list of defines specific to the light type.
  78204. * @param defines the list of defines
  78205. * @param lightIndex defines the index of the light for the effect
  78206. */
  78207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78208. }
  78209. }
  78210. declare module BABYLON {
  78211. /** @hidden */
  78212. export var vrMultiviewToSingleviewPixelShader: {
  78213. name: string;
  78214. shader: string;
  78215. };
  78216. }
  78217. declare module BABYLON {
  78218. /**
  78219. * Renders to multiple views with a single draw call
  78220. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78221. */
  78222. export class MultiviewRenderTarget extends RenderTargetTexture {
  78223. /**
  78224. * Creates a multiview render target
  78225. * @param scene scene used with the render target
  78226. * @param size the size of the render target (used for each view)
  78227. */
  78228. constructor(scene: Scene, size?: number | {
  78229. width: number;
  78230. height: number;
  78231. } | {
  78232. ratio: number;
  78233. });
  78234. /**
  78235. * @hidden
  78236. * @param faceIndex the face index, if its a cube texture
  78237. */
  78238. _bindFrameBuffer(faceIndex?: number): void;
  78239. /**
  78240. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78241. * @returns the view count
  78242. */
  78243. getViewCount(): number;
  78244. }
  78245. }
  78246. declare module BABYLON {
  78247. /**
  78248. * Reprasents a camera frustum
  78249. */
  78250. export class Frustum {
  78251. /**
  78252. * Gets the planes representing the frustum
  78253. * @param transform matrix to be applied to the returned planes
  78254. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78255. */
  78256. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78257. /**
  78258. * Gets the near frustum plane transformed by the transform matrix
  78259. * @param transform transformation matrix to be applied to the resulting frustum plane
  78260. * @param frustumPlane the resuling frustum plane
  78261. */
  78262. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78263. /**
  78264. * Gets the far frustum plane transformed by the transform matrix
  78265. * @param transform transformation matrix to be applied to the resulting frustum plane
  78266. * @param frustumPlane the resuling frustum plane
  78267. */
  78268. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78269. /**
  78270. * Gets the left frustum plane transformed by the transform matrix
  78271. * @param transform transformation matrix to be applied to the resulting frustum plane
  78272. * @param frustumPlane the resuling frustum plane
  78273. */
  78274. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78275. /**
  78276. * Gets the right frustum plane transformed by the transform matrix
  78277. * @param transform transformation matrix to be applied to the resulting frustum plane
  78278. * @param frustumPlane the resuling frustum plane
  78279. */
  78280. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78281. /**
  78282. * Gets the top frustum plane transformed by the transform matrix
  78283. * @param transform transformation matrix to be applied to the resulting frustum plane
  78284. * @param frustumPlane the resuling frustum plane
  78285. */
  78286. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78287. /**
  78288. * Gets the bottom frustum plane transformed by the transform matrix
  78289. * @param transform transformation matrix to be applied to the resulting frustum plane
  78290. * @param frustumPlane the resuling frustum plane
  78291. */
  78292. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78293. /**
  78294. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78295. * @param transform transformation matrix to be applied to the resulting frustum planes
  78296. * @param frustumPlanes the resuling frustum planes
  78297. */
  78298. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78299. }
  78300. }
  78301. declare module BABYLON {
  78302. interface Engine {
  78303. /**
  78304. * Creates a new multiview render target
  78305. * @param width defines the width of the texture
  78306. * @param height defines the height of the texture
  78307. * @returns the created multiview texture
  78308. */
  78309. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78310. /**
  78311. * Binds a multiview framebuffer to be drawn to
  78312. * @param multiviewTexture texture to bind
  78313. */
  78314. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78315. }
  78316. interface Camera {
  78317. /**
  78318. * @hidden
  78319. * 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)
  78320. */
  78321. _useMultiviewToSingleView: boolean;
  78322. /**
  78323. * @hidden
  78324. * 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)
  78325. */
  78326. _multiviewTexture: Nullable<RenderTargetTexture>;
  78327. /**
  78328. * @hidden
  78329. * ensures the multiview texture of the camera exists and has the specified width/height
  78330. * @param width height to set on the multiview texture
  78331. * @param height width to set on the multiview texture
  78332. */
  78333. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78334. }
  78335. interface Scene {
  78336. /** @hidden */
  78337. _transformMatrixR: Matrix;
  78338. /** @hidden */
  78339. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78340. /** @hidden */
  78341. _createMultiviewUbo(): void;
  78342. /** @hidden */
  78343. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78344. /** @hidden */
  78345. _renderMultiviewToSingleView(camera: Camera): void;
  78346. }
  78347. }
  78348. declare module BABYLON {
  78349. /**
  78350. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78351. * This will not be used for webXR as it supports displaying texture arrays directly
  78352. */
  78353. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78354. /**
  78355. * Initializes a VRMultiviewToSingleview
  78356. * @param name name of the post process
  78357. * @param camera camera to be applied to
  78358. * @param scaleFactor scaling factor to the size of the output texture
  78359. */
  78360. constructor(name: string, camera: Camera, scaleFactor: number);
  78361. }
  78362. }
  78363. declare module BABYLON {
  78364. interface Engine {
  78365. /** @hidden */
  78366. _vrDisplay: any;
  78367. /** @hidden */
  78368. _vrSupported: boolean;
  78369. /** @hidden */
  78370. _oldSize: Size;
  78371. /** @hidden */
  78372. _oldHardwareScaleFactor: number;
  78373. /** @hidden */
  78374. _vrExclusivePointerMode: boolean;
  78375. /** @hidden */
  78376. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78377. /** @hidden */
  78378. _onVRDisplayPointerRestricted: () => void;
  78379. /** @hidden */
  78380. _onVRDisplayPointerUnrestricted: () => void;
  78381. /** @hidden */
  78382. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78383. /** @hidden */
  78384. _onVrDisplayDisconnect: Nullable<() => void>;
  78385. /** @hidden */
  78386. _onVrDisplayPresentChange: Nullable<() => void>;
  78387. /**
  78388. * Observable signaled when VR display mode changes
  78389. */
  78390. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78391. /**
  78392. * Observable signaled when VR request present is complete
  78393. */
  78394. onVRRequestPresentComplete: Observable<boolean>;
  78395. /**
  78396. * Observable signaled when VR request present starts
  78397. */
  78398. onVRRequestPresentStart: Observable<Engine>;
  78399. /**
  78400. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78401. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78402. */
  78403. isInVRExclusivePointerMode: boolean;
  78404. /**
  78405. * Gets a boolean indicating if a webVR device was detected
  78406. * @returns true if a webVR device was detected
  78407. */
  78408. isVRDevicePresent(): boolean;
  78409. /**
  78410. * Gets the current webVR device
  78411. * @returns the current webVR device (or null)
  78412. */
  78413. getVRDevice(): any;
  78414. /**
  78415. * Initializes a webVR display and starts listening to display change events
  78416. * The onVRDisplayChangedObservable will be notified upon these changes
  78417. * @returns A promise containing a VRDisplay and if vr is supported
  78418. */
  78419. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78420. /** @hidden */
  78421. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78422. /**
  78423. * Call this function to switch to webVR mode
  78424. * Will do nothing if webVR is not supported or if there is no webVR device
  78425. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78426. */
  78427. enableVR(): void;
  78428. /** @hidden */
  78429. _onVRFullScreenTriggered(): void;
  78430. }
  78431. }
  78432. declare module BABYLON {
  78433. /**
  78434. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78435. * IMPORTANT!! The data is right-hand data.
  78436. * @export
  78437. * @interface DevicePose
  78438. */
  78439. export interface DevicePose {
  78440. /**
  78441. * The position of the device, values in array are [x,y,z].
  78442. */
  78443. readonly position: Nullable<Float32Array>;
  78444. /**
  78445. * The linearVelocity of the device, values in array are [x,y,z].
  78446. */
  78447. readonly linearVelocity: Nullable<Float32Array>;
  78448. /**
  78449. * The linearAcceleration of the device, values in array are [x,y,z].
  78450. */
  78451. readonly linearAcceleration: Nullable<Float32Array>;
  78452. /**
  78453. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78454. */
  78455. readonly orientation: Nullable<Float32Array>;
  78456. /**
  78457. * The angularVelocity of the device, values in array are [x,y,z].
  78458. */
  78459. readonly angularVelocity: Nullable<Float32Array>;
  78460. /**
  78461. * The angularAcceleration of the device, values in array are [x,y,z].
  78462. */
  78463. readonly angularAcceleration: Nullable<Float32Array>;
  78464. }
  78465. /**
  78466. * Interface representing a pose controlled object in Babylon.
  78467. * A pose controlled object has both regular pose values as well as pose values
  78468. * from an external device such as a VR head mounted display
  78469. */
  78470. export interface PoseControlled {
  78471. /**
  78472. * The position of the object in babylon space.
  78473. */
  78474. position: Vector3;
  78475. /**
  78476. * The rotation quaternion of the object in babylon space.
  78477. */
  78478. rotationQuaternion: Quaternion;
  78479. /**
  78480. * The position of the device in babylon space.
  78481. */
  78482. devicePosition?: Vector3;
  78483. /**
  78484. * The rotation quaternion of the device in babylon space.
  78485. */
  78486. deviceRotationQuaternion: Quaternion;
  78487. /**
  78488. * The raw pose coming from the device.
  78489. */
  78490. rawPose: Nullable<DevicePose>;
  78491. /**
  78492. * The scale of the device to be used when translating from device space to babylon space.
  78493. */
  78494. deviceScaleFactor: number;
  78495. /**
  78496. * Updates the poseControlled values based on the input device pose.
  78497. * @param poseData the pose data to update the object with
  78498. */
  78499. updateFromDevice(poseData: DevicePose): void;
  78500. }
  78501. /**
  78502. * Set of options to customize the webVRCamera
  78503. */
  78504. export interface WebVROptions {
  78505. /**
  78506. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78507. */
  78508. trackPosition?: boolean;
  78509. /**
  78510. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78511. */
  78512. positionScale?: number;
  78513. /**
  78514. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78515. */
  78516. displayName?: string;
  78517. /**
  78518. * Should the native controller meshes be initialized. (default: true)
  78519. */
  78520. controllerMeshes?: boolean;
  78521. /**
  78522. * Creating a default HemiLight only on controllers. (default: true)
  78523. */
  78524. defaultLightingOnControllers?: boolean;
  78525. /**
  78526. * If you don't want to use the default VR button of the helper. (default: false)
  78527. */
  78528. useCustomVRButton?: boolean;
  78529. /**
  78530. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78531. */
  78532. customVRButton?: HTMLButtonElement;
  78533. /**
  78534. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78535. */
  78536. rayLength?: number;
  78537. /**
  78538. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78539. */
  78540. defaultHeight?: number;
  78541. /**
  78542. * If multiview should be used if availible (default: false)
  78543. */
  78544. useMultiview?: boolean;
  78545. }
  78546. /**
  78547. * This represents a WebVR camera.
  78548. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78549. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78550. */
  78551. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78552. private webVROptions;
  78553. /**
  78554. * @hidden
  78555. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78556. */
  78557. _vrDevice: any;
  78558. /**
  78559. * The rawPose of the vrDevice.
  78560. */
  78561. rawPose: Nullable<DevicePose>;
  78562. private _onVREnabled;
  78563. private _specsVersion;
  78564. private _attached;
  78565. private _frameData;
  78566. protected _descendants: Array<Node>;
  78567. private _deviceRoomPosition;
  78568. /** @hidden */
  78569. _deviceRoomRotationQuaternion: Quaternion;
  78570. private _standingMatrix;
  78571. /**
  78572. * Represents device position in babylon space.
  78573. */
  78574. devicePosition: Vector3;
  78575. /**
  78576. * Represents device rotation in babylon space.
  78577. */
  78578. deviceRotationQuaternion: Quaternion;
  78579. /**
  78580. * The scale of the device to be used when translating from device space to babylon space.
  78581. */
  78582. deviceScaleFactor: number;
  78583. private _deviceToWorld;
  78584. private _worldToDevice;
  78585. /**
  78586. * References to the webVR controllers for the vrDevice.
  78587. */
  78588. controllers: Array<WebVRController>;
  78589. /**
  78590. * Emits an event when a controller is attached.
  78591. */
  78592. onControllersAttachedObservable: Observable<WebVRController[]>;
  78593. /**
  78594. * Emits an event when a controller's mesh has been loaded;
  78595. */
  78596. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78597. /**
  78598. * Emits an event when the HMD's pose has been updated.
  78599. */
  78600. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78601. private _poseSet;
  78602. /**
  78603. * If the rig cameras be used as parent instead of this camera.
  78604. */
  78605. rigParenting: boolean;
  78606. private _lightOnControllers;
  78607. private _defaultHeight?;
  78608. /**
  78609. * Instantiates a WebVRFreeCamera.
  78610. * @param name The name of the WebVRFreeCamera
  78611. * @param position The starting anchor position for the camera
  78612. * @param scene The scene the camera belongs to
  78613. * @param webVROptions a set of customizable options for the webVRCamera
  78614. */
  78615. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78616. /**
  78617. * Gets the device distance from the ground in meters.
  78618. * @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.
  78619. */
  78620. deviceDistanceToRoomGround(): number;
  78621. /**
  78622. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78623. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78624. */
  78625. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78626. /**
  78627. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78628. * @returns A promise with a boolean set to if the standing matrix is supported.
  78629. */
  78630. useStandingMatrixAsync(): Promise<boolean>;
  78631. /**
  78632. * Disposes the camera
  78633. */
  78634. dispose(): void;
  78635. /**
  78636. * Gets a vrController by name.
  78637. * @param name The name of the controller to retreive
  78638. * @returns the controller matching the name specified or null if not found
  78639. */
  78640. getControllerByName(name: string): Nullable<WebVRController>;
  78641. private _leftController;
  78642. /**
  78643. * The controller corresponding to the users left hand.
  78644. */
  78645. readonly leftController: Nullable<WebVRController>;
  78646. private _rightController;
  78647. /**
  78648. * The controller corresponding to the users right hand.
  78649. */
  78650. readonly rightController: Nullable<WebVRController>;
  78651. /**
  78652. * Casts a ray forward from the vrCamera's gaze.
  78653. * @param length Length of the ray (default: 100)
  78654. * @returns the ray corresponding to the gaze
  78655. */
  78656. getForwardRay(length?: number): Ray;
  78657. /**
  78658. * @hidden
  78659. * Updates the camera based on device's frame data
  78660. */
  78661. _checkInputs(): void;
  78662. /**
  78663. * Updates the poseControlled values based on the input device pose.
  78664. * @param poseData Pose coming from the device
  78665. */
  78666. updateFromDevice(poseData: DevicePose): void;
  78667. private _htmlElementAttached;
  78668. private _detachIfAttached;
  78669. /**
  78670. * WebVR's attach control will start broadcasting frames to the device.
  78671. * Note that in certain browsers (chrome for example) this function must be called
  78672. * within a user-interaction callback. Example:
  78673. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78674. *
  78675. * @param element html element to attach the vrDevice to
  78676. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78677. */
  78678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78679. /**
  78680. * Detaches the camera from the html element and disables VR
  78681. *
  78682. * @param element html element to detach from
  78683. */
  78684. detachControl(element: HTMLElement): void;
  78685. /**
  78686. * @returns the name of this class
  78687. */
  78688. getClassName(): string;
  78689. /**
  78690. * Calls resetPose on the vrDisplay
  78691. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78692. */
  78693. resetToCurrentRotation(): void;
  78694. /**
  78695. * @hidden
  78696. * Updates the rig cameras (left and right eye)
  78697. */
  78698. _updateRigCameras(): void;
  78699. private _workingVector;
  78700. private _oneVector;
  78701. private _workingMatrix;
  78702. private updateCacheCalled;
  78703. private _correctPositionIfNotTrackPosition;
  78704. /**
  78705. * @hidden
  78706. * Updates the cached values of the camera
  78707. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78708. */
  78709. _updateCache(ignoreParentClass?: boolean): void;
  78710. /**
  78711. * @hidden
  78712. * Get current device position in babylon world
  78713. */
  78714. _computeDevicePosition(): void;
  78715. /**
  78716. * Updates the current device position and rotation in the babylon world
  78717. */
  78718. update(): void;
  78719. /**
  78720. * @hidden
  78721. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78722. * @returns an identity matrix
  78723. */
  78724. _getViewMatrix(): Matrix;
  78725. private _tmpMatrix;
  78726. /**
  78727. * This function is called by the two RIG cameras.
  78728. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78729. * @hidden
  78730. */
  78731. _getWebVRViewMatrix(): Matrix;
  78732. /** @hidden */
  78733. _getWebVRProjectionMatrix(): Matrix;
  78734. private _onGamepadConnectedObserver;
  78735. private _onGamepadDisconnectedObserver;
  78736. private _updateCacheWhenTrackingDisabledObserver;
  78737. /**
  78738. * Initializes the controllers and their meshes
  78739. */
  78740. initControllers(): void;
  78741. }
  78742. }
  78743. declare module BABYLON {
  78744. /**
  78745. * Size options for a post process
  78746. */
  78747. export type PostProcessOptions = {
  78748. width: number;
  78749. height: number;
  78750. };
  78751. /**
  78752. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78753. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78754. */
  78755. export class PostProcess {
  78756. /** Name of the PostProcess. */
  78757. name: string;
  78758. /**
  78759. * Gets or sets the unique id of the post process
  78760. */
  78761. uniqueId: number;
  78762. /**
  78763. * Width of the texture to apply the post process on
  78764. */
  78765. width: number;
  78766. /**
  78767. * Height of the texture to apply the post process on
  78768. */
  78769. height: number;
  78770. /**
  78771. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78772. * @hidden
  78773. */
  78774. _outputTexture: Nullable<InternalTexture>;
  78775. /**
  78776. * Sampling mode used by the shader
  78777. * See https://doc.babylonjs.com/classes/3.1/texture
  78778. */
  78779. renderTargetSamplingMode: number;
  78780. /**
  78781. * Clear color to use when screen clearing
  78782. */
  78783. clearColor: Color4;
  78784. /**
  78785. * If the buffer needs to be cleared before applying the post process. (default: true)
  78786. * Should be set to false if shader will overwrite all previous pixels.
  78787. */
  78788. autoClear: boolean;
  78789. /**
  78790. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78791. */
  78792. alphaMode: number;
  78793. /**
  78794. * Sets the setAlphaBlendConstants of the babylon engine
  78795. */
  78796. alphaConstants: Color4;
  78797. /**
  78798. * Animations to be used for the post processing
  78799. */
  78800. animations: Animation[];
  78801. /**
  78802. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78803. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78804. */
  78805. enablePixelPerfectMode: boolean;
  78806. /**
  78807. * Force the postprocess to be applied without taking in account viewport
  78808. */
  78809. forceFullscreenViewport: boolean;
  78810. /**
  78811. * List of inspectable custom properties (used by the Inspector)
  78812. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78813. */
  78814. inspectableCustomProperties: IInspectable[];
  78815. /**
  78816. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78817. *
  78818. * | Value | Type | Description |
  78819. * | ----- | ----------------------------------- | ----------- |
  78820. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78821. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78822. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78823. *
  78824. */
  78825. scaleMode: number;
  78826. /**
  78827. * Force textures to be a power of two (default: false)
  78828. */
  78829. alwaysForcePOT: boolean;
  78830. private _samples;
  78831. /**
  78832. * Number of sample textures (default: 1)
  78833. */
  78834. samples: number;
  78835. /**
  78836. * Modify the scale of the post process to be the same as the viewport (default: false)
  78837. */
  78838. adaptScaleToCurrentViewport: boolean;
  78839. private _camera;
  78840. private _scene;
  78841. private _engine;
  78842. private _options;
  78843. private _reusable;
  78844. private _textureType;
  78845. /**
  78846. * Smart array of input and output textures for the post process.
  78847. * @hidden
  78848. */
  78849. _textures: SmartArray<InternalTexture>;
  78850. /**
  78851. * The index in _textures that corresponds to the output texture.
  78852. * @hidden
  78853. */
  78854. _currentRenderTextureInd: number;
  78855. private _effect;
  78856. private _samplers;
  78857. private _fragmentUrl;
  78858. private _vertexUrl;
  78859. private _parameters;
  78860. private _scaleRatio;
  78861. protected _indexParameters: any;
  78862. private _shareOutputWithPostProcess;
  78863. private _texelSize;
  78864. private _forcedOutputTexture;
  78865. /**
  78866. * Returns the fragment url or shader name used in the post process.
  78867. * @returns the fragment url or name in the shader store.
  78868. */
  78869. getEffectName(): string;
  78870. /**
  78871. * An event triggered when the postprocess is activated.
  78872. */
  78873. onActivateObservable: Observable<Camera>;
  78874. private _onActivateObserver;
  78875. /**
  78876. * A function that is added to the onActivateObservable
  78877. */
  78878. onActivate: Nullable<(camera: Camera) => void>;
  78879. /**
  78880. * An event triggered when the postprocess changes its size.
  78881. */
  78882. onSizeChangedObservable: Observable<PostProcess>;
  78883. private _onSizeChangedObserver;
  78884. /**
  78885. * A function that is added to the onSizeChangedObservable
  78886. */
  78887. onSizeChanged: (postProcess: PostProcess) => void;
  78888. /**
  78889. * An event triggered when the postprocess applies its effect.
  78890. */
  78891. onApplyObservable: Observable<Effect>;
  78892. private _onApplyObserver;
  78893. /**
  78894. * A function that is added to the onApplyObservable
  78895. */
  78896. onApply: (effect: Effect) => void;
  78897. /**
  78898. * An event triggered before rendering the postprocess
  78899. */
  78900. onBeforeRenderObservable: Observable<Effect>;
  78901. private _onBeforeRenderObserver;
  78902. /**
  78903. * A function that is added to the onBeforeRenderObservable
  78904. */
  78905. onBeforeRender: (effect: Effect) => void;
  78906. /**
  78907. * An event triggered after rendering the postprocess
  78908. */
  78909. onAfterRenderObservable: Observable<Effect>;
  78910. private _onAfterRenderObserver;
  78911. /**
  78912. * A function that is added to the onAfterRenderObservable
  78913. */
  78914. onAfterRender: (efect: Effect) => void;
  78915. /**
  78916. * 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
  78917. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  78918. */
  78919. inputTexture: InternalTexture;
  78920. /**
  78921. * Gets the camera which post process is applied to.
  78922. * @returns The camera the post process is applied to.
  78923. */
  78924. getCamera(): Camera;
  78925. /**
  78926. * Gets the texel size of the postprocess.
  78927. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  78928. */
  78929. readonly texelSize: Vector2;
  78930. /**
  78931. * Creates a new instance PostProcess
  78932. * @param name The name of the PostProcess.
  78933. * @param fragmentUrl The url of the fragment shader to be used.
  78934. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  78935. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  78936. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78937. * @param camera The camera to apply the render pass to.
  78938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78939. * @param engine The engine which the post process will be applied. (default: current engine)
  78940. * @param reusable If the post process can be reused on the same frame. (default: false)
  78941. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  78942. * @param textureType Type of textures used when performing the post process. (default: 0)
  78943. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  78944. * @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
  78945. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  78946. */
  78947. constructor(
  78948. /** Name of the PostProcess. */
  78949. 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);
  78950. /**
  78951. * Gets a string idenfifying the name of the class
  78952. * @returns "PostProcess" string
  78953. */
  78954. getClassName(): string;
  78955. /**
  78956. * Gets the engine which this post process belongs to.
  78957. * @returns The engine the post process was enabled with.
  78958. */
  78959. getEngine(): Engine;
  78960. /**
  78961. * The effect that is created when initializing the post process.
  78962. * @returns The created effect corresponding the the postprocess.
  78963. */
  78964. getEffect(): Effect;
  78965. /**
  78966. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  78967. * @param postProcess The post process to share the output with.
  78968. * @returns This post process.
  78969. */
  78970. shareOutputWith(postProcess: PostProcess): PostProcess;
  78971. /**
  78972. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  78973. * This should be called if the post process that shares output with this post process is disabled/disposed.
  78974. */
  78975. useOwnOutput(): void;
  78976. /**
  78977. * Updates the effect with the current post process compile time values and recompiles the shader.
  78978. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78979. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78980. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78981. * @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
  78982. * @param onCompiled Called when the shader has been compiled.
  78983. * @param onError Called if there is an error when compiling a shader.
  78984. */
  78985. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78986. /**
  78987. * The post process is reusable if it can be used multiple times within one frame.
  78988. * @returns If the post process is reusable
  78989. */
  78990. isReusable(): boolean;
  78991. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  78992. markTextureDirty(): void;
  78993. /**
  78994. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  78995. * 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.
  78996. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  78997. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  78998. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  78999. * @returns The target texture that was bound to be written to.
  79000. */
  79001. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  79002. /**
  79003. * If the post process is supported.
  79004. */
  79005. readonly isSupported: boolean;
  79006. /**
  79007. * The aspect ratio of the output texture.
  79008. */
  79009. readonly aspectRatio: number;
  79010. /**
  79011. * Get a value indicating if the post-process is ready to be used
  79012. * @returns true if the post-process is ready (shader is compiled)
  79013. */
  79014. isReady(): boolean;
  79015. /**
  79016. * Binds all textures and uniforms to the shader, this will be run on every pass.
  79017. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  79018. */
  79019. apply(): Nullable<Effect>;
  79020. private _disposeTextures;
  79021. /**
  79022. * Disposes the post process.
  79023. * @param camera The camera to dispose the post process on.
  79024. */
  79025. dispose(camera?: Camera): void;
  79026. }
  79027. }
  79028. declare module BABYLON {
  79029. /** @hidden */
  79030. export var kernelBlurVaryingDeclaration: {
  79031. name: string;
  79032. shader: string;
  79033. };
  79034. }
  79035. declare module BABYLON {
  79036. /** @hidden */
  79037. export var kernelBlurFragment: {
  79038. name: string;
  79039. shader: string;
  79040. };
  79041. }
  79042. declare module BABYLON {
  79043. /** @hidden */
  79044. export var kernelBlurFragment2: {
  79045. name: string;
  79046. shader: string;
  79047. };
  79048. }
  79049. declare module BABYLON {
  79050. /** @hidden */
  79051. export var kernelBlurPixelShader: {
  79052. name: string;
  79053. shader: string;
  79054. };
  79055. }
  79056. declare module BABYLON {
  79057. /** @hidden */
  79058. export var kernelBlurVertex: {
  79059. name: string;
  79060. shader: string;
  79061. };
  79062. }
  79063. declare module BABYLON {
  79064. /** @hidden */
  79065. export var kernelBlurVertexShader: {
  79066. name: string;
  79067. shader: string;
  79068. };
  79069. }
  79070. declare module BABYLON {
  79071. /**
  79072. * The Blur Post Process which blurs an image based on a kernel and direction.
  79073. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79074. */
  79075. export class BlurPostProcess extends PostProcess {
  79076. /** The direction in which to blur the image. */
  79077. direction: Vector2;
  79078. private blockCompilation;
  79079. protected _kernel: number;
  79080. protected _idealKernel: number;
  79081. protected _packedFloat: boolean;
  79082. private _staticDefines;
  79083. /**
  79084. * Sets the length in pixels of the blur sample region
  79085. */
  79086. /**
  79087. * Gets the length in pixels of the blur sample region
  79088. */
  79089. kernel: number;
  79090. /**
  79091. * Sets wether or not the blur needs to unpack/repack floats
  79092. */
  79093. /**
  79094. * Gets wether or not the blur is unpacking/repacking floats
  79095. */
  79096. packedFloat: boolean;
  79097. /**
  79098. * Creates a new instance BlurPostProcess
  79099. * @param name The name of the effect.
  79100. * @param direction The direction in which to blur the image.
  79101. * @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.
  79102. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79103. * @param camera The camera to apply the render pass to.
  79104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79105. * @param engine The engine which the post process will be applied. (default: current engine)
  79106. * @param reusable If the post process can be reused on the same frame. (default: false)
  79107. * @param textureType Type of textures used when performing the post process. (default: 0)
  79108. * @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)
  79109. */
  79110. constructor(name: string,
  79111. /** The direction in which to blur the image. */
  79112. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79113. /**
  79114. * Updates the effect with the current post process compile time values and recompiles the shader.
  79115. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79116. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79117. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79118. * @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
  79119. * @param onCompiled Called when the shader has been compiled.
  79120. * @param onError Called if there is an error when compiling a shader.
  79121. */
  79122. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79123. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79124. /**
  79125. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79126. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79127. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79128. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79129. * The gaps between physical kernels are compensated for in the weighting of the samples
  79130. * @param idealKernel Ideal blur kernel.
  79131. * @return Nearest best kernel.
  79132. */
  79133. protected _nearestBestKernel(idealKernel: number): number;
  79134. /**
  79135. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79136. * @param x The point on the Gaussian distribution to sample.
  79137. * @return the value of the Gaussian function at x.
  79138. */
  79139. protected _gaussianWeight(x: number): number;
  79140. /**
  79141. * Generates a string that can be used as a floating point number in GLSL.
  79142. * @param x Value to print.
  79143. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79144. * @return GLSL float string.
  79145. */
  79146. protected _glslFloat(x: number, decimalFigures?: number): string;
  79147. }
  79148. }
  79149. declare module BABYLON {
  79150. /**
  79151. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79152. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79153. * You can then easily use it as a reflectionTexture on a flat surface.
  79154. * In case the surface is not a plane, please consider relying on reflection probes.
  79155. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79156. */
  79157. export class MirrorTexture extends RenderTargetTexture {
  79158. private scene;
  79159. /**
  79160. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79161. * 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.
  79162. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79163. */
  79164. mirrorPlane: Plane;
  79165. /**
  79166. * Define the blur ratio used to blur the reflection if needed.
  79167. */
  79168. blurRatio: number;
  79169. /**
  79170. * Define the adaptive blur kernel used to blur the reflection if needed.
  79171. * This will autocompute the closest best match for the `blurKernel`
  79172. */
  79173. adaptiveBlurKernel: number;
  79174. /**
  79175. * Define the blur kernel used to blur the reflection if needed.
  79176. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79177. */
  79178. blurKernel: number;
  79179. /**
  79180. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79181. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79182. */
  79183. blurKernelX: number;
  79184. /**
  79185. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79186. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79187. */
  79188. blurKernelY: number;
  79189. private _autoComputeBlurKernel;
  79190. protected _onRatioRescale(): void;
  79191. private _updateGammaSpace;
  79192. private _imageProcessingConfigChangeObserver;
  79193. private _transformMatrix;
  79194. private _mirrorMatrix;
  79195. private _savedViewMatrix;
  79196. private _blurX;
  79197. private _blurY;
  79198. private _adaptiveBlurKernel;
  79199. private _blurKernelX;
  79200. private _blurKernelY;
  79201. private _blurRatio;
  79202. /**
  79203. * Instantiates a Mirror Texture.
  79204. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79205. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79206. * You can then easily use it as a reflectionTexture on a flat surface.
  79207. * In case the surface is not a plane, please consider relying on reflection probes.
  79208. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79209. * @param name
  79210. * @param size
  79211. * @param scene
  79212. * @param generateMipMaps
  79213. * @param type
  79214. * @param samplingMode
  79215. * @param generateDepthBuffer
  79216. */
  79217. constructor(name: string, size: number | {
  79218. width: number;
  79219. height: number;
  79220. } | {
  79221. ratio: number;
  79222. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79223. private _preparePostProcesses;
  79224. /**
  79225. * Clone the mirror texture.
  79226. * @returns the cloned texture
  79227. */
  79228. clone(): MirrorTexture;
  79229. /**
  79230. * Serialize the texture to a JSON representation you could use in Parse later on
  79231. * @returns the serialized JSON representation
  79232. */
  79233. serialize(): any;
  79234. /**
  79235. * Dispose the texture and release its associated resources.
  79236. */
  79237. dispose(): void;
  79238. }
  79239. }
  79240. declare module BABYLON {
  79241. /**
  79242. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79243. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79244. */
  79245. export class Texture extends BaseTexture {
  79246. /** @hidden */
  79247. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79248. /** @hidden */
  79249. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79250. /** @hidden */
  79251. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79252. /** nearest is mag = nearest and min = nearest and mip = linear */
  79253. static readonly NEAREST_SAMPLINGMODE: number;
  79254. /** nearest is mag = nearest and min = nearest and mip = linear */
  79255. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79256. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79257. static readonly BILINEAR_SAMPLINGMODE: number;
  79258. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79259. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79260. /** Trilinear is mag = linear and min = linear and mip = linear */
  79261. static readonly TRILINEAR_SAMPLINGMODE: number;
  79262. /** Trilinear is mag = linear and min = linear and mip = linear */
  79263. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79264. /** mag = nearest and min = nearest and mip = nearest */
  79265. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79266. /** mag = nearest and min = linear and mip = nearest */
  79267. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79268. /** mag = nearest and min = linear and mip = linear */
  79269. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79270. /** mag = nearest and min = linear and mip = none */
  79271. static readonly NEAREST_LINEAR: number;
  79272. /** mag = nearest and min = nearest and mip = none */
  79273. static readonly NEAREST_NEAREST: number;
  79274. /** mag = linear and min = nearest and mip = nearest */
  79275. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79276. /** mag = linear and min = nearest and mip = linear */
  79277. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79278. /** mag = linear and min = linear and mip = none */
  79279. static readonly LINEAR_LINEAR: number;
  79280. /** mag = linear and min = nearest and mip = none */
  79281. static readonly LINEAR_NEAREST: number;
  79282. /** Explicit coordinates mode */
  79283. static readonly EXPLICIT_MODE: number;
  79284. /** Spherical coordinates mode */
  79285. static readonly SPHERICAL_MODE: number;
  79286. /** Planar coordinates mode */
  79287. static readonly PLANAR_MODE: number;
  79288. /** Cubic coordinates mode */
  79289. static readonly CUBIC_MODE: number;
  79290. /** Projection coordinates mode */
  79291. static readonly PROJECTION_MODE: number;
  79292. /** Inverse Cubic coordinates mode */
  79293. static readonly SKYBOX_MODE: number;
  79294. /** Inverse Cubic coordinates mode */
  79295. static readonly INVCUBIC_MODE: number;
  79296. /** Equirectangular coordinates mode */
  79297. static readonly EQUIRECTANGULAR_MODE: number;
  79298. /** Equirectangular Fixed coordinates mode */
  79299. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79300. /** Equirectangular Fixed Mirrored coordinates mode */
  79301. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79302. /** Texture is not repeating outside of 0..1 UVs */
  79303. static readonly CLAMP_ADDRESSMODE: number;
  79304. /** Texture is repeating outside of 0..1 UVs */
  79305. static readonly WRAP_ADDRESSMODE: number;
  79306. /** Texture is repeating and mirrored */
  79307. static readonly MIRROR_ADDRESSMODE: number;
  79308. /**
  79309. * 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
  79310. */
  79311. static UseSerializedUrlIfAny: boolean;
  79312. /**
  79313. * Define the url of the texture.
  79314. */
  79315. url: Nullable<string>;
  79316. /**
  79317. * Define an offset on the texture to offset the u coordinates of the UVs
  79318. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79319. */
  79320. uOffset: number;
  79321. /**
  79322. * Define an offset on the texture to offset the v coordinates of the UVs
  79323. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79324. */
  79325. vOffset: number;
  79326. /**
  79327. * Define an offset on the texture to scale the u coordinates of the UVs
  79328. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79329. */
  79330. uScale: number;
  79331. /**
  79332. * Define an offset on the texture to scale the v coordinates of the UVs
  79333. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79334. */
  79335. vScale: number;
  79336. /**
  79337. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79338. * @see http://doc.babylonjs.com/how_to/more_materials
  79339. */
  79340. uAng: number;
  79341. /**
  79342. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79343. * @see http://doc.babylonjs.com/how_to/more_materials
  79344. */
  79345. vAng: number;
  79346. /**
  79347. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79348. * @see http://doc.babylonjs.com/how_to/more_materials
  79349. */
  79350. wAng: number;
  79351. /**
  79352. * Defines the center of rotation (U)
  79353. */
  79354. uRotationCenter: number;
  79355. /**
  79356. * Defines the center of rotation (V)
  79357. */
  79358. vRotationCenter: number;
  79359. /**
  79360. * Defines the center of rotation (W)
  79361. */
  79362. wRotationCenter: number;
  79363. /**
  79364. * Are mip maps generated for this texture or not.
  79365. */
  79366. readonly noMipmap: boolean;
  79367. /**
  79368. * List of inspectable custom properties (used by the Inspector)
  79369. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79370. */
  79371. inspectableCustomProperties: Nullable<IInspectable[]>;
  79372. private _noMipmap;
  79373. /** @hidden */
  79374. _invertY: boolean;
  79375. private _rowGenerationMatrix;
  79376. private _cachedTextureMatrix;
  79377. private _projectionModeMatrix;
  79378. private _t0;
  79379. private _t1;
  79380. private _t2;
  79381. private _cachedUOffset;
  79382. private _cachedVOffset;
  79383. private _cachedUScale;
  79384. private _cachedVScale;
  79385. private _cachedUAng;
  79386. private _cachedVAng;
  79387. private _cachedWAng;
  79388. private _cachedProjectionMatrixId;
  79389. private _cachedCoordinatesMode;
  79390. /** @hidden */
  79391. protected _initialSamplingMode: number;
  79392. /** @hidden */
  79393. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79394. private _deleteBuffer;
  79395. protected _format: Nullable<number>;
  79396. private _delayedOnLoad;
  79397. private _delayedOnError;
  79398. /**
  79399. * Observable triggered once the texture has been loaded.
  79400. */
  79401. onLoadObservable: Observable<Texture>;
  79402. protected _isBlocking: boolean;
  79403. /**
  79404. * Is the texture preventing material to render while loading.
  79405. * If false, a default texture will be used instead of the loading one during the preparation step.
  79406. */
  79407. isBlocking: boolean;
  79408. /**
  79409. * Get the current sampling mode associated with the texture.
  79410. */
  79411. readonly samplingMode: number;
  79412. /**
  79413. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79414. */
  79415. readonly invertY: boolean;
  79416. /**
  79417. * Instantiates a new texture.
  79418. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79419. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79420. * @param url define the url of the picture to load as a texture
  79421. * @param scene define the scene or engine the texture will belong to
  79422. * @param noMipmap define if the texture will require mip maps or not
  79423. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79424. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79425. * @param onLoad define a callback triggered when the texture has been loaded
  79426. * @param onError define a callback triggered when an error occurred during the loading session
  79427. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79428. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79429. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79430. */
  79431. 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);
  79432. /**
  79433. * Update the url (and optional buffer) of this texture if url was null during construction.
  79434. * @param url the url of the texture
  79435. * @param buffer the buffer of the texture (defaults to null)
  79436. * @param onLoad callback called when the texture is loaded (defaults to null)
  79437. */
  79438. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79439. /**
  79440. * Finish the loading sequence of a texture flagged as delayed load.
  79441. * @hidden
  79442. */
  79443. delayLoad(): void;
  79444. private _prepareRowForTextureGeneration;
  79445. /**
  79446. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79447. * @returns the transform matrix of the texture.
  79448. */
  79449. getTextureMatrix(): Matrix;
  79450. /**
  79451. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79452. * @returns The reflection texture transform
  79453. */
  79454. getReflectionTextureMatrix(): Matrix;
  79455. /**
  79456. * Clones the texture.
  79457. * @returns the cloned texture
  79458. */
  79459. clone(): Texture;
  79460. /**
  79461. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79462. * @returns The JSON representation of the texture
  79463. */
  79464. serialize(): any;
  79465. /**
  79466. * Get the current class name of the texture useful for serialization or dynamic coding.
  79467. * @returns "Texture"
  79468. */
  79469. getClassName(): string;
  79470. /**
  79471. * Dispose the texture and release its associated resources.
  79472. */
  79473. dispose(): void;
  79474. /**
  79475. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79476. * @param parsedTexture Define the JSON representation of the texture
  79477. * @param scene Define the scene the parsed texture should be instantiated in
  79478. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79479. * @returns The parsed texture if successful
  79480. */
  79481. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79482. /**
  79483. * Creates a texture from its base 64 representation.
  79484. * @param data Define the base64 payload without the data: prefix
  79485. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79486. * @param scene Define the scene the texture should belong to
  79487. * @param noMipmap Forces the texture to not create mip map information if true
  79488. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79489. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79490. * @param onLoad define a callback triggered when the texture has been loaded
  79491. * @param onError define a callback triggered when an error occurred during the loading session
  79492. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79493. * @returns the created texture
  79494. */
  79495. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79496. /**
  79497. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79498. * @param data Define the base64 payload without the data: prefix
  79499. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79500. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79501. * @param scene Define the scene the texture should belong to
  79502. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79503. * @param noMipmap Forces the texture to not create mip map information if true
  79504. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79505. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79506. * @param onLoad define a callback triggered when the texture has been loaded
  79507. * @param onError define a callback triggered when an error occurred during the loading session
  79508. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79509. * @returns the created texture
  79510. */
  79511. 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;
  79512. }
  79513. }
  79514. declare module BABYLON {
  79515. /**
  79516. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79517. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79518. */
  79519. export class PostProcessManager {
  79520. private _scene;
  79521. private _indexBuffer;
  79522. private _vertexBuffers;
  79523. /**
  79524. * Creates a new instance PostProcess
  79525. * @param scene The scene that the post process is associated with.
  79526. */
  79527. constructor(scene: Scene);
  79528. private _prepareBuffers;
  79529. private _buildIndexBuffer;
  79530. /**
  79531. * Rebuilds the vertex buffers of the manager.
  79532. * @hidden
  79533. */
  79534. _rebuild(): void;
  79535. /**
  79536. * Prepares a frame to be run through a post process.
  79537. * @param sourceTexture The input texture to the post procesess. (default: null)
  79538. * @param postProcesses An array of post processes to be run. (default: null)
  79539. * @returns True if the post processes were able to be run.
  79540. * @hidden
  79541. */
  79542. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79543. /**
  79544. * Manually render a set of post processes to a texture.
  79545. * @param postProcesses An array of post processes to be run.
  79546. * @param targetTexture The target texture to render to.
  79547. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79548. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79549. * @param lodLevel defines which lod of the texture to render to
  79550. */
  79551. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79552. /**
  79553. * Finalize the result of the output of the postprocesses.
  79554. * @param doNotPresent If true the result will not be displayed to the screen.
  79555. * @param targetTexture The target texture to render to.
  79556. * @param faceIndex The index of the face to bind the target texture to.
  79557. * @param postProcesses The array of post processes to render.
  79558. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79559. * @hidden
  79560. */
  79561. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79562. /**
  79563. * Disposes of the post process manager.
  79564. */
  79565. dispose(): void;
  79566. }
  79567. }
  79568. declare module BABYLON {
  79569. /** Interface used by value gradients (color, factor, ...) */
  79570. export interface IValueGradient {
  79571. /**
  79572. * Gets or sets the gradient value (between 0 and 1)
  79573. */
  79574. gradient: number;
  79575. }
  79576. /** Class used to store color4 gradient */
  79577. export class ColorGradient implements IValueGradient {
  79578. /**
  79579. * Gets or sets the gradient value (between 0 and 1)
  79580. */
  79581. gradient: number;
  79582. /**
  79583. * Gets or sets first associated color
  79584. */
  79585. color1: Color4;
  79586. /**
  79587. * Gets or sets second associated color
  79588. */
  79589. color2?: Color4;
  79590. /**
  79591. * Will get a color picked randomly between color1 and color2.
  79592. * If color2 is undefined then color1 will be used
  79593. * @param result defines the target Color4 to store the result in
  79594. */
  79595. getColorToRef(result: Color4): void;
  79596. }
  79597. /** Class used to store color 3 gradient */
  79598. export class Color3Gradient implements IValueGradient {
  79599. /**
  79600. * Gets or sets the gradient value (between 0 and 1)
  79601. */
  79602. gradient: number;
  79603. /**
  79604. * Gets or sets the associated color
  79605. */
  79606. color: Color3;
  79607. }
  79608. /** Class used to store factor gradient */
  79609. export class FactorGradient implements IValueGradient {
  79610. /**
  79611. * Gets or sets the gradient value (between 0 and 1)
  79612. */
  79613. gradient: number;
  79614. /**
  79615. * Gets or sets first associated factor
  79616. */
  79617. factor1: number;
  79618. /**
  79619. * Gets or sets second associated factor
  79620. */
  79621. factor2?: number;
  79622. /**
  79623. * Will get a number picked randomly between factor1 and factor2.
  79624. * If factor2 is undefined then factor1 will be used
  79625. * @returns the picked number
  79626. */
  79627. getFactor(): number;
  79628. }
  79629. /**
  79630. * Helper used to simplify some generic gradient tasks
  79631. */
  79632. export class GradientHelper {
  79633. /**
  79634. * Gets the current gradient from an array of IValueGradient
  79635. * @param ratio defines the current ratio to get
  79636. * @param gradients defines the array of IValueGradient
  79637. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79638. */
  79639. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79640. }
  79641. }
  79642. declare module BABYLON {
  79643. interface AbstractScene {
  79644. /**
  79645. * The list of procedural textures added to the scene
  79646. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79647. */
  79648. proceduralTextures: Array<ProceduralTexture>;
  79649. }
  79650. /**
  79651. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79652. * in a given scene.
  79653. */
  79654. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79655. /**
  79656. * The component name helpfull to identify the component in the list of scene components.
  79657. */
  79658. readonly name: string;
  79659. /**
  79660. * The scene the component belongs to.
  79661. */
  79662. scene: Scene;
  79663. /**
  79664. * Creates a new instance of the component for the given scene
  79665. * @param scene Defines the scene to register the component in
  79666. */
  79667. constructor(scene: Scene);
  79668. /**
  79669. * Registers the component in a given scene
  79670. */
  79671. register(): void;
  79672. /**
  79673. * Rebuilds the elements related to this component in case of
  79674. * context lost for instance.
  79675. */
  79676. rebuild(): void;
  79677. /**
  79678. * Disposes the component and the associated ressources.
  79679. */
  79680. dispose(): void;
  79681. private _beforeClear;
  79682. }
  79683. }
  79684. declare module BABYLON {
  79685. interface Engine {
  79686. /**
  79687. * Creates a new render target cube texture
  79688. * @param size defines the size of the texture
  79689. * @param options defines the options used to create the texture
  79690. * @returns a new render target cube texture stored in an InternalTexture
  79691. */
  79692. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79693. }
  79694. }
  79695. declare module BABYLON {
  79696. /** @hidden */
  79697. export var proceduralVertexShader: {
  79698. name: string;
  79699. shader: string;
  79700. };
  79701. }
  79702. declare module BABYLON {
  79703. /**
  79704. * 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.
  79705. * This is the base class of any Procedural texture and contains most of the shareable code.
  79706. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79707. */
  79708. export class ProceduralTexture extends Texture {
  79709. isCube: boolean;
  79710. /**
  79711. * Define if the texture is enabled or not (disabled texture will not render)
  79712. */
  79713. isEnabled: boolean;
  79714. /**
  79715. * Define if the texture must be cleared before rendering (default is true)
  79716. */
  79717. autoClear: boolean;
  79718. /**
  79719. * Callback called when the texture is generated
  79720. */
  79721. onGenerated: () => void;
  79722. /**
  79723. * Event raised when the texture is generated
  79724. */
  79725. onGeneratedObservable: Observable<ProceduralTexture>;
  79726. /** @hidden */
  79727. _generateMipMaps: boolean;
  79728. /** @hidden **/
  79729. _effect: Effect;
  79730. /** @hidden */
  79731. _textures: {
  79732. [key: string]: Texture;
  79733. };
  79734. private _size;
  79735. private _currentRefreshId;
  79736. private _refreshRate;
  79737. private _vertexBuffers;
  79738. private _indexBuffer;
  79739. private _uniforms;
  79740. private _samplers;
  79741. private _fragment;
  79742. private _floats;
  79743. private _ints;
  79744. private _floatsArrays;
  79745. private _colors3;
  79746. private _colors4;
  79747. private _vectors2;
  79748. private _vectors3;
  79749. private _matrices;
  79750. private _fallbackTexture;
  79751. private _fallbackTextureUsed;
  79752. private _engine;
  79753. private _cachedDefines;
  79754. private _contentUpdateId;
  79755. private _contentData;
  79756. /**
  79757. * Instantiates a new procedural texture.
  79758. * 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.
  79759. * This is the base class of any Procedural texture and contains most of the shareable code.
  79760. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79761. * @param name Define the name of the texture
  79762. * @param size Define the size of the texture to create
  79763. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79764. * @param scene Define the scene the texture belongs to
  79765. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79766. * @param generateMipMaps Define if the texture should creates mip maps or not
  79767. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79768. */
  79769. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79770. /**
  79771. * The effect that is created when initializing the post process.
  79772. * @returns The created effect corresponding the the postprocess.
  79773. */
  79774. getEffect(): Effect;
  79775. /**
  79776. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79777. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79778. */
  79779. getContent(): Nullable<ArrayBufferView>;
  79780. private _createIndexBuffer;
  79781. /** @hidden */
  79782. _rebuild(): void;
  79783. /**
  79784. * Resets the texture in order to recreate its associated resources.
  79785. * This can be called in case of context loss
  79786. */
  79787. reset(): void;
  79788. protected _getDefines(): string;
  79789. /**
  79790. * Is the texture ready to be used ? (rendered at least once)
  79791. * @returns true if ready, otherwise, false.
  79792. */
  79793. isReady(): boolean;
  79794. /**
  79795. * Resets the refresh counter of the texture and start bak from scratch.
  79796. * Could be useful to regenerate the texture if it is setup to render only once.
  79797. */
  79798. resetRefreshCounter(): void;
  79799. /**
  79800. * Set the fragment shader to use in order to render the texture.
  79801. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79802. */
  79803. setFragment(fragment: any): void;
  79804. /**
  79805. * Define the refresh rate of the texture or the rendering frequency.
  79806. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79807. */
  79808. refreshRate: number;
  79809. /** @hidden */
  79810. _shouldRender(): boolean;
  79811. /**
  79812. * Get the size the texture is rendering at.
  79813. * @returns the size (texture is always squared)
  79814. */
  79815. getRenderSize(): number;
  79816. /**
  79817. * Resize the texture to new value.
  79818. * @param size Define the new size the texture should have
  79819. * @param generateMipMaps Define whether the new texture should create mip maps
  79820. */
  79821. resize(size: number, generateMipMaps: boolean): void;
  79822. private _checkUniform;
  79823. /**
  79824. * Set a texture in the shader program used to render.
  79825. * @param name Define the name of the uniform samplers as defined in the shader
  79826. * @param texture Define the texture to bind to this sampler
  79827. * @return the texture itself allowing "fluent" like uniform updates
  79828. */
  79829. setTexture(name: string, texture: Texture): ProceduralTexture;
  79830. /**
  79831. * Set a float in the shader.
  79832. * @param name Define the name of the uniform as defined in the shader
  79833. * @param value Define the value to give to the uniform
  79834. * @return the texture itself allowing "fluent" like uniform updates
  79835. */
  79836. setFloat(name: string, value: number): ProceduralTexture;
  79837. /**
  79838. * Set a int in the shader.
  79839. * @param name Define the name of the uniform as defined in the shader
  79840. * @param value Define the value to give to the uniform
  79841. * @return the texture itself allowing "fluent" like uniform updates
  79842. */
  79843. setInt(name: string, value: number): ProceduralTexture;
  79844. /**
  79845. * Set an array of floats in the shader.
  79846. * @param name Define the name of the uniform as defined in the shader
  79847. * @param value Define the value to give to the uniform
  79848. * @return the texture itself allowing "fluent" like uniform updates
  79849. */
  79850. setFloats(name: string, value: number[]): ProceduralTexture;
  79851. /**
  79852. * Set a vec3 in the shader from a Color3.
  79853. * @param name Define the name of the uniform as defined in the shader
  79854. * @param value Define the value to give to the uniform
  79855. * @return the texture itself allowing "fluent" like uniform updates
  79856. */
  79857. setColor3(name: string, value: Color3): ProceduralTexture;
  79858. /**
  79859. * Set a vec4 in the shader from a Color4.
  79860. * @param name Define the name of the uniform as defined in the shader
  79861. * @param value Define the value to give to the uniform
  79862. * @return the texture itself allowing "fluent" like uniform updates
  79863. */
  79864. setColor4(name: string, value: Color4): ProceduralTexture;
  79865. /**
  79866. * Set a vec2 in the shader from a Vector2.
  79867. * @param name Define the name of the uniform as defined in the shader
  79868. * @param value Define the value to give to the uniform
  79869. * @return the texture itself allowing "fluent" like uniform updates
  79870. */
  79871. setVector2(name: string, value: Vector2): ProceduralTexture;
  79872. /**
  79873. * Set a vec3 in the shader from a Vector3.
  79874. * @param name Define the name of the uniform as defined in the shader
  79875. * @param value Define the value to give to the uniform
  79876. * @return the texture itself allowing "fluent" like uniform updates
  79877. */
  79878. setVector3(name: string, value: Vector3): ProceduralTexture;
  79879. /**
  79880. * Set a mat4 in the shader from a MAtrix.
  79881. * @param name Define the name of the uniform as defined in the shader
  79882. * @param value Define the value to give to the uniform
  79883. * @return the texture itself allowing "fluent" like uniform updates
  79884. */
  79885. setMatrix(name: string, value: Matrix): ProceduralTexture;
  79886. /**
  79887. * Render the texture to its associated render target.
  79888. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  79889. */
  79890. render(useCameraPostProcess?: boolean): void;
  79891. /**
  79892. * Clone the texture.
  79893. * @returns the cloned texture
  79894. */
  79895. clone(): ProceduralTexture;
  79896. /**
  79897. * Dispose the texture and release its asoociated resources.
  79898. */
  79899. dispose(): void;
  79900. }
  79901. }
  79902. declare module BABYLON {
  79903. /**
  79904. * This represents the base class for particle system in Babylon.
  79905. * 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.
  79906. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  79907. * @example https://doc.babylonjs.com/babylon101/particles
  79908. */
  79909. export class BaseParticleSystem {
  79910. /**
  79911. * Source color is added to the destination color without alpha affecting the result
  79912. */
  79913. static BLENDMODE_ONEONE: number;
  79914. /**
  79915. * Blend current color and particle color using particle’s alpha
  79916. */
  79917. static BLENDMODE_STANDARD: number;
  79918. /**
  79919. * Add current color and particle color multiplied by particle’s alpha
  79920. */
  79921. static BLENDMODE_ADD: number;
  79922. /**
  79923. * Multiply current color with particle color
  79924. */
  79925. static BLENDMODE_MULTIPLY: number;
  79926. /**
  79927. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  79928. */
  79929. static BLENDMODE_MULTIPLYADD: number;
  79930. /**
  79931. * List of animations used by the particle system.
  79932. */
  79933. animations: Animation[];
  79934. /**
  79935. * The id of the Particle system.
  79936. */
  79937. id: string;
  79938. /**
  79939. * The friendly name of the Particle system.
  79940. */
  79941. name: string;
  79942. /**
  79943. * The rendering group used by the Particle system to chose when to render.
  79944. */
  79945. renderingGroupId: number;
  79946. /**
  79947. * The emitter represents the Mesh or position we are attaching the particle system to.
  79948. */
  79949. emitter: Nullable<AbstractMesh | Vector3>;
  79950. /**
  79951. * The maximum number of particles to emit per frame
  79952. */
  79953. emitRate: number;
  79954. /**
  79955. * If you want to launch only a few particles at once, that can be done, as well.
  79956. */
  79957. manualEmitCount: number;
  79958. /**
  79959. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  79960. */
  79961. updateSpeed: number;
  79962. /**
  79963. * The amount of time the particle system is running (depends of the overall update speed).
  79964. */
  79965. targetStopDuration: number;
  79966. /**
  79967. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  79968. */
  79969. disposeOnStop: boolean;
  79970. /**
  79971. * Minimum power of emitting particles.
  79972. */
  79973. minEmitPower: number;
  79974. /**
  79975. * Maximum power of emitting particles.
  79976. */
  79977. maxEmitPower: number;
  79978. /**
  79979. * Minimum life time of emitting particles.
  79980. */
  79981. minLifeTime: number;
  79982. /**
  79983. * Maximum life time of emitting particles.
  79984. */
  79985. maxLifeTime: number;
  79986. /**
  79987. * Minimum Size of emitting particles.
  79988. */
  79989. minSize: number;
  79990. /**
  79991. * Maximum Size of emitting particles.
  79992. */
  79993. maxSize: number;
  79994. /**
  79995. * Minimum scale of emitting particles on X axis.
  79996. */
  79997. minScaleX: number;
  79998. /**
  79999. * Maximum scale of emitting particles on X axis.
  80000. */
  80001. maxScaleX: number;
  80002. /**
  80003. * Minimum scale of emitting particles on Y axis.
  80004. */
  80005. minScaleY: number;
  80006. /**
  80007. * Maximum scale of emitting particles on Y axis.
  80008. */
  80009. maxScaleY: number;
  80010. /**
  80011. * Gets or sets the minimal initial rotation in radians.
  80012. */
  80013. minInitialRotation: number;
  80014. /**
  80015. * Gets or sets the maximal initial rotation in radians.
  80016. */
  80017. maxInitialRotation: number;
  80018. /**
  80019. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  80020. */
  80021. minAngularSpeed: number;
  80022. /**
  80023. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  80024. */
  80025. maxAngularSpeed: number;
  80026. /**
  80027. * The texture used to render each particle. (this can be a spritesheet)
  80028. */
  80029. particleTexture: Nullable<Texture>;
  80030. /**
  80031. * The layer mask we are rendering the particles through.
  80032. */
  80033. layerMask: number;
  80034. /**
  80035. * This can help using your own shader to render the particle system.
  80036. * The according effect will be created
  80037. */
  80038. customShader: any;
  80039. /**
  80040. * By default particle system starts as soon as they are created. This prevents the
  80041. * automatic start to happen and let you decide when to start emitting particles.
  80042. */
  80043. preventAutoStart: boolean;
  80044. private _noiseTexture;
  80045. /**
  80046. * Gets or sets a texture used to add random noise to particle positions
  80047. */
  80048. noiseTexture: Nullable<ProceduralTexture>;
  80049. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80050. noiseStrength: Vector3;
  80051. /**
  80052. * Callback triggered when the particle animation is ending.
  80053. */
  80054. onAnimationEnd: Nullable<() => void>;
  80055. /**
  80056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80057. */
  80058. blendMode: number;
  80059. /**
  80060. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80061. * to override the particles.
  80062. */
  80063. forceDepthWrite: boolean;
  80064. /** 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 */
  80065. preWarmCycles: number;
  80066. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80067. preWarmStepOffset: number;
  80068. /**
  80069. * 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)
  80070. */
  80071. spriteCellChangeSpeed: number;
  80072. /**
  80073. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80074. */
  80075. startSpriteCellID: number;
  80076. /**
  80077. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80078. */
  80079. endSpriteCellID: number;
  80080. /**
  80081. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80082. */
  80083. spriteCellWidth: number;
  80084. /**
  80085. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80086. */
  80087. spriteCellHeight: number;
  80088. /**
  80089. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80090. */
  80091. spriteRandomStartCell: boolean;
  80092. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80093. translationPivot: Vector2;
  80094. /** @hidden */
  80095. protected _isAnimationSheetEnabled: boolean;
  80096. /**
  80097. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80098. */
  80099. beginAnimationOnStart: boolean;
  80100. /**
  80101. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80102. */
  80103. beginAnimationFrom: number;
  80104. /**
  80105. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80106. */
  80107. beginAnimationTo: number;
  80108. /**
  80109. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80110. */
  80111. beginAnimationLoop: boolean;
  80112. /**
  80113. * Gets or sets a world offset applied to all particles
  80114. */
  80115. worldOffset: Vector3;
  80116. /**
  80117. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80118. */
  80119. isAnimationSheetEnabled: boolean;
  80120. /**
  80121. * Get hosting scene
  80122. * @returns the scene
  80123. */
  80124. getScene(): Scene;
  80125. /**
  80126. * You can use gravity if you want to give an orientation to your particles.
  80127. */
  80128. gravity: Vector3;
  80129. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80130. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80131. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80132. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80133. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80134. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80135. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80136. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80137. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80138. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80139. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80140. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80141. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80142. /**
  80143. * Defines the delay in milliseconds before starting the system (0 by default)
  80144. */
  80145. startDelay: number;
  80146. /**
  80147. * Gets the current list of drag gradients.
  80148. * You must use addDragGradient and removeDragGradient to udpate this list
  80149. * @returns the list of drag gradients
  80150. */
  80151. getDragGradients(): Nullable<Array<FactorGradient>>;
  80152. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80153. limitVelocityDamping: number;
  80154. /**
  80155. * Gets the current list of limit velocity gradients.
  80156. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80157. * @returns the list of limit velocity gradients
  80158. */
  80159. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80160. /**
  80161. * Gets the current list of color gradients.
  80162. * You must use addColorGradient and removeColorGradient to udpate this list
  80163. * @returns the list of color gradients
  80164. */
  80165. getColorGradients(): Nullable<Array<ColorGradient>>;
  80166. /**
  80167. * Gets the current list of size gradients.
  80168. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80169. * @returns the list of size gradients
  80170. */
  80171. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80172. /**
  80173. * Gets the current list of color remap gradients.
  80174. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80175. * @returns the list of color remap gradients
  80176. */
  80177. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80178. /**
  80179. * Gets the current list of alpha remap gradients.
  80180. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80181. * @returns the list of alpha remap gradients
  80182. */
  80183. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80184. /**
  80185. * Gets the current list of life time gradients.
  80186. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80187. * @returns the list of life time gradients
  80188. */
  80189. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80190. /**
  80191. * Gets the current list of angular speed gradients.
  80192. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80193. * @returns the list of angular speed gradients
  80194. */
  80195. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80196. /**
  80197. * Gets the current list of velocity gradients.
  80198. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80199. * @returns the list of velocity gradients
  80200. */
  80201. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80202. /**
  80203. * Gets the current list of start size gradients.
  80204. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80205. * @returns the list of start size gradients
  80206. */
  80207. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80208. /**
  80209. * Gets the current list of emit rate gradients.
  80210. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80211. * @returns the list of emit rate gradients
  80212. */
  80213. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80214. /**
  80215. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80216. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80217. */
  80218. direction1: Vector3;
  80219. /**
  80220. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80221. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80222. */
  80223. direction2: Vector3;
  80224. /**
  80225. * 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.
  80226. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80227. */
  80228. minEmitBox: Vector3;
  80229. /**
  80230. * 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.
  80231. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80232. */
  80233. maxEmitBox: Vector3;
  80234. /**
  80235. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80236. */
  80237. color1: Color4;
  80238. /**
  80239. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80240. */
  80241. color2: Color4;
  80242. /**
  80243. * Color the particle will have at the end of its lifetime
  80244. */
  80245. colorDead: Color4;
  80246. /**
  80247. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80248. */
  80249. textureMask: Color4;
  80250. /**
  80251. * The particle emitter type defines the emitter used by the particle system.
  80252. * It can be for example box, sphere, or cone...
  80253. */
  80254. particleEmitterType: IParticleEmitterType;
  80255. /** @hidden */
  80256. _isSubEmitter: boolean;
  80257. /**
  80258. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80259. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80260. */
  80261. billboardMode: number;
  80262. protected _isBillboardBased: boolean;
  80263. /**
  80264. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80265. */
  80266. isBillboardBased: boolean;
  80267. /**
  80268. * The scene the particle system belongs to.
  80269. */
  80270. protected _scene: Scene;
  80271. /**
  80272. * Local cache of defines for image processing.
  80273. */
  80274. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80275. /**
  80276. * Default configuration related to image processing available in the standard Material.
  80277. */
  80278. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80279. /**
  80280. * Gets the image processing configuration used either in this material.
  80281. */
  80282. /**
  80283. * Sets the Default image processing configuration used either in the this material.
  80284. *
  80285. * If sets to null, the scene one is in use.
  80286. */
  80287. imageProcessingConfiguration: ImageProcessingConfiguration;
  80288. /**
  80289. * Attaches a new image processing configuration to the Standard Material.
  80290. * @param configuration
  80291. */
  80292. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80293. /** @hidden */
  80294. protected _reset(): void;
  80295. /** @hidden */
  80296. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80297. /**
  80298. * Instantiates a particle system.
  80299. * 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.
  80300. * @param name The name of the particle system
  80301. */
  80302. constructor(name: string);
  80303. /**
  80304. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80305. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80306. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80307. * @returns the emitter
  80308. */
  80309. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80310. /**
  80311. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80312. * @param radius The radius of the hemisphere to emit from
  80313. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80314. * @returns the emitter
  80315. */
  80316. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80317. /**
  80318. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80319. * @param radius The radius of the sphere to emit from
  80320. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80321. * @returns the emitter
  80322. */
  80323. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80324. /**
  80325. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80326. * @param radius The radius of the sphere to emit from
  80327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80329. * @returns the emitter
  80330. */
  80331. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80332. /**
  80333. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80334. * @param radius The radius of the emission cylinder
  80335. * @param height The height of the emission cylinder
  80336. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80337. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80338. * @returns the emitter
  80339. */
  80340. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80341. /**
  80342. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80343. * @param radius The radius of the cylinder to emit from
  80344. * @param height The height of the emission cylinder
  80345. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80346. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80347. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80348. * @returns the emitter
  80349. */
  80350. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80351. /**
  80352. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80353. * @param radius The radius of the cone to emit from
  80354. * @param angle The base angle of the cone
  80355. * @returns the emitter
  80356. */
  80357. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80358. /**
  80359. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80360. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80361. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80362. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80363. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80364. * @returns the emitter
  80365. */
  80366. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80367. }
  80368. }
  80369. declare module BABYLON {
  80370. /**
  80371. * Type of sub emitter
  80372. */
  80373. export enum SubEmitterType {
  80374. /**
  80375. * Attached to the particle over it's lifetime
  80376. */
  80377. ATTACHED = 0,
  80378. /**
  80379. * Created when the particle dies
  80380. */
  80381. END = 1
  80382. }
  80383. /**
  80384. * Sub emitter class used to emit particles from an existing particle
  80385. */
  80386. export class SubEmitter {
  80387. /**
  80388. * the particle system to be used by the sub emitter
  80389. */
  80390. particleSystem: ParticleSystem;
  80391. /**
  80392. * Type of the submitter (Default: END)
  80393. */
  80394. type: SubEmitterType;
  80395. /**
  80396. * 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)
  80397. * Note: This only is supported when using an emitter of type Mesh
  80398. */
  80399. inheritDirection: boolean;
  80400. /**
  80401. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80402. */
  80403. inheritedVelocityAmount: number;
  80404. /**
  80405. * Creates a sub emitter
  80406. * @param particleSystem the particle system to be used by the sub emitter
  80407. */
  80408. constructor(
  80409. /**
  80410. * the particle system to be used by the sub emitter
  80411. */
  80412. particleSystem: ParticleSystem);
  80413. /**
  80414. * Clones the sub emitter
  80415. * @returns the cloned sub emitter
  80416. */
  80417. clone(): SubEmitter;
  80418. /**
  80419. * Serialize current object to a JSON object
  80420. * @returns the serialized object
  80421. */
  80422. serialize(): any;
  80423. /** @hidden */
  80424. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80425. /**
  80426. * Creates a new SubEmitter from a serialized JSON version
  80427. * @param serializationObject defines the JSON object to read from
  80428. * @param scene defines the hosting scene
  80429. * @param rootUrl defines the rootUrl for data loading
  80430. * @returns a new SubEmitter
  80431. */
  80432. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80433. /** Release associated resources */
  80434. dispose(): void;
  80435. }
  80436. }
  80437. declare module BABYLON {
  80438. /** @hidden */
  80439. export var clipPlaneFragmentDeclaration: {
  80440. name: string;
  80441. shader: string;
  80442. };
  80443. }
  80444. declare module BABYLON {
  80445. /** @hidden */
  80446. export var imageProcessingDeclaration: {
  80447. name: string;
  80448. shader: string;
  80449. };
  80450. }
  80451. declare module BABYLON {
  80452. /** @hidden */
  80453. export var imageProcessingFunctions: {
  80454. name: string;
  80455. shader: string;
  80456. };
  80457. }
  80458. declare module BABYLON {
  80459. /** @hidden */
  80460. export var clipPlaneFragment: {
  80461. name: string;
  80462. shader: string;
  80463. };
  80464. }
  80465. declare module BABYLON {
  80466. /** @hidden */
  80467. export var particlesPixelShader: {
  80468. name: string;
  80469. shader: string;
  80470. };
  80471. }
  80472. declare module BABYLON {
  80473. /** @hidden */
  80474. export var clipPlaneVertexDeclaration: {
  80475. name: string;
  80476. shader: string;
  80477. };
  80478. }
  80479. declare module BABYLON {
  80480. /** @hidden */
  80481. export var clipPlaneVertex: {
  80482. name: string;
  80483. shader: string;
  80484. };
  80485. }
  80486. declare module BABYLON {
  80487. /** @hidden */
  80488. export var particlesVertexShader: {
  80489. name: string;
  80490. shader: string;
  80491. };
  80492. }
  80493. declare module BABYLON {
  80494. /**
  80495. * This represents a particle system in Babylon.
  80496. * 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.
  80497. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80498. * @example https://doc.babylonjs.com/babylon101/particles
  80499. */
  80500. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80501. /**
  80502. * Billboard mode will only apply to Y axis
  80503. */
  80504. static readonly BILLBOARDMODE_Y: number;
  80505. /**
  80506. * Billboard mode will apply to all axes
  80507. */
  80508. static readonly BILLBOARDMODE_ALL: number;
  80509. /**
  80510. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80511. */
  80512. static readonly BILLBOARDMODE_STRETCHED: number;
  80513. /**
  80514. * This function can be defined to provide custom update for active particles.
  80515. * This function will be called instead of regular update (age, position, color, etc.).
  80516. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80517. */
  80518. updateFunction: (particles: Particle[]) => void;
  80519. private _emitterWorldMatrix;
  80520. /**
  80521. * This function can be defined to specify initial direction for every new particle.
  80522. * It by default use the emitterType defined function
  80523. */
  80524. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80525. /**
  80526. * This function can be defined to specify initial position for every new particle.
  80527. * It by default use the emitterType defined function
  80528. */
  80529. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80530. /**
  80531. * @hidden
  80532. */
  80533. _inheritedVelocityOffset: Vector3;
  80534. /**
  80535. * An event triggered when the system is disposed
  80536. */
  80537. onDisposeObservable: Observable<ParticleSystem>;
  80538. private _onDisposeObserver;
  80539. /**
  80540. * Sets a callback that will be triggered when the system is disposed
  80541. */
  80542. onDispose: () => void;
  80543. private _particles;
  80544. private _epsilon;
  80545. private _capacity;
  80546. private _stockParticles;
  80547. private _newPartsExcess;
  80548. private _vertexData;
  80549. private _vertexBuffer;
  80550. private _vertexBuffers;
  80551. private _spriteBuffer;
  80552. private _indexBuffer;
  80553. private _effect;
  80554. private _customEffect;
  80555. private _cachedDefines;
  80556. private _scaledColorStep;
  80557. private _colorDiff;
  80558. private _scaledDirection;
  80559. private _scaledGravity;
  80560. private _currentRenderId;
  80561. private _alive;
  80562. private _useInstancing;
  80563. private _started;
  80564. private _stopped;
  80565. private _actualFrame;
  80566. private _scaledUpdateSpeed;
  80567. private _vertexBufferSize;
  80568. /** @hidden */
  80569. _currentEmitRateGradient: Nullable<FactorGradient>;
  80570. /** @hidden */
  80571. _currentEmitRate1: number;
  80572. /** @hidden */
  80573. _currentEmitRate2: number;
  80574. /** @hidden */
  80575. _currentStartSizeGradient: Nullable<FactorGradient>;
  80576. /** @hidden */
  80577. _currentStartSize1: number;
  80578. /** @hidden */
  80579. _currentStartSize2: number;
  80580. private readonly _rawTextureWidth;
  80581. private _rampGradientsTexture;
  80582. private _useRampGradients;
  80583. /** Gets or sets a boolean indicating that ramp gradients must be used
  80584. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80585. */
  80586. useRampGradients: boolean;
  80587. /**
  80588. * 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.
  80589. * 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: [])
  80590. */
  80591. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80592. private _subEmitters;
  80593. /**
  80594. * @hidden
  80595. * If the particle systems emitter should be disposed when the particle system is disposed
  80596. */
  80597. _disposeEmitterOnDispose: boolean;
  80598. /**
  80599. * The current active Sub-systems, this property is used by the root particle system only.
  80600. */
  80601. activeSubSystems: Array<ParticleSystem>;
  80602. private _rootParticleSystem;
  80603. /**
  80604. * Gets the current list of active particles
  80605. */
  80606. readonly particles: Particle[];
  80607. /**
  80608. * Returns the string "ParticleSystem"
  80609. * @returns a string containing the class name
  80610. */
  80611. getClassName(): string;
  80612. /**
  80613. * Instantiates a particle system.
  80614. * 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.
  80615. * @param name The name of the particle system
  80616. * @param capacity The max number of particles alive at the same time
  80617. * @param scene The scene the particle system belongs to
  80618. * @param customEffect a custom effect used to change the way particles are rendered by default
  80619. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80620. * @param epsilon Offset used to render the particles
  80621. */
  80622. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80623. private _addFactorGradient;
  80624. private _removeFactorGradient;
  80625. /**
  80626. * Adds a new life time gradient
  80627. * @param gradient defines the gradient to use (between 0 and 1)
  80628. * @param factor defines the life time factor to affect to the specified gradient
  80629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80630. * @returns the current particle system
  80631. */
  80632. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80633. /**
  80634. * Remove a specific life time gradient
  80635. * @param gradient defines the gradient to remove
  80636. * @returns the current particle system
  80637. */
  80638. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80639. /**
  80640. * Adds a new size gradient
  80641. * @param gradient defines the gradient to use (between 0 and 1)
  80642. * @param factor defines the size factor to affect to the specified gradient
  80643. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80644. * @returns the current particle system
  80645. */
  80646. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80647. /**
  80648. * Remove a specific size gradient
  80649. * @param gradient defines the gradient to remove
  80650. * @returns the current particle system
  80651. */
  80652. removeSizeGradient(gradient: number): IParticleSystem;
  80653. /**
  80654. * Adds a new color remap gradient
  80655. * @param gradient defines the gradient to use (between 0 and 1)
  80656. * @param min defines the color remap minimal range
  80657. * @param max defines the color remap maximal range
  80658. * @returns the current particle system
  80659. */
  80660. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80661. /**
  80662. * Remove a specific color remap gradient
  80663. * @param gradient defines the gradient to remove
  80664. * @returns the current particle system
  80665. */
  80666. removeColorRemapGradient(gradient: number): IParticleSystem;
  80667. /**
  80668. * Adds a new alpha remap gradient
  80669. * @param gradient defines the gradient to use (between 0 and 1)
  80670. * @param min defines the alpha remap minimal range
  80671. * @param max defines the alpha remap maximal range
  80672. * @returns the current particle system
  80673. */
  80674. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80675. /**
  80676. * Remove a specific alpha remap gradient
  80677. * @param gradient defines the gradient to remove
  80678. * @returns the current particle system
  80679. */
  80680. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80681. /**
  80682. * Adds a new angular speed gradient
  80683. * @param gradient defines the gradient to use (between 0 and 1)
  80684. * @param factor defines the angular speed to affect to the specified gradient
  80685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80686. * @returns the current particle system
  80687. */
  80688. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80689. /**
  80690. * Remove a specific angular speed gradient
  80691. * @param gradient defines the gradient to remove
  80692. * @returns the current particle system
  80693. */
  80694. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80695. /**
  80696. * Adds a new velocity gradient
  80697. * @param gradient defines the gradient to use (between 0 and 1)
  80698. * @param factor defines the velocity to affect to the specified gradient
  80699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80700. * @returns the current particle system
  80701. */
  80702. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80703. /**
  80704. * Remove a specific velocity gradient
  80705. * @param gradient defines the gradient to remove
  80706. * @returns the current particle system
  80707. */
  80708. removeVelocityGradient(gradient: number): IParticleSystem;
  80709. /**
  80710. * Adds a new limit velocity gradient
  80711. * @param gradient defines the gradient to use (between 0 and 1)
  80712. * @param factor defines the limit velocity value to affect to the specified gradient
  80713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80714. * @returns the current particle system
  80715. */
  80716. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80717. /**
  80718. * Remove a specific limit velocity gradient
  80719. * @param gradient defines the gradient to remove
  80720. * @returns the current particle system
  80721. */
  80722. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80723. /**
  80724. * Adds a new drag gradient
  80725. * @param gradient defines the gradient to use (between 0 and 1)
  80726. * @param factor defines the drag value to affect to the specified gradient
  80727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80728. * @returns the current particle system
  80729. */
  80730. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80731. /**
  80732. * Remove a specific drag gradient
  80733. * @param gradient defines the gradient to remove
  80734. * @returns the current particle system
  80735. */
  80736. removeDragGradient(gradient: number): IParticleSystem;
  80737. /**
  80738. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80739. * @param gradient defines the gradient to use (between 0 and 1)
  80740. * @param factor defines the emit rate value to affect to the specified gradient
  80741. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80742. * @returns the current particle system
  80743. */
  80744. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80745. /**
  80746. * Remove a specific emit rate gradient
  80747. * @param gradient defines the gradient to remove
  80748. * @returns the current particle system
  80749. */
  80750. removeEmitRateGradient(gradient: number): IParticleSystem;
  80751. /**
  80752. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80753. * @param gradient defines the gradient to use (between 0 and 1)
  80754. * @param factor defines the start size value to affect to the specified gradient
  80755. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80756. * @returns the current particle system
  80757. */
  80758. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80759. /**
  80760. * Remove a specific start size gradient
  80761. * @param gradient defines the gradient to remove
  80762. * @returns the current particle system
  80763. */
  80764. removeStartSizeGradient(gradient: number): IParticleSystem;
  80765. private _createRampGradientTexture;
  80766. /**
  80767. * Gets the current list of ramp gradients.
  80768. * You must use addRampGradient and removeRampGradient to udpate this list
  80769. * @returns the list of ramp gradients
  80770. */
  80771. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80772. /**
  80773. * Adds a new ramp gradient used to remap particle colors
  80774. * @param gradient defines the gradient to use (between 0 and 1)
  80775. * @param color defines the color to affect to the specified gradient
  80776. * @returns the current particle system
  80777. */
  80778. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80779. /**
  80780. * Remove a specific ramp gradient
  80781. * @param gradient defines the gradient to remove
  80782. * @returns the current particle system
  80783. */
  80784. removeRampGradient(gradient: number): ParticleSystem;
  80785. /**
  80786. * Adds a new color gradient
  80787. * @param gradient defines the gradient to use (between 0 and 1)
  80788. * @param color1 defines the color to affect to the specified gradient
  80789. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80790. * @returns this particle system
  80791. */
  80792. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80793. /**
  80794. * Remove a specific color gradient
  80795. * @param gradient defines the gradient to remove
  80796. * @returns this particle system
  80797. */
  80798. removeColorGradient(gradient: number): IParticleSystem;
  80799. private _fetchR;
  80800. protected _reset(): void;
  80801. private _resetEffect;
  80802. private _createVertexBuffers;
  80803. private _createIndexBuffer;
  80804. /**
  80805. * Gets the maximum number of particles active at the same time.
  80806. * @returns The max number of active particles.
  80807. */
  80808. getCapacity(): number;
  80809. /**
  80810. * Gets whether there are still active particles in the system.
  80811. * @returns True if it is alive, otherwise false.
  80812. */
  80813. isAlive(): boolean;
  80814. /**
  80815. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80816. * @returns True if it has been started, otherwise false.
  80817. */
  80818. isStarted(): boolean;
  80819. private _prepareSubEmitterInternalArray;
  80820. /**
  80821. * Starts the particle system and begins to emit
  80822. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80823. */
  80824. start(delay?: number): void;
  80825. /**
  80826. * Stops the particle system.
  80827. * @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.
  80828. */
  80829. stop(stopSubEmitters?: boolean): void;
  80830. /**
  80831. * Remove all active particles
  80832. */
  80833. reset(): void;
  80834. /**
  80835. * @hidden (for internal use only)
  80836. */
  80837. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80838. /**
  80839. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80840. * Its lifetime will start back at 0.
  80841. */
  80842. recycleParticle: (particle: Particle) => void;
  80843. private _stopSubEmitters;
  80844. private _createParticle;
  80845. private _removeFromRoot;
  80846. private _emitFromParticle;
  80847. private _update;
  80848. /** @hidden */
  80849. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  80850. /** @hidden */
  80851. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  80852. /** @hidden */
  80853. private _getEffect;
  80854. /**
  80855. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  80856. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  80857. */
  80858. animate(preWarmOnly?: boolean): void;
  80859. private _appendParticleVertices;
  80860. /**
  80861. * Rebuilds the particle system.
  80862. */
  80863. rebuild(): void;
  80864. /**
  80865. * Is this system ready to be used/rendered
  80866. * @return true if the system is ready
  80867. */
  80868. isReady(): boolean;
  80869. private _render;
  80870. /**
  80871. * Renders the particle system in its current state.
  80872. * @returns the current number of particles
  80873. */
  80874. render(): number;
  80875. /**
  80876. * Disposes the particle system and free the associated resources
  80877. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  80878. */
  80879. dispose(disposeTexture?: boolean): void;
  80880. /**
  80881. * Clones the particle system.
  80882. * @param name The name of the cloned object
  80883. * @param newEmitter The new emitter to use
  80884. * @returns the cloned particle system
  80885. */
  80886. clone(name: string, newEmitter: any): ParticleSystem;
  80887. /**
  80888. * Serializes the particle system to a JSON object.
  80889. * @returns the JSON object
  80890. */
  80891. serialize(): any;
  80892. /** @hidden */
  80893. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  80894. /** @hidden */
  80895. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  80896. /**
  80897. * Parses a JSON object to create a particle system.
  80898. * @param parsedParticleSystem The JSON object to parse
  80899. * @param scene The scene to create the particle system in
  80900. * @param rootUrl The root url to use to load external dependencies like texture
  80901. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  80902. * @returns the Parsed particle system
  80903. */
  80904. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  80905. }
  80906. }
  80907. declare module BABYLON {
  80908. /**
  80909. * A particle represents one of the element emitted by a particle system.
  80910. * This is mainly define by its coordinates, direction, velocity and age.
  80911. */
  80912. export class Particle {
  80913. /**
  80914. * The particle system the particle belongs to.
  80915. */
  80916. particleSystem: ParticleSystem;
  80917. private static _Count;
  80918. /**
  80919. * Unique ID of the particle
  80920. */
  80921. id: number;
  80922. /**
  80923. * The world position of the particle in the scene.
  80924. */
  80925. position: Vector3;
  80926. /**
  80927. * The world direction of the particle in the scene.
  80928. */
  80929. direction: Vector3;
  80930. /**
  80931. * The color of the particle.
  80932. */
  80933. color: Color4;
  80934. /**
  80935. * The color change of the particle per step.
  80936. */
  80937. colorStep: Color4;
  80938. /**
  80939. * Defines how long will the life of the particle be.
  80940. */
  80941. lifeTime: number;
  80942. /**
  80943. * The current age of the particle.
  80944. */
  80945. age: number;
  80946. /**
  80947. * The current size of the particle.
  80948. */
  80949. size: number;
  80950. /**
  80951. * The current scale of the particle.
  80952. */
  80953. scale: Vector2;
  80954. /**
  80955. * The current angle of the particle.
  80956. */
  80957. angle: number;
  80958. /**
  80959. * Defines how fast is the angle changing.
  80960. */
  80961. angularSpeed: number;
  80962. /**
  80963. * Defines the cell index used by the particle to be rendered from a sprite.
  80964. */
  80965. cellIndex: number;
  80966. /**
  80967. * The information required to support color remapping
  80968. */
  80969. remapData: Vector4;
  80970. /** @hidden */
  80971. _randomCellOffset?: number;
  80972. /** @hidden */
  80973. _initialDirection: Nullable<Vector3>;
  80974. /** @hidden */
  80975. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  80976. /** @hidden */
  80977. _initialStartSpriteCellID: number;
  80978. /** @hidden */
  80979. _initialEndSpriteCellID: number;
  80980. /** @hidden */
  80981. _currentColorGradient: Nullable<ColorGradient>;
  80982. /** @hidden */
  80983. _currentColor1: Color4;
  80984. /** @hidden */
  80985. _currentColor2: Color4;
  80986. /** @hidden */
  80987. _currentSizeGradient: Nullable<FactorGradient>;
  80988. /** @hidden */
  80989. _currentSize1: number;
  80990. /** @hidden */
  80991. _currentSize2: number;
  80992. /** @hidden */
  80993. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  80994. /** @hidden */
  80995. _currentAngularSpeed1: number;
  80996. /** @hidden */
  80997. _currentAngularSpeed2: number;
  80998. /** @hidden */
  80999. _currentVelocityGradient: Nullable<FactorGradient>;
  81000. /** @hidden */
  81001. _currentVelocity1: number;
  81002. /** @hidden */
  81003. _currentVelocity2: number;
  81004. /** @hidden */
  81005. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  81006. /** @hidden */
  81007. _currentLimitVelocity1: number;
  81008. /** @hidden */
  81009. _currentLimitVelocity2: number;
  81010. /** @hidden */
  81011. _currentDragGradient: Nullable<FactorGradient>;
  81012. /** @hidden */
  81013. _currentDrag1: number;
  81014. /** @hidden */
  81015. _currentDrag2: number;
  81016. /** @hidden */
  81017. _randomNoiseCoordinates1: Vector3;
  81018. /** @hidden */
  81019. _randomNoiseCoordinates2: Vector3;
  81020. /**
  81021. * Creates a new instance Particle
  81022. * @param particleSystem the particle system the particle belongs to
  81023. */
  81024. constructor(
  81025. /**
  81026. * The particle system the particle belongs to.
  81027. */
  81028. particleSystem: ParticleSystem);
  81029. private updateCellInfoFromSystem;
  81030. /**
  81031. * Defines how the sprite cell index is updated for the particle
  81032. */
  81033. updateCellIndex(): void;
  81034. /** @hidden */
  81035. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81036. /** @hidden */
  81037. _inheritParticleInfoToSubEmitters(): void;
  81038. /** @hidden */
  81039. _reset(): void;
  81040. /**
  81041. * Copy the properties of particle to another one.
  81042. * @param other the particle to copy the information to.
  81043. */
  81044. copyTo(other: Particle): void;
  81045. }
  81046. }
  81047. declare module BABYLON {
  81048. /**
  81049. * Particle emitter represents a volume emitting particles.
  81050. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81051. */
  81052. export interface IParticleEmitterType {
  81053. /**
  81054. * Called by the particle System when the direction is computed for the created particle.
  81055. * @param worldMatrix is the world matrix of the particle system
  81056. * @param directionToUpdate is the direction vector to update with the result
  81057. * @param particle is the particle we are computed the direction for
  81058. */
  81059. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81060. /**
  81061. * Called by the particle System when the position is computed for the created particle.
  81062. * @param worldMatrix is the world matrix of the particle system
  81063. * @param positionToUpdate is the position vector to update with the result
  81064. * @param particle is the particle we are computed the position for
  81065. */
  81066. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81067. /**
  81068. * Clones the current emitter and returns a copy of it
  81069. * @returns the new emitter
  81070. */
  81071. clone(): IParticleEmitterType;
  81072. /**
  81073. * Called by the GPUParticleSystem to setup the update shader
  81074. * @param effect defines the update shader
  81075. */
  81076. applyToShader(effect: Effect): void;
  81077. /**
  81078. * Returns a string to use to update the GPU particles update shader
  81079. * @returns the effect defines string
  81080. */
  81081. getEffectDefines(): string;
  81082. /**
  81083. * Returns a string representing the class name
  81084. * @returns a string containing the class name
  81085. */
  81086. getClassName(): string;
  81087. /**
  81088. * Serializes the particle system to a JSON object.
  81089. * @returns the JSON object
  81090. */
  81091. serialize(): any;
  81092. /**
  81093. * Parse properties from a JSON object
  81094. * @param serializationObject defines the JSON object
  81095. */
  81096. parse(serializationObject: any): void;
  81097. }
  81098. }
  81099. declare module BABYLON {
  81100. /**
  81101. * Particle emitter emitting particles from the inside of a box.
  81102. * It emits the particles randomly between 2 given directions.
  81103. */
  81104. export class BoxParticleEmitter implements IParticleEmitterType {
  81105. /**
  81106. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81107. */
  81108. direction1: Vector3;
  81109. /**
  81110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81111. */
  81112. direction2: Vector3;
  81113. /**
  81114. * 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.
  81115. */
  81116. minEmitBox: Vector3;
  81117. /**
  81118. * 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.
  81119. */
  81120. maxEmitBox: Vector3;
  81121. /**
  81122. * Creates a new instance BoxParticleEmitter
  81123. */
  81124. constructor();
  81125. /**
  81126. * Called by the particle System when the direction is computed for the created particle.
  81127. * @param worldMatrix is the world matrix of the particle system
  81128. * @param directionToUpdate is the direction vector to update with the result
  81129. * @param particle is the particle we are computed the direction for
  81130. */
  81131. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81132. /**
  81133. * Called by the particle System when the position is computed for the created particle.
  81134. * @param worldMatrix is the world matrix of the particle system
  81135. * @param positionToUpdate is the position vector to update with the result
  81136. * @param particle is the particle we are computed the position for
  81137. */
  81138. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81139. /**
  81140. * Clones the current emitter and returns a copy of it
  81141. * @returns the new emitter
  81142. */
  81143. clone(): BoxParticleEmitter;
  81144. /**
  81145. * Called by the GPUParticleSystem to setup the update shader
  81146. * @param effect defines the update shader
  81147. */
  81148. applyToShader(effect: Effect): void;
  81149. /**
  81150. * Returns a string to use to update the GPU particles update shader
  81151. * @returns a string containng the defines string
  81152. */
  81153. getEffectDefines(): string;
  81154. /**
  81155. * Returns the string "BoxParticleEmitter"
  81156. * @returns a string containing the class name
  81157. */
  81158. getClassName(): string;
  81159. /**
  81160. * Serializes the particle system to a JSON object.
  81161. * @returns the JSON object
  81162. */
  81163. serialize(): any;
  81164. /**
  81165. * Parse properties from a JSON object
  81166. * @param serializationObject defines the JSON object
  81167. */
  81168. parse(serializationObject: any): void;
  81169. }
  81170. }
  81171. declare module BABYLON {
  81172. /**
  81173. * Particle emitter emitting particles from the inside of a cone.
  81174. * It emits the particles alongside the cone volume from the base to the particle.
  81175. * The emission direction might be randomized.
  81176. */
  81177. export class ConeParticleEmitter implements IParticleEmitterType {
  81178. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81179. directionRandomizer: number;
  81180. private _radius;
  81181. private _angle;
  81182. private _height;
  81183. /**
  81184. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81185. */
  81186. radiusRange: number;
  81187. /**
  81188. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81189. */
  81190. heightRange: number;
  81191. /**
  81192. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81193. */
  81194. emitFromSpawnPointOnly: boolean;
  81195. /**
  81196. * Gets or sets the radius of the emission cone
  81197. */
  81198. radius: number;
  81199. /**
  81200. * Gets or sets the angle of the emission cone
  81201. */
  81202. angle: number;
  81203. private _buildHeight;
  81204. /**
  81205. * Creates a new instance ConeParticleEmitter
  81206. * @param radius the radius of the emission cone (1 by default)
  81207. * @param angle the cone base angle (PI by default)
  81208. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81209. */
  81210. constructor(radius?: number, angle?: number,
  81211. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81212. directionRandomizer?: number);
  81213. /**
  81214. * Called by the particle System when the direction is computed for the created particle.
  81215. * @param worldMatrix is the world matrix of the particle system
  81216. * @param directionToUpdate is the direction vector to update with the result
  81217. * @param particle is the particle we are computed the direction for
  81218. */
  81219. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81220. /**
  81221. * Called by the particle System when the position is computed for the created particle.
  81222. * @param worldMatrix is the world matrix of the particle system
  81223. * @param positionToUpdate is the position vector to update with the result
  81224. * @param particle is the particle we are computed the position for
  81225. */
  81226. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81227. /**
  81228. * Clones the current emitter and returns a copy of it
  81229. * @returns the new emitter
  81230. */
  81231. clone(): ConeParticleEmitter;
  81232. /**
  81233. * Called by the GPUParticleSystem to setup the update shader
  81234. * @param effect defines the update shader
  81235. */
  81236. applyToShader(effect: Effect): void;
  81237. /**
  81238. * Returns a string to use to update the GPU particles update shader
  81239. * @returns a string containng the defines string
  81240. */
  81241. getEffectDefines(): string;
  81242. /**
  81243. * Returns the string "ConeParticleEmitter"
  81244. * @returns a string containing the class name
  81245. */
  81246. getClassName(): string;
  81247. /**
  81248. * Serializes the particle system to a JSON object.
  81249. * @returns the JSON object
  81250. */
  81251. serialize(): any;
  81252. /**
  81253. * Parse properties from a JSON object
  81254. * @param serializationObject defines the JSON object
  81255. */
  81256. parse(serializationObject: any): void;
  81257. }
  81258. }
  81259. declare module BABYLON {
  81260. /**
  81261. * Particle emitter emitting particles from the inside of a cylinder.
  81262. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81263. */
  81264. export class CylinderParticleEmitter implements IParticleEmitterType {
  81265. /**
  81266. * The radius of the emission cylinder.
  81267. */
  81268. radius: number;
  81269. /**
  81270. * The height of the emission cylinder.
  81271. */
  81272. height: number;
  81273. /**
  81274. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81275. */
  81276. radiusRange: number;
  81277. /**
  81278. * How much to randomize the particle direction [0-1].
  81279. */
  81280. directionRandomizer: number;
  81281. /**
  81282. * Creates a new instance CylinderParticleEmitter
  81283. * @param radius the radius of the emission cylinder (1 by default)
  81284. * @param height the height of the emission cylinder (1 by default)
  81285. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81286. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81287. */
  81288. constructor(
  81289. /**
  81290. * The radius of the emission cylinder.
  81291. */
  81292. radius?: number,
  81293. /**
  81294. * The height of the emission cylinder.
  81295. */
  81296. height?: number,
  81297. /**
  81298. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81299. */
  81300. radiusRange?: number,
  81301. /**
  81302. * How much to randomize the particle direction [0-1].
  81303. */
  81304. directionRandomizer?: number);
  81305. /**
  81306. * Called by the particle System when the direction is computed for the created particle.
  81307. * @param worldMatrix is the world matrix of the particle system
  81308. * @param directionToUpdate is the direction vector to update with the result
  81309. * @param particle is the particle we are computed the direction for
  81310. */
  81311. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81312. /**
  81313. * Called by the particle System when the position is computed for the created particle.
  81314. * @param worldMatrix is the world matrix of the particle system
  81315. * @param positionToUpdate is the position vector to update with the result
  81316. * @param particle is the particle we are computed the position for
  81317. */
  81318. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81319. /**
  81320. * Clones the current emitter and returns a copy of it
  81321. * @returns the new emitter
  81322. */
  81323. clone(): CylinderParticleEmitter;
  81324. /**
  81325. * Called by the GPUParticleSystem to setup the update shader
  81326. * @param effect defines the update shader
  81327. */
  81328. applyToShader(effect: Effect): void;
  81329. /**
  81330. * Returns a string to use to update the GPU particles update shader
  81331. * @returns a string containng the defines string
  81332. */
  81333. getEffectDefines(): string;
  81334. /**
  81335. * Returns the string "CylinderParticleEmitter"
  81336. * @returns a string containing the class name
  81337. */
  81338. getClassName(): string;
  81339. /**
  81340. * Serializes the particle system to a JSON object.
  81341. * @returns the JSON object
  81342. */
  81343. serialize(): any;
  81344. /**
  81345. * Parse properties from a JSON object
  81346. * @param serializationObject defines the JSON object
  81347. */
  81348. parse(serializationObject: any): void;
  81349. }
  81350. /**
  81351. * Particle emitter emitting particles from the inside of a cylinder.
  81352. * It emits the particles randomly between two vectors.
  81353. */
  81354. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81355. /**
  81356. * The min limit of the emission direction.
  81357. */
  81358. direction1: Vector3;
  81359. /**
  81360. * The max limit of the emission direction.
  81361. */
  81362. direction2: Vector3;
  81363. /**
  81364. * Creates a new instance CylinderDirectedParticleEmitter
  81365. * @param radius the radius of the emission cylinder (1 by default)
  81366. * @param height the height of the emission cylinder (1 by default)
  81367. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81368. * @param direction1 the min limit of the emission direction (up vector by default)
  81369. * @param direction2 the max limit of the emission direction (up vector by default)
  81370. */
  81371. constructor(radius?: number, height?: number, radiusRange?: number,
  81372. /**
  81373. * The min limit of the emission direction.
  81374. */
  81375. direction1?: Vector3,
  81376. /**
  81377. * The max limit of the emission direction.
  81378. */
  81379. direction2?: Vector3);
  81380. /**
  81381. * Called by the particle System when the direction is computed for the created particle.
  81382. * @param worldMatrix is the world matrix of the particle system
  81383. * @param directionToUpdate is the direction vector to update with the result
  81384. * @param particle is the particle we are computed the direction for
  81385. */
  81386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81387. /**
  81388. * Clones the current emitter and returns a copy of it
  81389. * @returns the new emitter
  81390. */
  81391. clone(): CylinderDirectedParticleEmitter;
  81392. /**
  81393. * Called by the GPUParticleSystem to setup the update shader
  81394. * @param effect defines the update shader
  81395. */
  81396. applyToShader(effect: Effect): void;
  81397. /**
  81398. * Returns a string to use to update the GPU particles update shader
  81399. * @returns a string containng the defines string
  81400. */
  81401. getEffectDefines(): string;
  81402. /**
  81403. * Returns the string "CylinderDirectedParticleEmitter"
  81404. * @returns a string containing the class name
  81405. */
  81406. getClassName(): string;
  81407. /**
  81408. * Serializes the particle system to a JSON object.
  81409. * @returns the JSON object
  81410. */
  81411. serialize(): any;
  81412. /**
  81413. * Parse properties from a JSON object
  81414. * @param serializationObject defines the JSON object
  81415. */
  81416. parse(serializationObject: any): void;
  81417. }
  81418. }
  81419. declare module BABYLON {
  81420. /**
  81421. * Particle emitter emitting particles from the inside of a hemisphere.
  81422. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81423. */
  81424. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81425. /**
  81426. * The radius of the emission hemisphere.
  81427. */
  81428. radius: number;
  81429. /**
  81430. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81431. */
  81432. radiusRange: number;
  81433. /**
  81434. * How much to randomize the particle direction [0-1].
  81435. */
  81436. directionRandomizer: number;
  81437. /**
  81438. * Creates a new instance HemisphericParticleEmitter
  81439. * @param radius the radius of the emission hemisphere (1 by default)
  81440. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81441. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81442. */
  81443. constructor(
  81444. /**
  81445. * The radius of the emission hemisphere.
  81446. */
  81447. radius?: number,
  81448. /**
  81449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81450. */
  81451. radiusRange?: number,
  81452. /**
  81453. * How much to randomize the particle direction [0-1].
  81454. */
  81455. directionRandomizer?: number);
  81456. /**
  81457. * Called by the particle System when the direction is computed for the created particle.
  81458. * @param worldMatrix is the world matrix of the particle system
  81459. * @param directionToUpdate is the direction vector to update with the result
  81460. * @param particle is the particle we are computed the direction for
  81461. */
  81462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81463. /**
  81464. * Called by the particle System when the position is computed for the created particle.
  81465. * @param worldMatrix is the world matrix of the particle system
  81466. * @param positionToUpdate is the position vector to update with the result
  81467. * @param particle is the particle we are computed the position for
  81468. */
  81469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81470. /**
  81471. * Clones the current emitter and returns a copy of it
  81472. * @returns the new emitter
  81473. */
  81474. clone(): HemisphericParticleEmitter;
  81475. /**
  81476. * Called by the GPUParticleSystem to setup the update shader
  81477. * @param effect defines the update shader
  81478. */
  81479. applyToShader(effect: Effect): void;
  81480. /**
  81481. * Returns a string to use to update the GPU particles update shader
  81482. * @returns a string containng the defines string
  81483. */
  81484. getEffectDefines(): string;
  81485. /**
  81486. * Returns the string "HemisphericParticleEmitter"
  81487. * @returns a string containing the class name
  81488. */
  81489. getClassName(): string;
  81490. /**
  81491. * Serializes the particle system to a JSON object.
  81492. * @returns the JSON object
  81493. */
  81494. serialize(): any;
  81495. /**
  81496. * Parse properties from a JSON object
  81497. * @param serializationObject defines the JSON object
  81498. */
  81499. parse(serializationObject: any): void;
  81500. }
  81501. }
  81502. declare module BABYLON {
  81503. /**
  81504. * Particle emitter emitting particles from a point.
  81505. * It emits the particles randomly between 2 given directions.
  81506. */
  81507. export class PointParticleEmitter implements IParticleEmitterType {
  81508. /**
  81509. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81510. */
  81511. direction1: Vector3;
  81512. /**
  81513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81514. */
  81515. direction2: Vector3;
  81516. /**
  81517. * Creates a new instance PointParticleEmitter
  81518. */
  81519. constructor();
  81520. /**
  81521. * Called by the particle System when the direction is computed for the created particle.
  81522. * @param worldMatrix is the world matrix of the particle system
  81523. * @param directionToUpdate is the direction vector to update with the result
  81524. * @param particle is the particle we are computed the direction for
  81525. */
  81526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81527. /**
  81528. * Called by the particle System when the position is computed for the created particle.
  81529. * @param worldMatrix is the world matrix of the particle system
  81530. * @param positionToUpdate is the position vector to update with the result
  81531. * @param particle is the particle we are computed the position for
  81532. */
  81533. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81534. /**
  81535. * Clones the current emitter and returns a copy of it
  81536. * @returns the new emitter
  81537. */
  81538. clone(): PointParticleEmitter;
  81539. /**
  81540. * Called by the GPUParticleSystem to setup the update shader
  81541. * @param effect defines the update shader
  81542. */
  81543. applyToShader(effect: Effect): void;
  81544. /**
  81545. * Returns a string to use to update the GPU particles update shader
  81546. * @returns a string containng the defines string
  81547. */
  81548. getEffectDefines(): string;
  81549. /**
  81550. * Returns the string "PointParticleEmitter"
  81551. * @returns a string containing the class name
  81552. */
  81553. getClassName(): string;
  81554. /**
  81555. * Serializes the particle system to a JSON object.
  81556. * @returns the JSON object
  81557. */
  81558. serialize(): any;
  81559. /**
  81560. * Parse properties from a JSON object
  81561. * @param serializationObject defines the JSON object
  81562. */
  81563. parse(serializationObject: any): void;
  81564. }
  81565. }
  81566. declare module BABYLON {
  81567. /**
  81568. * Particle emitter emitting particles from the inside of a sphere.
  81569. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81570. */
  81571. export class SphereParticleEmitter implements IParticleEmitterType {
  81572. /**
  81573. * The radius of the emission sphere.
  81574. */
  81575. radius: number;
  81576. /**
  81577. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81578. */
  81579. radiusRange: number;
  81580. /**
  81581. * How much to randomize the particle direction [0-1].
  81582. */
  81583. directionRandomizer: number;
  81584. /**
  81585. * Creates a new instance SphereParticleEmitter
  81586. * @param radius the radius of the emission sphere (1 by default)
  81587. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81588. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81589. */
  81590. constructor(
  81591. /**
  81592. * The radius of the emission sphere.
  81593. */
  81594. radius?: number,
  81595. /**
  81596. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81597. */
  81598. radiusRange?: number,
  81599. /**
  81600. * How much to randomize the particle direction [0-1].
  81601. */
  81602. directionRandomizer?: number);
  81603. /**
  81604. * Called by the particle System when the direction is computed for the created particle.
  81605. * @param worldMatrix is the world matrix of the particle system
  81606. * @param directionToUpdate is the direction vector to update with the result
  81607. * @param particle is the particle we are computed the direction for
  81608. */
  81609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81610. /**
  81611. * Called by the particle System when the position is computed for the created particle.
  81612. * @param worldMatrix is the world matrix of the particle system
  81613. * @param positionToUpdate is the position vector to update with the result
  81614. * @param particle is the particle we are computed the position for
  81615. */
  81616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81617. /**
  81618. * Clones the current emitter and returns a copy of it
  81619. * @returns the new emitter
  81620. */
  81621. clone(): SphereParticleEmitter;
  81622. /**
  81623. * Called by the GPUParticleSystem to setup the update shader
  81624. * @param effect defines the update shader
  81625. */
  81626. applyToShader(effect: Effect): void;
  81627. /**
  81628. * Returns a string to use to update the GPU particles update shader
  81629. * @returns a string containng the defines string
  81630. */
  81631. getEffectDefines(): string;
  81632. /**
  81633. * Returns the string "SphereParticleEmitter"
  81634. * @returns a string containing the class name
  81635. */
  81636. getClassName(): string;
  81637. /**
  81638. * Serializes the particle system to a JSON object.
  81639. * @returns the JSON object
  81640. */
  81641. serialize(): any;
  81642. /**
  81643. * Parse properties from a JSON object
  81644. * @param serializationObject defines the JSON object
  81645. */
  81646. parse(serializationObject: any): void;
  81647. }
  81648. /**
  81649. * Particle emitter emitting particles from the inside of a sphere.
  81650. * It emits the particles randomly between two vectors.
  81651. */
  81652. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81653. /**
  81654. * The min limit of the emission direction.
  81655. */
  81656. direction1: Vector3;
  81657. /**
  81658. * The max limit of the emission direction.
  81659. */
  81660. direction2: Vector3;
  81661. /**
  81662. * Creates a new instance SphereDirectedParticleEmitter
  81663. * @param radius the radius of the emission sphere (1 by default)
  81664. * @param direction1 the min limit of the emission direction (up vector by default)
  81665. * @param direction2 the max limit of the emission direction (up vector by default)
  81666. */
  81667. constructor(radius?: number,
  81668. /**
  81669. * The min limit of the emission direction.
  81670. */
  81671. direction1?: Vector3,
  81672. /**
  81673. * The max limit of the emission direction.
  81674. */
  81675. direction2?: Vector3);
  81676. /**
  81677. * Called by the particle System when the direction is computed for the created particle.
  81678. * @param worldMatrix is the world matrix of the particle system
  81679. * @param directionToUpdate is the direction vector to update with the result
  81680. * @param particle is the particle we are computed the direction for
  81681. */
  81682. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81683. /**
  81684. * Clones the current emitter and returns a copy of it
  81685. * @returns the new emitter
  81686. */
  81687. clone(): SphereDirectedParticleEmitter;
  81688. /**
  81689. * Called by the GPUParticleSystem to setup the update shader
  81690. * @param effect defines the update shader
  81691. */
  81692. applyToShader(effect: Effect): void;
  81693. /**
  81694. * Returns a string to use to update the GPU particles update shader
  81695. * @returns a string containng the defines string
  81696. */
  81697. getEffectDefines(): string;
  81698. /**
  81699. * Returns the string "SphereDirectedParticleEmitter"
  81700. * @returns a string containing the class name
  81701. */
  81702. getClassName(): string;
  81703. /**
  81704. * Serializes the particle system to a JSON object.
  81705. * @returns the JSON object
  81706. */
  81707. serialize(): any;
  81708. /**
  81709. * Parse properties from a JSON object
  81710. * @param serializationObject defines the JSON object
  81711. */
  81712. parse(serializationObject: any): void;
  81713. }
  81714. }
  81715. declare module BABYLON {
  81716. /**
  81717. * Interface representing a particle system in Babylon.js.
  81718. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81719. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81720. */
  81721. export interface IParticleSystem {
  81722. /**
  81723. * List of animations used by the particle system.
  81724. */
  81725. animations: Animation[];
  81726. /**
  81727. * The id of the Particle system.
  81728. */
  81729. id: string;
  81730. /**
  81731. * The name of the Particle system.
  81732. */
  81733. name: string;
  81734. /**
  81735. * The emitter represents the Mesh or position we are attaching the particle system to.
  81736. */
  81737. emitter: Nullable<AbstractMesh | Vector3>;
  81738. /**
  81739. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81740. */
  81741. isBillboardBased: boolean;
  81742. /**
  81743. * The rendering group used by the Particle system to chose when to render.
  81744. */
  81745. renderingGroupId: number;
  81746. /**
  81747. * The layer mask we are rendering the particles through.
  81748. */
  81749. layerMask: number;
  81750. /**
  81751. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81752. */
  81753. updateSpeed: number;
  81754. /**
  81755. * The amount of time the particle system is running (depends of the overall update speed).
  81756. */
  81757. targetStopDuration: number;
  81758. /**
  81759. * The texture used to render each particle. (this can be a spritesheet)
  81760. */
  81761. particleTexture: Nullable<Texture>;
  81762. /**
  81763. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81764. */
  81765. blendMode: number;
  81766. /**
  81767. * Minimum life time of emitting particles.
  81768. */
  81769. minLifeTime: number;
  81770. /**
  81771. * Maximum life time of emitting particles.
  81772. */
  81773. maxLifeTime: number;
  81774. /**
  81775. * Minimum Size of emitting particles.
  81776. */
  81777. minSize: number;
  81778. /**
  81779. * Maximum Size of emitting particles.
  81780. */
  81781. maxSize: number;
  81782. /**
  81783. * Minimum scale of emitting particles on X axis.
  81784. */
  81785. minScaleX: number;
  81786. /**
  81787. * Maximum scale of emitting particles on X axis.
  81788. */
  81789. maxScaleX: number;
  81790. /**
  81791. * Minimum scale of emitting particles on Y axis.
  81792. */
  81793. minScaleY: number;
  81794. /**
  81795. * Maximum scale of emitting particles on Y axis.
  81796. */
  81797. maxScaleY: number;
  81798. /**
  81799. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81800. */
  81801. color1: Color4;
  81802. /**
  81803. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81804. */
  81805. color2: Color4;
  81806. /**
  81807. * Color the particle will have at the end of its lifetime.
  81808. */
  81809. colorDead: Color4;
  81810. /**
  81811. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81812. */
  81813. emitRate: number;
  81814. /**
  81815. * You can use gravity if you want to give an orientation to your particles.
  81816. */
  81817. gravity: Vector3;
  81818. /**
  81819. * Minimum power of emitting particles.
  81820. */
  81821. minEmitPower: number;
  81822. /**
  81823. * Maximum power of emitting particles.
  81824. */
  81825. maxEmitPower: number;
  81826. /**
  81827. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81828. */
  81829. minAngularSpeed: number;
  81830. /**
  81831. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81832. */
  81833. maxAngularSpeed: number;
  81834. /**
  81835. * Gets or sets the minimal initial rotation in radians.
  81836. */
  81837. minInitialRotation: number;
  81838. /**
  81839. * Gets or sets the maximal initial rotation in radians.
  81840. */
  81841. maxInitialRotation: number;
  81842. /**
  81843. * The particle emitter type defines the emitter used by the particle system.
  81844. * It can be for example box, sphere, or cone...
  81845. */
  81846. particleEmitterType: Nullable<IParticleEmitterType>;
  81847. /**
  81848. * Defines the delay in milliseconds before starting the system (0 by default)
  81849. */
  81850. startDelay: number;
  81851. /**
  81852. * 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
  81853. */
  81854. preWarmCycles: number;
  81855. /**
  81856. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  81857. */
  81858. preWarmStepOffset: number;
  81859. /**
  81860. * 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)
  81861. */
  81862. spriteCellChangeSpeed: number;
  81863. /**
  81864. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81865. */
  81866. startSpriteCellID: number;
  81867. /**
  81868. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81869. */
  81870. endSpriteCellID: number;
  81871. /**
  81872. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81873. */
  81874. spriteCellWidth: number;
  81875. /**
  81876. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81877. */
  81878. spriteCellHeight: number;
  81879. /**
  81880. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81881. */
  81882. spriteRandomStartCell: boolean;
  81883. /**
  81884. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  81885. */
  81886. isAnimationSheetEnabled: boolean;
  81887. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81888. translationPivot: Vector2;
  81889. /**
  81890. * Gets or sets a texture used to add random noise to particle positions
  81891. */
  81892. noiseTexture: Nullable<BaseTexture>;
  81893. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81894. noiseStrength: Vector3;
  81895. /**
  81896. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81897. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81898. */
  81899. billboardMode: number;
  81900. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81901. limitVelocityDamping: number;
  81902. /**
  81903. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81904. */
  81905. beginAnimationOnStart: boolean;
  81906. /**
  81907. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81908. */
  81909. beginAnimationFrom: number;
  81910. /**
  81911. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81912. */
  81913. beginAnimationTo: number;
  81914. /**
  81915. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81916. */
  81917. beginAnimationLoop: boolean;
  81918. /**
  81919. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81920. */
  81921. disposeOnStop: boolean;
  81922. /**
  81923. * Gets the maximum number of particles active at the same time.
  81924. * @returns The max number of active particles.
  81925. */
  81926. getCapacity(): number;
  81927. /**
  81928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81929. * @returns True if it has been started, otherwise false.
  81930. */
  81931. isStarted(): boolean;
  81932. /**
  81933. * Animates the particle system for this frame.
  81934. */
  81935. animate(): void;
  81936. /**
  81937. * Renders the particle system in its current state.
  81938. * @returns the current number of particles
  81939. */
  81940. render(): number;
  81941. /**
  81942. * Dispose the particle system and frees its associated resources.
  81943. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81944. */
  81945. dispose(disposeTexture?: boolean): void;
  81946. /**
  81947. * Clones the particle system.
  81948. * @param name The name of the cloned object
  81949. * @param newEmitter The new emitter to use
  81950. * @returns the cloned particle system
  81951. */
  81952. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  81953. /**
  81954. * Serializes the particle system to a JSON object.
  81955. * @returns the JSON object
  81956. */
  81957. serialize(): any;
  81958. /**
  81959. * Rebuild the particle system
  81960. */
  81961. rebuild(): void;
  81962. /**
  81963. * Starts the particle system and begins to emit
  81964. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  81965. */
  81966. start(delay?: number): void;
  81967. /**
  81968. * Stops the particle system.
  81969. */
  81970. stop(): void;
  81971. /**
  81972. * Remove all active particles
  81973. */
  81974. reset(): void;
  81975. /**
  81976. * Is this system ready to be used/rendered
  81977. * @return true if the system is ready
  81978. */
  81979. isReady(): boolean;
  81980. /**
  81981. * Adds a new color gradient
  81982. * @param gradient defines the gradient to use (between 0 and 1)
  81983. * @param color1 defines the color to affect to the specified gradient
  81984. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81985. * @returns the current particle system
  81986. */
  81987. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81988. /**
  81989. * Remove a specific color gradient
  81990. * @param gradient defines the gradient to remove
  81991. * @returns the current particle system
  81992. */
  81993. removeColorGradient(gradient: number): IParticleSystem;
  81994. /**
  81995. * Adds a new size gradient
  81996. * @param gradient defines the gradient to use (between 0 and 1)
  81997. * @param factor defines the size factor to affect to the specified gradient
  81998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81999. * @returns the current particle system
  82000. */
  82001. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82002. /**
  82003. * Remove a specific size gradient
  82004. * @param gradient defines the gradient to remove
  82005. * @returns the current particle system
  82006. */
  82007. removeSizeGradient(gradient: number): IParticleSystem;
  82008. /**
  82009. * Gets the current list of color gradients.
  82010. * You must use addColorGradient and removeColorGradient to udpate this list
  82011. * @returns the list of color gradients
  82012. */
  82013. getColorGradients(): Nullable<Array<ColorGradient>>;
  82014. /**
  82015. * Gets the current list of size gradients.
  82016. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82017. * @returns the list of size gradients
  82018. */
  82019. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82020. /**
  82021. * Gets the current list of angular speed gradients.
  82022. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82023. * @returns the list of angular speed gradients
  82024. */
  82025. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82026. /**
  82027. * Adds a new angular speed gradient
  82028. * @param gradient defines the gradient to use (between 0 and 1)
  82029. * @param factor defines the angular speed to affect to the specified gradient
  82030. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82031. * @returns the current particle system
  82032. */
  82033. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82034. /**
  82035. * Remove a specific angular speed gradient
  82036. * @param gradient defines the gradient to remove
  82037. * @returns the current particle system
  82038. */
  82039. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82040. /**
  82041. * Gets the current list of velocity gradients.
  82042. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82043. * @returns the list of velocity gradients
  82044. */
  82045. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82046. /**
  82047. * Adds a new velocity gradient
  82048. * @param gradient defines the gradient to use (between 0 and 1)
  82049. * @param factor defines the velocity to affect to the specified gradient
  82050. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82051. * @returns the current particle system
  82052. */
  82053. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82054. /**
  82055. * Remove a specific velocity gradient
  82056. * @param gradient defines the gradient to remove
  82057. * @returns the current particle system
  82058. */
  82059. removeVelocityGradient(gradient: number): IParticleSystem;
  82060. /**
  82061. * Gets the current list of limit velocity gradients.
  82062. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82063. * @returns the list of limit velocity gradients
  82064. */
  82065. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82066. /**
  82067. * Adds a new limit velocity gradient
  82068. * @param gradient defines the gradient to use (between 0 and 1)
  82069. * @param factor defines the limit velocity to affect to the specified gradient
  82070. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82071. * @returns the current particle system
  82072. */
  82073. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82074. /**
  82075. * Remove a specific limit velocity gradient
  82076. * @param gradient defines the gradient to remove
  82077. * @returns the current particle system
  82078. */
  82079. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82080. /**
  82081. * Adds a new drag gradient
  82082. * @param gradient defines the gradient to use (between 0 and 1)
  82083. * @param factor defines the drag to affect to the specified gradient
  82084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82085. * @returns the current particle system
  82086. */
  82087. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82088. /**
  82089. * Remove a specific drag gradient
  82090. * @param gradient defines the gradient to remove
  82091. * @returns the current particle system
  82092. */
  82093. removeDragGradient(gradient: number): IParticleSystem;
  82094. /**
  82095. * Gets the current list of drag gradients.
  82096. * You must use addDragGradient and removeDragGradient to udpate this list
  82097. * @returns the list of drag gradients
  82098. */
  82099. getDragGradients(): Nullable<Array<FactorGradient>>;
  82100. /**
  82101. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82102. * @param gradient defines the gradient to use (between 0 and 1)
  82103. * @param factor defines the emit rate to affect to the specified gradient
  82104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82105. * @returns the current particle system
  82106. */
  82107. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82108. /**
  82109. * Remove a specific emit rate gradient
  82110. * @param gradient defines the gradient to remove
  82111. * @returns the current particle system
  82112. */
  82113. removeEmitRateGradient(gradient: number): IParticleSystem;
  82114. /**
  82115. * Gets the current list of emit rate gradients.
  82116. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82117. * @returns the list of emit rate gradients
  82118. */
  82119. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82120. /**
  82121. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82122. * @param gradient defines the gradient to use (between 0 and 1)
  82123. * @param factor defines the start size to affect to the specified gradient
  82124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82125. * @returns the current particle system
  82126. */
  82127. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82128. /**
  82129. * Remove a specific start size gradient
  82130. * @param gradient defines the gradient to remove
  82131. * @returns the current particle system
  82132. */
  82133. removeStartSizeGradient(gradient: number): IParticleSystem;
  82134. /**
  82135. * Gets the current list of start size gradients.
  82136. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82137. * @returns the list of start size gradients
  82138. */
  82139. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82140. /**
  82141. * Adds a new life time gradient
  82142. * @param gradient defines the gradient to use (between 0 and 1)
  82143. * @param factor defines the life time factor to affect to the specified gradient
  82144. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82145. * @returns the current particle system
  82146. */
  82147. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82148. /**
  82149. * Remove a specific life time gradient
  82150. * @param gradient defines the gradient to remove
  82151. * @returns the current particle system
  82152. */
  82153. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82154. /**
  82155. * Gets the current list of life time gradients.
  82156. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82157. * @returns the list of life time gradients
  82158. */
  82159. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82160. /**
  82161. * Gets the current list of color gradients.
  82162. * You must use addColorGradient and removeColorGradient to udpate this list
  82163. * @returns the list of color gradients
  82164. */
  82165. getColorGradients(): Nullable<Array<ColorGradient>>;
  82166. /**
  82167. * Adds a new ramp gradient used to remap particle colors
  82168. * @param gradient defines the gradient to use (between 0 and 1)
  82169. * @param color defines the color to affect to the specified gradient
  82170. * @returns the current particle system
  82171. */
  82172. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82173. /**
  82174. * Gets the current list of ramp gradients.
  82175. * You must use addRampGradient and removeRampGradient to udpate this list
  82176. * @returns the list of ramp gradients
  82177. */
  82178. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82179. /** Gets or sets a boolean indicating that ramp gradients must be used
  82180. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82181. */
  82182. useRampGradients: boolean;
  82183. /**
  82184. * Adds a new color remap gradient
  82185. * @param gradient defines the gradient to use (between 0 and 1)
  82186. * @param min defines the color remap minimal range
  82187. * @param max defines the color remap maximal range
  82188. * @returns the current particle system
  82189. */
  82190. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82191. /**
  82192. * Gets the current list of color remap gradients.
  82193. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82194. * @returns the list of color remap gradients
  82195. */
  82196. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82197. /**
  82198. * Adds a new alpha remap gradient
  82199. * @param gradient defines the gradient to use (between 0 and 1)
  82200. * @param min defines the alpha remap minimal range
  82201. * @param max defines the alpha remap maximal range
  82202. * @returns the current particle system
  82203. */
  82204. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82205. /**
  82206. * Gets the current list of alpha remap gradients.
  82207. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82208. * @returns the list of alpha remap gradients
  82209. */
  82210. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82211. /**
  82212. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82215. * @returns the emitter
  82216. */
  82217. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82218. /**
  82219. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82220. * @param radius The radius of the hemisphere to emit from
  82221. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82222. * @returns the emitter
  82223. */
  82224. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82225. /**
  82226. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82227. * @param radius The radius of the sphere to emit from
  82228. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82229. * @returns the emitter
  82230. */
  82231. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82232. /**
  82233. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82234. * @param radius The radius of the sphere to emit from
  82235. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82236. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82237. * @returns the emitter
  82238. */
  82239. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82240. /**
  82241. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82242. * @param radius The radius of the emission cylinder
  82243. * @param height The height of the emission cylinder
  82244. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82245. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82246. * @returns the emitter
  82247. */
  82248. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82249. /**
  82250. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82251. * @param radius The radius of the cylinder to emit from
  82252. * @param height The height of the emission cylinder
  82253. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82254. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82255. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82256. * @returns the emitter
  82257. */
  82258. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82259. /**
  82260. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82261. * @param radius The radius of the cone to emit from
  82262. * @param angle The base angle of the cone
  82263. * @returns the emitter
  82264. */
  82265. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82266. /**
  82267. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82268. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82269. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82270. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82271. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82272. * @returns the emitter
  82273. */
  82274. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82275. /**
  82276. * Get hosting scene
  82277. * @returns the scene
  82278. */
  82279. getScene(): Scene;
  82280. }
  82281. }
  82282. declare module BABYLON {
  82283. /**
  82284. * Creates an instance based on a source mesh.
  82285. */
  82286. export class InstancedMesh extends AbstractMesh {
  82287. private _sourceMesh;
  82288. private _currentLOD;
  82289. /** @hidden */
  82290. _indexInSourceMeshInstanceArray: number;
  82291. constructor(name: string, source: Mesh);
  82292. /**
  82293. * Returns the string "InstancedMesh".
  82294. */
  82295. getClassName(): string;
  82296. /** Gets the list of lights affecting that mesh */
  82297. readonly lightSources: Light[];
  82298. _resyncLightSources(): void;
  82299. _resyncLighSource(light: Light): void;
  82300. _removeLightSource(light: Light): void;
  82301. /**
  82302. * If the source mesh receives shadows
  82303. */
  82304. readonly receiveShadows: boolean;
  82305. /**
  82306. * The material of the source mesh
  82307. */
  82308. readonly material: Nullable<Material>;
  82309. /**
  82310. * Visibility of the source mesh
  82311. */
  82312. readonly visibility: number;
  82313. /**
  82314. * Skeleton of the source mesh
  82315. */
  82316. readonly skeleton: Nullable<Skeleton>;
  82317. /**
  82318. * Rendering ground id of the source mesh
  82319. */
  82320. renderingGroupId: number;
  82321. /**
  82322. * Returns the total number of vertices (integer).
  82323. */
  82324. getTotalVertices(): number;
  82325. /**
  82326. * Returns a positive integer : the total number of indices in this mesh geometry.
  82327. * @returns the numner of indices or zero if the mesh has no geometry.
  82328. */
  82329. getTotalIndices(): number;
  82330. /**
  82331. * The source mesh of the instance
  82332. */
  82333. readonly sourceMesh: Mesh;
  82334. /**
  82335. * Is this node ready to be used/rendered
  82336. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82337. * @return {boolean} is it ready
  82338. */
  82339. isReady(completeCheck?: boolean): boolean;
  82340. /**
  82341. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82342. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82343. * @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.
  82344. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82345. */
  82346. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82347. /**
  82348. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82349. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82350. * The `data` are either a numeric array either a Float32Array.
  82351. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82352. * 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).
  82353. * Note that a new underlying VertexBuffer object is created each call.
  82354. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82355. *
  82356. * Possible `kind` values :
  82357. * - VertexBuffer.PositionKind
  82358. * - VertexBuffer.UVKind
  82359. * - VertexBuffer.UV2Kind
  82360. * - VertexBuffer.UV3Kind
  82361. * - VertexBuffer.UV4Kind
  82362. * - VertexBuffer.UV5Kind
  82363. * - VertexBuffer.UV6Kind
  82364. * - VertexBuffer.ColorKind
  82365. * - VertexBuffer.MatricesIndicesKind
  82366. * - VertexBuffer.MatricesIndicesExtraKind
  82367. * - VertexBuffer.MatricesWeightsKind
  82368. * - VertexBuffer.MatricesWeightsExtraKind
  82369. *
  82370. * Returns the Mesh.
  82371. */
  82372. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82373. /**
  82374. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82375. * If the mesh has no geometry, it is simply returned as it is.
  82376. * The `data` are either a numeric array either a Float32Array.
  82377. * No new underlying VertexBuffer object is created.
  82378. * 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.
  82379. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82380. *
  82381. * Possible `kind` values :
  82382. * - VertexBuffer.PositionKind
  82383. * - VertexBuffer.UVKind
  82384. * - VertexBuffer.UV2Kind
  82385. * - VertexBuffer.UV3Kind
  82386. * - VertexBuffer.UV4Kind
  82387. * - VertexBuffer.UV5Kind
  82388. * - VertexBuffer.UV6Kind
  82389. * - VertexBuffer.ColorKind
  82390. * - VertexBuffer.MatricesIndicesKind
  82391. * - VertexBuffer.MatricesIndicesExtraKind
  82392. * - VertexBuffer.MatricesWeightsKind
  82393. * - VertexBuffer.MatricesWeightsExtraKind
  82394. *
  82395. * Returns the Mesh.
  82396. */
  82397. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82398. /**
  82399. * Sets the mesh indices.
  82400. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82401. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82402. * This method creates a new index buffer each call.
  82403. * Returns the Mesh.
  82404. */
  82405. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82406. /**
  82407. * Boolean : True if the mesh owns the requested kind of data.
  82408. */
  82409. isVerticesDataPresent(kind: string): boolean;
  82410. /**
  82411. * Returns an array of indices (IndicesArray).
  82412. */
  82413. getIndices(): Nullable<IndicesArray>;
  82414. readonly _positions: Nullable<Vector3[]>;
  82415. /**
  82416. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82417. * This means the mesh underlying bounding box and sphere are recomputed.
  82418. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82419. * @returns the current mesh
  82420. */
  82421. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82422. /** @hidden */
  82423. _preActivate(): InstancedMesh;
  82424. /** @hidden */
  82425. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82426. /** @hidden */
  82427. _postActivate(): void;
  82428. getWorldMatrix(): Matrix;
  82429. readonly isAnInstance: boolean;
  82430. /**
  82431. * Returns the current associated LOD AbstractMesh.
  82432. */
  82433. getLOD(camera: Camera): AbstractMesh;
  82434. /** @hidden */
  82435. _syncSubMeshes(): InstancedMesh;
  82436. /** @hidden */
  82437. _generatePointsArray(): boolean;
  82438. /**
  82439. * Creates a new InstancedMesh from the current mesh.
  82440. * - name (string) : the cloned mesh name
  82441. * - newParent (optional Node) : the optional Node to parent the clone to.
  82442. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82443. *
  82444. * Returns the clone.
  82445. */
  82446. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82447. /**
  82448. * Disposes the InstancedMesh.
  82449. * Returns nothing.
  82450. */
  82451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82452. }
  82453. }
  82454. declare module BABYLON {
  82455. /**
  82456. * Defines the options associated with the creation of a shader material.
  82457. */
  82458. export interface IShaderMaterialOptions {
  82459. /**
  82460. * Does the material work in alpha blend mode
  82461. */
  82462. needAlphaBlending: boolean;
  82463. /**
  82464. * Does the material work in alpha test mode
  82465. */
  82466. needAlphaTesting: boolean;
  82467. /**
  82468. * The list of attribute names used in the shader
  82469. */
  82470. attributes: string[];
  82471. /**
  82472. * The list of unifrom names used in the shader
  82473. */
  82474. uniforms: string[];
  82475. /**
  82476. * The list of UBO names used in the shader
  82477. */
  82478. uniformBuffers: string[];
  82479. /**
  82480. * The list of sampler names used in the shader
  82481. */
  82482. samplers: string[];
  82483. /**
  82484. * The list of defines used in the shader
  82485. */
  82486. defines: string[];
  82487. }
  82488. /**
  82489. * 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.
  82490. *
  82491. * This returned material effects how the mesh will look based on the code in the shaders.
  82492. *
  82493. * @see http://doc.babylonjs.com/how_to/shader_material
  82494. */
  82495. export class ShaderMaterial extends Material {
  82496. private _shaderPath;
  82497. private _options;
  82498. private _textures;
  82499. private _textureArrays;
  82500. private _floats;
  82501. private _ints;
  82502. private _floatsArrays;
  82503. private _colors3;
  82504. private _colors3Arrays;
  82505. private _colors4;
  82506. private _colors4Arrays;
  82507. private _vectors2;
  82508. private _vectors3;
  82509. private _vectors4;
  82510. private _matrices;
  82511. private _matrices3x3;
  82512. private _matrices2x2;
  82513. private _vectors2Arrays;
  82514. private _vectors3Arrays;
  82515. private _vectors4Arrays;
  82516. private _cachedWorldViewMatrix;
  82517. private _cachedWorldViewProjectionMatrix;
  82518. private _renderId;
  82519. /**
  82520. * Instantiate a new shader material.
  82521. * 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.
  82522. * This returned material effects how the mesh will look based on the code in the shaders.
  82523. * @see http://doc.babylonjs.com/how_to/shader_material
  82524. * @param name Define the name of the material in the scene
  82525. * @param scene Define the scene the material belongs to
  82526. * @param shaderPath Defines the route to the shader code in one of three ways:
  82527. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82528. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82529. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82530. * @param options Define the options used to create the shader
  82531. */
  82532. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82533. /**
  82534. * Gets the options used to compile the shader.
  82535. * They can be modified to trigger a new compilation
  82536. */
  82537. readonly options: IShaderMaterialOptions;
  82538. /**
  82539. * Gets the current class name of the material e.g. "ShaderMaterial"
  82540. * Mainly use in serialization.
  82541. * @returns the class name
  82542. */
  82543. getClassName(): string;
  82544. /**
  82545. * Specifies if the material will require alpha blending
  82546. * @returns a boolean specifying if alpha blending is needed
  82547. */
  82548. needAlphaBlending(): boolean;
  82549. /**
  82550. * Specifies if this material should be rendered in alpha test mode
  82551. * @returns a boolean specifying if an alpha test is needed.
  82552. */
  82553. needAlphaTesting(): boolean;
  82554. private _checkUniform;
  82555. /**
  82556. * Set a texture in the shader.
  82557. * @param name Define the name of the uniform samplers as defined in the shader
  82558. * @param texture Define the texture to bind to this sampler
  82559. * @return the material itself allowing "fluent" like uniform updates
  82560. */
  82561. setTexture(name: string, texture: Texture): ShaderMaterial;
  82562. /**
  82563. * Set a texture array in the shader.
  82564. * @param name Define the name of the uniform sampler array as defined in the shader
  82565. * @param textures Define the list of textures to bind to this sampler
  82566. * @return the material itself allowing "fluent" like uniform updates
  82567. */
  82568. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82569. /**
  82570. * Set a float in the shader.
  82571. * @param name Define the name of the uniform as defined in the shader
  82572. * @param value Define the value to give to the uniform
  82573. * @return the material itself allowing "fluent" like uniform updates
  82574. */
  82575. setFloat(name: string, value: number): ShaderMaterial;
  82576. /**
  82577. * Set a int in the shader.
  82578. * @param name Define the name of the uniform as defined in the shader
  82579. * @param value Define the value to give to the uniform
  82580. * @return the material itself allowing "fluent" like uniform updates
  82581. */
  82582. setInt(name: string, value: number): ShaderMaterial;
  82583. /**
  82584. * Set an array of floats in the shader.
  82585. * @param name Define the name of the uniform as defined in the shader
  82586. * @param value Define the value to give to the uniform
  82587. * @return the material itself allowing "fluent" like uniform updates
  82588. */
  82589. setFloats(name: string, value: number[]): ShaderMaterial;
  82590. /**
  82591. * Set a vec3 in the shader from a Color3.
  82592. * @param name Define the name of the uniform as defined in the shader
  82593. * @param value Define the value to give to the uniform
  82594. * @return the material itself allowing "fluent" like uniform updates
  82595. */
  82596. setColor3(name: string, value: Color3): ShaderMaterial;
  82597. /**
  82598. * Set a vec3 array in the shader from a Color3 array.
  82599. * @param name Define the name of the uniform as defined in the shader
  82600. * @param value Define the value to give to the uniform
  82601. * @return the material itself allowing "fluent" like uniform updates
  82602. */
  82603. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82604. /**
  82605. * Set a vec4 in the shader from a Color4.
  82606. * @param name Define the name of the uniform as defined in the shader
  82607. * @param value Define the value to give to the uniform
  82608. * @return the material itself allowing "fluent" like uniform updates
  82609. */
  82610. setColor4(name: string, value: Color4): ShaderMaterial;
  82611. /**
  82612. * Set a vec4 array in the shader from a Color4 array.
  82613. * @param name Define the name of the uniform as defined in the shader
  82614. * @param value Define the value to give to the uniform
  82615. * @return the material itself allowing "fluent" like uniform updates
  82616. */
  82617. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82618. /**
  82619. * Set a vec2 in the shader from a Vector2.
  82620. * @param name Define the name of the uniform as defined in the shader
  82621. * @param value Define the value to give to the uniform
  82622. * @return the material itself allowing "fluent" like uniform updates
  82623. */
  82624. setVector2(name: string, value: Vector2): ShaderMaterial;
  82625. /**
  82626. * Set a vec3 in the shader from a Vector3.
  82627. * @param name Define the name of the uniform as defined in the shader
  82628. * @param value Define the value to give to the uniform
  82629. * @return the material itself allowing "fluent" like uniform updates
  82630. */
  82631. setVector3(name: string, value: Vector3): ShaderMaterial;
  82632. /**
  82633. * Set a vec4 in the shader from a Vector4.
  82634. * @param name Define the name of the uniform as defined in the shader
  82635. * @param value Define the value to give to the uniform
  82636. * @return the material itself allowing "fluent" like uniform updates
  82637. */
  82638. setVector4(name: string, value: Vector4): ShaderMaterial;
  82639. /**
  82640. * Set a mat4 in the shader from a Matrix.
  82641. * @param name Define the name of the uniform as defined in the shader
  82642. * @param value Define the value to give to the uniform
  82643. * @return the material itself allowing "fluent" like uniform updates
  82644. */
  82645. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82646. /**
  82647. * Set a mat3 in the shader from a Float32Array.
  82648. * @param name Define the name of the uniform as defined in the shader
  82649. * @param value Define the value to give to the uniform
  82650. * @return the material itself allowing "fluent" like uniform updates
  82651. */
  82652. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82653. /**
  82654. * Set a mat2 in the shader from a Float32Array.
  82655. * @param name Define the name of the uniform as defined in the shader
  82656. * @param value Define the value to give to the uniform
  82657. * @return the material itself allowing "fluent" like uniform updates
  82658. */
  82659. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82660. /**
  82661. * Set a vec2 array in the shader from a number array.
  82662. * @param name Define the name of the uniform as defined in the shader
  82663. * @param value Define the value to give to the uniform
  82664. * @return the material itself allowing "fluent" like uniform updates
  82665. */
  82666. setArray2(name: string, value: number[]): ShaderMaterial;
  82667. /**
  82668. * Set a vec3 array in the shader from a number array.
  82669. * @param name Define the name of the uniform as defined in the shader
  82670. * @param value Define the value to give to the uniform
  82671. * @return the material itself allowing "fluent" like uniform updates
  82672. */
  82673. setArray3(name: string, value: number[]): ShaderMaterial;
  82674. /**
  82675. * Set a vec4 array in the shader from a number array.
  82676. * @param name Define the name of the uniform as defined in the shader
  82677. * @param value Define the value to give to the uniform
  82678. * @return the material itself allowing "fluent" like uniform updates
  82679. */
  82680. setArray4(name: string, value: number[]): ShaderMaterial;
  82681. private _checkCache;
  82682. /**
  82683. * Specifies that the submesh is ready to be used
  82684. * @param mesh defines the mesh to check
  82685. * @param subMesh defines which submesh to check
  82686. * @param useInstances specifies that instances should be used
  82687. * @returns a boolean indicating that the submesh is ready or not
  82688. */
  82689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82690. /**
  82691. * Checks if the material is ready to render the requested mesh
  82692. * @param mesh Define the mesh to render
  82693. * @param useInstances Define whether or not the material is used with instances
  82694. * @returns true if ready, otherwise false
  82695. */
  82696. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82697. /**
  82698. * Binds the world matrix to the material
  82699. * @param world defines the world transformation matrix
  82700. */
  82701. bindOnlyWorldMatrix(world: Matrix): void;
  82702. /**
  82703. * Binds the material to the mesh
  82704. * @param world defines the world transformation matrix
  82705. * @param mesh defines the mesh to bind the material to
  82706. */
  82707. bind(world: Matrix, mesh?: Mesh): void;
  82708. /**
  82709. * Gets the active textures from the material
  82710. * @returns an array of textures
  82711. */
  82712. getActiveTextures(): BaseTexture[];
  82713. /**
  82714. * Specifies if the material uses a texture
  82715. * @param texture defines the texture to check against the material
  82716. * @returns a boolean specifying if the material uses the texture
  82717. */
  82718. hasTexture(texture: BaseTexture): boolean;
  82719. /**
  82720. * Makes a duplicate of the material, and gives it a new name
  82721. * @param name defines the new name for the duplicated material
  82722. * @returns the cloned material
  82723. */
  82724. clone(name: string): ShaderMaterial;
  82725. /**
  82726. * Disposes the material
  82727. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82728. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82729. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82730. */
  82731. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82732. /**
  82733. * Serializes this material in a JSON representation
  82734. * @returns the serialized material object
  82735. */
  82736. serialize(): any;
  82737. /**
  82738. * Creates a shader material from parsed shader material data
  82739. * @param source defines the JSON represnetation of the material
  82740. * @param scene defines the hosting scene
  82741. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82742. * @returns a new material
  82743. */
  82744. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82745. }
  82746. }
  82747. declare module BABYLON {
  82748. /** @hidden */
  82749. export var colorPixelShader: {
  82750. name: string;
  82751. shader: string;
  82752. };
  82753. }
  82754. declare module BABYLON {
  82755. /** @hidden */
  82756. export var colorVertexShader: {
  82757. name: string;
  82758. shader: string;
  82759. };
  82760. }
  82761. declare module BABYLON {
  82762. /**
  82763. * Line mesh
  82764. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82765. */
  82766. export class LinesMesh extends Mesh {
  82767. /**
  82768. * If vertex color should be applied to the mesh
  82769. */
  82770. readonly useVertexColor?: boolean | undefined;
  82771. /**
  82772. * If vertex alpha should be applied to the mesh
  82773. */
  82774. readonly useVertexAlpha?: boolean | undefined;
  82775. /**
  82776. * Color of the line (Default: White)
  82777. */
  82778. color: Color3;
  82779. /**
  82780. * Alpha of the line (Default: 1)
  82781. */
  82782. alpha: number;
  82783. /**
  82784. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82785. * This margin is expressed in world space coordinates, so its value may vary.
  82786. * Default value is 0.1
  82787. */
  82788. intersectionThreshold: number;
  82789. private _colorShader;
  82790. private color4;
  82791. /**
  82792. * Creates a new LinesMesh
  82793. * @param name defines the name
  82794. * @param scene defines the hosting scene
  82795. * @param parent defines the parent mesh if any
  82796. * @param source defines the optional source LinesMesh used to clone data from
  82797. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82798. * When false, achieved by calling a clone(), also passing False.
  82799. * This will make creation of children, recursive.
  82800. * @param useVertexColor defines if this LinesMesh supports vertex color
  82801. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82802. */
  82803. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82804. /**
  82805. * If vertex color should be applied to the mesh
  82806. */
  82807. useVertexColor?: boolean | undefined,
  82808. /**
  82809. * If vertex alpha should be applied to the mesh
  82810. */
  82811. useVertexAlpha?: boolean | undefined);
  82812. private _addClipPlaneDefine;
  82813. private _removeClipPlaneDefine;
  82814. isReady(): boolean;
  82815. /**
  82816. * Returns the string "LineMesh"
  82817. */
  82818. getClassName(): string;
  82819. /**
  82820. * @hidden
  82821. */
  82822. /**
  82823. * @hidden
  82824. */
  82825. material: Material;
  82826. /**
  82827. * @hidden
  82828. */
  82829. readonly checkCollisions: boolean;
  82830. /** @hidden */
  82831. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82832. /** @hidden */
  82833. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82834. /**
  82835. * Disposes of the line mesh
  82836. * @param doNotRecurse If children should be disposed
  82837. */
  82838. dispose(doNotRecurse?: boolean): void;
  82839. /**
  82840. * Returns a new LineMesh object cloned from the current one.
  82841. */
  82842. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  82843. /**
  82844. * Creates a new InstancedLinesMesh object from the mesh model.
  82845. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82846. * @param name defines the name of the new instance
  82847. * @returns a new InstancedLinesMesh
  82848. */
  82849. createInstance(name: string): InstancedLinesMesh;
  82850. }
  82851. /**
  82852. * Creates an instance based on a source LinesMesh
  82853. */
  82854. export class InstancedLinesMesh extends InstancedMesh {
  82855. /**
  82856. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82857. * This margin is expressed in world space coordinates, so its value may vary.
  82858. * Initilized with the intersectionThreshold value of the source LinesMesh
  82859. */
  82860. intersectionThreshold: number;
  82861. constructor(name: string, source: LinesMesh);
  82862. /**
  82863. * Returns the string "InstancedLinesMesh".
  82864. */
  82865. getClassName(): string;
  82866. }
  82867. }
  82868. declare module BABYLON {
  82869. /** @hidden */
  82870. export var linePixelShader: {
  82871. name: string;
  82872. shader: string;
  82873. };
  82874. }
  82875. declare module BABYLON {
  82876. /** @hidden */
  82877. export var lineVertexShader: {
  82878. name: string;
  82879. shader: string;
  82880. };
  82881. }
  82882. declare module BABYLON {
  82883. interface AbstractMesh {
  82884. /**
  82885. * Gets the edgesRenderer associated with the mesh
  82886. */
  82887. edgesRenderer: Nullable<EdgesRenderer>;
  82888. }
  82889. interface LinesMesh {
  82890. /**
  82891. * Enables the edge rendering mode on the mesh.
  82892. * This mode makes the mesh edges visible
  82893. * @param epsilon defines the maximal distance between two angles to detect a face
  82894. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82895. * @returns the currentAbstractMesh
  82896. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82897. */
  82898. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  82899. }
  82900. interface InstancedLinesMesh {
  82901. /**
  82902. * Enables the edge rendering mode on the mesh.
  82903. * This mode makes the mesh edges visible
  82904. * @param epsilon defines the maximal distance between two angles to detect a face
  82905. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82906. * @returns the current InstancedLinesMesh
  82907. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82908. */
  82909. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  82910. }
  82911. /**
  82912. * Defines the minimum contract an Edges renderer should follow.
  82913. */
  82914. export interface IEdgesRenderer extends IDisposable {
  82915. /**
  82916. * Gets or sets a boolean indicating if the edgesRenderer is active
  82917. */
  82918. isEnabled: boolean;
  82919. /**
  82920. * Renders the edges of the attached mesh,
  82921. */
  82922. render(): void;
  82923. /**
  82924. * Checks wether or not the edges renderer is ready to render.
  82925. * @return true if ready, otherwise false.
  82926. */
  82927. isReady(): boolean;
  82928. }
  82929. /**
  82930. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  82931. */
  82932. export class EdgesRenderer implements IEdgesRenderer {
  82933. /**
  82934. * Define the size of the edges with an orthographic camera
  82935. */
  82936. edgesWidthScalerForOrthographic: number;
  82937. /**
  82938. * Define the size of the edges with a perspective camera
  82939. */
  82940. edgesWidthScalerForPerspective: number;
  82941. protected _source: AbstractMesh;
  82942. protected _linesPositions: number[];
  82943. protected _linesNormals: number[];
  82944. protected _linesIndices: number[];
  82945. protected _epsilon: number;
  82946. protected _indicesCount: number;
  82947. protected _lineShader: ShaderMaterial;
  82948. protected _ib: DataBuffer;
  82949. protected _buffers: {
  82950. [key: string]: Nullable<VertexBuffer>;
  82951. };
  82952. protected _checkVerticesInsteadOfIndices: boolean;
  82953. private _meshRebuildObserver;
  82954. private _meshDisposeObserver;
  82955. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  82956. isEnabled: boolean;
  82957. /**
  82958. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  82959. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  82960. * @param source Mesh used to create edges
  82961. * @param epsilon sum of angles in adjacency to check for edge
  82962. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  82963. * @param generateEdgesLines - should generate Lines or only prepare resources.
  82964. */
  82965. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  82966. protected _prepareRessources(): void;
  82967. /** @hidden */
  82968. _rebuild(): void;
  82969. /**
  82970. * Releases the required resources for the edges renderer
  82971. */
  82972. dispose(): void;
  82973. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  82974. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  82975. /**
  82976. * Checks if the pair of p0 and p1 is en edge
  82977. * @param faceIndex
  82978. * @param edge
  82979. * @param faceNormals
  82980. * @param p0
  82981. * @param p1
  82982. * @private
  82983. */
  82984. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  82985. /**
  82986. * push line into the position, normal and index buffer
  82987. * @protected
  82988. */
  82989. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  82990. /**
  82991. * Generates lines edges from adjacencjes
  82992. * @private
  82993. */
  82994. _generateEdgesLines(): void;
  82995. /**
  82996. * Checks wether or not the edges renderer is ready to render.
  82997. * @return true if ready, otherwise false.
  82998. */
  82999. isReady(): boolean;
  83000. /**
  83001. * Renders the edges of the attached mesh,
  83002. */
  83003. render(): void;
  83004. }
  83005. /**
  83006. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  83007. */
  83008. export class LineEdgesRenderer extends EdgesRenderer {
  83009. /**
  83010. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  83011. * @param source LineMesh used to generate edges
  83012. * @param epsilon not important (specified angle for edge detection)
  83013. * @param checkVerticesInsteadOfIndices not important for LineMesh
  83014. */
  83015. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  83016. /**
  83017. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  83018. */
  83019. _generateEdgesLines(): void;
  83020. }
  83021. }
  83022. declare module BABYLON {
  83023. /**
  83024. * This represents the object necessary to create a rendering group.
  83025. * This is exclusively used and created by the rendering manager.
  83026. * To modify the behavior, you use the available helpers in your scene or meshes.
  83027. * @hidden
  83028. */
  83029. export class RenderingGroup {
  83030. index: number;
  83031. private static _zeroVector;
  83032. private _scene;
  83033. private _opaqueSubMeshes;
  83034. private _transparentSubMeshes;
  83035. private _alphaTestSubMeshes;
  83036. private _depthOnlySubMeshes;
  83037. private _particleSystems;
  83038. private _spriteManagers;
  83039. private _opaqueSortCompareFn;
  83040. private _alphaTestSortCompareFn;
  83041. private _transparentSortCompareFn;
  83042. private _renderOpaque;
  83043. private _renderAlphaTest;
  83044. private _renderTransparent;
  83045. /** @hidden */
  83046. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83047. onBeforeTransparentRendering: () => void;
  83048. /**
  83049. * Set the opaque sort comparison function.
  83050. * If null the sub meshes will be render in the order they were created
  83051. */
  83052. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83053. /**
  83054. * Set the alpha test sort comparison function.
  83055. * If null the sub meshes will be render in the order they were created
  83056. */
  83057. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83058. /**
  83059. * Set the transparent sort comparison function.
  83060. * If null the sub meshes will be render in the order they were created
  83061. */
  83062. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83063. /**
  83064. * Creates a new rendering group.
  83065. * @param index The rendering group index
  83066. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83067. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83068. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83069. */
  83070. 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>);
  83071. /**
  83072. * Render all the sub meshes contained in the group.
  83073. * @param customRenderFunction Used to override the default render behaviour of the group.
  83074. * @returns true if rendered some submeshes.
  83075. */
  83076. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83077. /**
  83078. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83079. * @param subMeshes The submeshes to render
  83080. */
  83081. private renderOpaqueSorted;
  83082. /**
  83083. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83084. * @param subMeshes The submeshes to render
  83085. */
  83086. private renderAlphaTestSorted;
  83087. /**
  83088. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83089. * @param subMeshes The submeshes to render
  83090. */
  83091. private renderTransparentSorted;
  83092. /**
  83093. * Renders the submeshes in a specified order.
  83094. * @param subMeshes The submeshes to sort before render
  83095. * @param sortCompareFn The comparison function use to sort
  83096. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83097. * @param transparent Specifies to activate blending if true
  83098. */
  83099. private static renderSorted;
  83100. /**
  83101. * Renders the submeshes in the order they were dispatched (no sort applied).
  83102. * @param subMeshes The submeshes to render
  83103. */
  83104. private static renderUnsorted;
  83105. /**
  83106. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83107. * are rendered back to front if in the same alpha index.
  83108. *
  83109. * @param a The first submesh
  83110. * @param b The second submesh
  83111. * @returns The result of the comparison
  83112. */
  83113. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83114. /**
  83115. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83116. * are rendered back to front.
  83117. *
  83118. * @param a The first submesh
  83119. * @param b The second submesh
  83120. * @returns The result of the comparison
  83121. */
  83122. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83123. /**
  83124. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83125. * are rendered front to back (prevent overdraw).
  83126. *
  83127. * @param a The first submesh
  83128. * @param b The second submesh
  83129. * @returns The result of the comparison
  83130. */
  83131. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83132. /**
  83133. * Resets the different lists of submeshes to prepare a new frame.
  83134. */
  83135. prepare(): void;
  83136. dispose(): void;
  83137. /**
  83138. * Inserts the submesh in its correct queue depending on its material.
  83139. * @param subMesh The submesh to dispatch
  83140. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83141. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83142. */
  83143. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83144. dispatchSprites(spriteManager: ISpriteManager): void;
  83145. dispatchParticles(particleSystem: IParticleSystem): void;
  83146. private _renderParticles;
  83147. private _renderSprites;
  83148. }
  83149. }
  83150. declare module BABYLON {
  83151. /**
  83152. * Interface describing the different options available in the rendering manager
  83153. * regarding Auto Clear between groups.
  83154. */
  83155. export interface IRenderingManagerAutoClearSetup {
  83156. /**
  83157. * Defines whether or not autoclear is enable.
  83158. */
  83159. autoClear: boolean;
  83160. /**
  83161. * Defines whether or not to autoclear the depth buffer.
  83162. */
  83163. depth: boolean;
  83164. /**
  83165. * Defines whether or not to autoclear the stencil buffer.
  83166. */
  83167. stencil: boolean;
  83168. }
  83169. /**
  83170. * This class is used by the onRenderingGroupObservable
  83171. */
  83172. export class RenderingGroupInfo {
  83173. /**
  83174. * The Scene that being rendered
  83175. */
  83176. scene: Scene;
  83177. /**
  83178. * The camera currently used for the rendering pass
  83179. */
  83180. camera: Nullable<Camera>;
  83181. /**
  83182. * The ID of the renderingGroup being processed
  83183. */
  83184. renderingGroupId: number;
  83185. }
  83186. /**
  83187. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83188. * It is enable to manage the different groups as well as the different necessary sort functions.
  83189. * This should not be used directly aside of the few static configurations
  83190. */
  83191. export class RenderingManager {
  83192. /**
  83193. * The max id used for rendering groups (not included)
  83194. */
  83195. static MAX_RENDERINGGROUPS: number;
  83196. /**
  83197. * The min id used for rendering groups (included)
  83198. */
  83199. static MIN_RENDERINGGROUPS: number;
  83200. /**
  83201. * Used to globally prevent autoclearing scenes.
  83202. */
  83203. static AUTOCLEAR: boolean;
  83204. /**
  83205. * @hidden
  83206. */
  83207. _useSceneAutoClearSetup: boolean;
  83208. private _scene;
  83209. private _renderingGroups;
  83210. private _depthStencilBufferAlreadyCleaned;
  83211. private _autoClearDepthStencil;
  83212. private _customOpaqueSortCompareFn;
  83213. private _customAlphaTestSortCompareFn;
  83214. private _customTransparentSortCompareFn;
  83215. private _renderingGroupInfo;
  83216. /**
  83217. * Instantiates a new rendering group for a particular scene
  83218. * @param scene Defines the scene the groups belongs to
  83219. */
  83220. constructor(scene: Scene);
  83221. private _clearDepthStencilBuffer;
  83222. /**
  83223. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83224. * @hidden
  83225. */
  83226. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83227. /**
  83228. * Resets the different information of the group to prepare a new frame
  83229. * @hidden
  83230. */
  83231. reset(): void;
  83232. /**
  83233. * Dispose and release the group and its associated resources.
  83234. * @hidden
  83235. */
  83236. dispose(): void;
  83237. /**
  83238. * Clear the info related to rendering groups preventing retention points during dispose.
  83239. */
  83240. freeRenderingGroups(): void;
  83241. private _prepareRenderingGroup;
  83242. /**
  83243. * Add a sprite manager to the rendering manager in order to render it this frame.
  83244. * @param spriteManager Define the sprite manager to render
  83245. */
  83246. dispatchSprites(spriteManager: ISpriteManager): void;
  83247. /**
  83248. * Add a particle system to the rendering manager in order to render it this frame.
  83249. * @param particleSystem Define the particle system to render
  83250. */
  83251. dispatchParticles(particleSystem: IParticleSystem): void;
  83252. /**
  83253. * Add a submesh to the manager in order to render it this frame
  83254. * @param subMesh The submesh to dispatch
  83255. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83256. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83257. */
  83258. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83259. /**
  83260. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83261. * This allowed control for front to back rendering or reversly depending of the special needs.
  83262. *
  83263. * @param renderingGroupId The rendering group id corresponding to its index
  83264. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83265. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83266. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83267. */
  83268. 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;
  83269. /**
  83270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83271. *
  83272. * @param renderingGroupId The rendering group id corresponding to its index
  83273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83274. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83275. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83276. */
  83277. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83278. /**
  83279. * Gets the current auto clear configuration for one rendering group of the rendering
  83280. * manager.
  83281. * @param index the rendering group index to get the information for
  83282. * @returns The auto clear setup for the requested rendering group
  83283. */
  83284. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83285. }
  83286. }
  83287. declare module BABYLON {
  83288. /**
  83289. * This Helps creating a texture that will be created from a camera in your scene.
  83290. * It is basically a dynamic texture that could be used to create special effects for instance.
  83291. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83292. */
  83293. export class RenderTargetTexture extends Texture {
  83294. isCube: boolean;
  83295. /**
  83296. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83297. */
  83298. static readonly REFRESHRATE_RENDER_ONCE: number;
  83299. /**
  83300. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83301. */
  83302. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83303. /**
  83304. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83305. * the central point of your effect and can save a lot of performances.
  83306. */
  83307. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83308. /**
  83309. * Use this predicate to dynamically define the list of mesh you want to render.
  83310. * If set, the renderList property will be overwritten.
  83311. */
  83312. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83313. private _renderList;
  83314. /**
  83315. * Use this list to define the list of mesh you want to render.
  83316. */
  83317. renderList: Nullable<Array<AbstractMesh>>;
  83318. private _hookArray;
  83319. /**
  83320. * Define if particles should be rendered in your texture.
  83321. */
  83322. renderParticles: boolean;
  83323. /**
  83324. * Define if sprites should be rendered in your texture.
  83325. */
  83326. renderSprites: boolean;
  83327. /**
  83328. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83329. */
  83330. coordinatesMode: number;
  83331. /**
  83332. * Define the camera used to render the texture.
  83333. */
  83334. activeCamera: Nullable<Camera>;
  83335. /**
  83336. * Override the render function of the texture with your own one.
  83337. */
  83338. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83339. /**
  83340. * Define if camera post processes should be use while rendering the texture.
  83341. */
  83342. useCameraPostProcesses: boolean;
  83343. /**
  83344. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83345. */
  83346. ignoreCameraViewport: boolean;
  83347. private _postProcessManager;
  83348. private _postProcesses;
  83349. private _resizeObserver;
  83350. /**
  83351. * An event triggered when the texture is unbind.
  83352. */
  83353. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83354. /**
  83355. * An event triggered when the texture is unbind.
  83356. */
  83357. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83358. private _onAfterUnbindObserver;
  83359. /**
  83360. * Set a after unbind callback in the texture.
  83361. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83362. */
  83363. onAfterUnbind: () => void;
  83364. /**
  83365. * An event triggered before rendering the texture
  83366. */
  83367. onBeforeRenderObservable: Observable<number>;
  83368. private _onBeforeRenderObserver;
  83369. /**
  83370. * Set a before render callback in the texture.
  83371. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83372. */
  83373. onBeforeRender: (faceIndex: number) => void;
  83374. /**
  83375. * An event triggered after rendering the texture
  83376. */
  83377. onAfterRenderObservable: Observable<number>;
  83378. private _onAfterRenderObserver;
  83379. /**
  83380. * Set a after render callback in the texture.
  83381. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83382. */
  83383. onAfterRender: (faceIndex: number) => void;
  83384. /**
  83385. * An event triggered after the texture clear
  83386. */
  83387. onClearObservable: Observable<Engine>;
  83388. private _onClearObserver;
  83389. /**
  83390. * Set a clear callback in the texture.
  83391. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83392. */
  83393. onClear: (Engine: Engine) => void;
  83394. /**
  83395. * Define the clear color of the Render Target if it should be different from the scene.
  83396. */
  83397. clearColor: Color4;
  83398. protected _size: number | {
  83399. width: number;
  83400. height: number;
  83401. };
  83402. protected _initialSizeParameter: number | {
  83403. width: number;
  83404. height: number;
  83405. } | {
  83406. ratio: number;
  83407. };
  83408. protected _sizeRatio: Nullable<number>;
  83409. /** @hidden */
  83410. _generateMipMaps: boolean;
  83411. protected _renderingManager: RenderingManager;
  83412. /** @hidden */
  83413. _waitingRenderList: string[];
  83414. protected _doNotChangeAspectRatio: boolean;
  83415. protected _currentRefreshId: number;
  83416. protected _refreshRate: number;
  83417. protected _textureMatrix: Matrix;
  83418. protected _samples: number;
  83419. protected _renderTargetOptions: RenderTargetCreationOptions;
  83420. /**
  83421. * Gets render target creation options that were used.
  83422. */
  83423. readonly renderTargetOptions: RenderTargetCreationOptions;
  83424. protected _engine: Engine;
  83425. protected _onRatioRescale(): void;
  83426. /**
  83427. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83428. * It must define where the camera used to render the texture is set
  83429. */
  83430. boundingBoxPosition: Vector3;
  83431. private _boundingBoxSize;
  83432. /**
  83433. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83434. * When defined, the cubemap will switch to local mode
  83435. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83436. * @example https://www.babylonjs-playground.com/#RNASML
  83437. */
  83438. boundingBoxSize: Vector3;
  83439. /**
  83440. * In case the RTT has been created with a depth texture, get the associated
  83441. * depth texture.
  83442. * Otherwise, return null.
  83443. */
  83444. depthStencilTexture: Nullable<InternalTexture>;
  83445. /**
  83446. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83447. * or used a shadow, depth texture...
  83448. * @param name The friendly name of the texture
  83449. * @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)
  83450. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83451. * @param generateMipMaps True if mip maps need to be generated after render.
  83452. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83453. * @param type The type of the buffer in the RTT (int, half float, float...)
  83454. * @param isCube True if a cube texture needs to be created
  83455. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83456. * @param generateDepthBuffer True to generate a depth buffer
  83457. * @param generateStencilBuffer True to generate a stencil buffer
  83458. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83459. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83460. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83461. */
  83462. constructor(name: string, size: number | {
  83463. width: number;
  83464. height: number;
  83465. } | {
  83466. ratio: number;
  83467. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83468. /**
  83469. * Creates a depth stencil texture.
  83470. * This is only available in WebGL 2 or with the depth texture extension available.
  83471. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83472. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83473. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83474. */
  83475. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83476. private _processSizeParameter;
  83477. /**
  83478. * Define the number of samples to use in case of MSAA.
  83479. * It defaults to one meaning no MSAA has been enabled.
  83480. */
  83481. samples: number;
  83482. /**
  83483. * Resets the refresh counter of the texture and start bak from scratch.
  83484. * Could be useful to regenerate the texture if it is setup to render only once.
  83485. */
  83486. resetRefreshCounter(): void;
  83487. /**
  83488. * Define the refresh rate of the texture or the rendering frequency.
  83489. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83490. */
  83491. refreshRate: number;
  83492. /**
  83493. * Adds a post process to the render target rendering passes.
  83494. * @param postProcess define the post process to add
  83495. */
  83496. addPostProcess(postProcess: PostProcess): void;
  83497. /**
  83498. * Clear all the post processes attached to the render target
  83499. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83500. */
  83501. clearPostProcesses(dispose?: boolean): void;
  83502. /**
  83503. * Remove one of the post process from the list of attached post processes to the texture
  83504. * @param postProcess define the post process to remove from the list
  83505. */
  83506. removePostProcess(postProcess: PostProcess): void;
  83507. /** @hidden */
  83508. _shouldRender(): boolean;
  83509. /**
  83510. * Gets the actual render size of the texture.
  83511. * @returns the width of the render size
  83512. */
  83513. getRenderSize(): number;
  83514. /**
  83515. * Gets the actual render width of the texture.
  83516. * @returns the width of the render size
  83517. */
  83518. getRenderWidth(): number;
  83519. /**
  83520. * Gets the actual render height of the texture.
  83521. * @returns the height of the render size
  83522. */
  83523. getRenderHeight(): number;
  83524. /**
  83525. * Get if the texture can be rescaled or not.
  83526. */
  83527. readonly canRescale: boolean;
  83528. /**
  83529. * Resize the texture using a ratio.
  83530. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83531. */
  83532. scale(ratio: number): void;
  83533. /**
  83534. * Get the texture reflection matrix used to rotate/transform the reflection.
  83535. * @returns the reflection matrix
  83536. */
  83537. getReflectionTextureMatrix(): Matrix;
  83538. /**
  83539. * Resize the texture to a new desired size.
  83540. * Be carrefull as it will recreate all the data in the new texture.
  83541. * @param size Define the new size. It can be:
  83542. * - a number for squared texture,
  83543. * - an object containing { width: number, height: number }
  83544. * - or an object containing a ratio { ratio: number }
  83545. */
  83546. resize(size: number | {
  83547. width: number;
  83548. height: number;
  83549. } | {
  83550. ratio: number;
  83551. }): void;
  83552. /**
  83553. * Renders all the objects from the render list into the texture.
  83554. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83555. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83556. */
  83557. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83558. private _bestReflectionRenderTargetDimension;
  83559. /**
  83560. * @hidden
  83561. * @param faceIndex face index to bind to if this is a cubetexture
  83562. */
  83563. _bindFrameBuffer(faceIndex?: number): void;
  83564. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83565. private renderToTarget;
  83566. /**
  83567. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83568. * This allowed control for front to back rendering or reversly depending of the special needs.
  83569. *
  83570. * @param renderingGroupId The rendering group id corresponding to its index
  83571. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83572. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83573. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83574. */
  83575. 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;
  83576. /**
  83577. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83578. *
  83579. * @param renderingGroupId The rendering group id corresponding to its index
  83580. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83581. */
  83582. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83583. /**
  83584. * Clones the texture.
  83585. * @returns the cloned texture
  83586. */
  83587. clone(): RenderTargetTexture;
  83588. /**
  83589. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83590. * @returns The JSON representation of the texture
  83591. */
  83592. serialize(): any;
  83593. /**
  83594. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83595. */
  83596. disposeFramebufferObjects(): void;
  83597. /**
  83598. * Dispose the texture and release its associated resources.
  83599. */
  83600. dispose(): void;
  83601. /** @hidden */
  83602. _rebuild(): void;
  83603. /**
  83604. * Clear the info related to rendering groups preventing retention point in material dispose.
  83605. */
  83606. freeRenderingGroups(): void;
  83607. /**
  83608. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83609. * @returns the view count
  83610. */
  83611. getViewCount(): number;
  83612. }
  83613. }
  83614. declare module BABYLON {
  83615. /**
  83616. * Base class for the main features of a material in Babylon.js
  83617. */
  83618. export class Material implements IAnimatable {
  83619. /**
  83620. * Returns the triangle fill mode
  83621. */
  83622. static readonly TriangleFillMode: number;
  83623. /**
  83624. * Returns the wireframe mode
  83625. */
  83626. static readonly WireFrameFillMode: number;
  83627. /**
  83628. * Returns the point fill mode
  83629. */
  83630. static readonly PointFillMode: number;
  83631. /**
  83632. * Returns the point list draw mode
  83633. */
  83634. static readonly PointListDrawMode: number;
  83635. /**
  83636. * Returns the line list draw mode
  83637. */
  83638. static readonly LineListDrawMode: number;
  83639. /**
  83640. * Returns the line loop draw mode
  83641. */
  83642. static readonly LineLoopDrawMode: number;
  83643. /**
  83644. * Returns the line strip draw mode
  83645. */
  83646. static readonly LineStripDrawMode: number;
  83647. /**
  83648. * Returns the triangle strip draw mode
  83649. */
  83650. static readonly TriangleStripDrawMode: number;
  83651. /**
  83652. * Returns the triangle fan draw mode
  83653. */
  83654. static readonly TriangleFanDrawMode: number;
  83655. /**
  83656. * Stores the clock-wise side orientation
  83657. */
  83658. static readonly ClockWiseSideOrientation: number;
  83659. /**
  83660. * Stores the counter clock-wise side orientation
  83661. */
  83662. static readonly CounterClockWiseSideOrientation: number;
  83663. /**
  83664. * The dirty texture flag value
  83665. */
  83666. static readonly TextureDirtyFlag: number;
  83667. /**
  83668. * The dirty light flag value
  83669. */
  83670. static readonly LightDirtyFlag: number;
  83671. /**
  83672. * The dirty fresnel flag value
  83673. */
  83674. static readonly FresnelDirtyFlag: number;
  83675. /**
  83676. * The dirty attribute flag value
  83677. */
  83678. static readonly AttributesDirtyFlag: number;
  83679. /**
  83680. * The dirty misc flag value
  83681. */
  83682. static readonly MiscDirtyFlag: number;
  83683. /**
  83684. * The all dirty flag value
  83685. */
  83686. static readonly AllDirtyFlag: number;
  83687. /**
  83688. * The ID of the material
  83689. */
  83690. id: string;
  83691. /**
  83692. * Gets or sets the unique id of the material
  83693. */
  83694. uniqueId: number;
  83695. /**
  83696. * The name of the material
  83697. */
  83698. name: string;
  83699. /**
  83700. * Gets or sets user defined metadata
  83701. */
  83702. metadata: any;
  83703. /**
  83704. * For internal use only. Please do not use.
  83705. */
  83706. reservedDataStore: any;
  83707. /**
  83708. * Specifies if the ready state should be checked on each call
  83709. */
  83710. checkReadyOnEveryCall: boolean;
  83711. /**
  83712. * Specifies if the ready state should be checked once
  83713. */
  83714. checkReadyOnlyOnce: boolean;
  83715. /**
  83716. * The state of the material
  83717. */
  83718. state: string;
  83719. /**
  83720. * The alpha value of the material
  83721. */
  83722. protected _alpha: number;
  83723. /**
  83724. * List of inspectable custom properties (used by the Inspector)
  83725. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83726. */
  83727. inspectableCustomProperties: IInspectable[];
  83728. /**
  83729. * Sets the alpha value of the material
  83730. */
  83731. /**
  83732. * Gets the alpha value of the material
  83733. */
  83734. alpha: number;
  83735. /**
  83736. * Specifies if back face culling is enabled
  83737. */
  83738. protected _backFaceCulling: boolean;
  83739. /**
  83740. * Sets the back-face culling state
  83741. */
  83742. /**
  83743. * Gets the back-face culling state
  83744. */
  83745. backFaceCulling: boolean;
  83746. /**
  83747. * Stores the value for side orientation
  83748. */
  83749. sideOrientation: number;
  83750. /**
  83751. * Callback triggered when the material is compiled
  83752. */
  83753. onCompiled: Nullable<(effect: Effect) => void>;
  83754. /**
  83755. * Callback triggered when an error occurs
  83756. */
  83757. onError: Nullable<(effect: Effect, errors: string) => void>;
  83758. /**
  83759. * Callback triggered to get the render target textures
  83760. */
  83761. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83762. /**
  83763. * Gets a boolean indicating that current material needs to register RTT
  83764. */
  83765. readonly hasRenderTargetTextures: boolean;
  83766. /**
  83767. * Specifies if the material should be serialized
  83768. */
  83769. doNotSerialize: boolean;
  83770. /**
  83771. * @hidden
  83772. */
  83773. _storeEffectOnSubMeshes: boolean;
  83774. /**
  83775. * Stores the animations for the material
  83776. */
  83777. animations: Nullable<Array<Animation>>;
  83778. /**
  83779. * An event triggered when the material is disposed
  83780. */
  83781. onDisposeObservable: Observable<Material>;
  83782. /**
  83783. * An observer which watches for dispose events
  83784. */
  83785. private _onDisposeObserver;
  83786. private _onUnBindObservable;
  83787. /**
  83788. * Called during a dispose event
  83789. */
  83790. onDispose: () => void;
  83791. private _onBindObservable;
  83792. /**
  83793. * An event triggered when the material is bound
  83794. */
  83795. readonly onBindObservable: Observable<AbstractMesh>;
  83796. /**
  83797. * An observer which watches for bind events
  83798. */
  83799. private _onBindObserver;
  83800. /**
  83801. * Called during a bind event
  83802. */
  83803. onBind: (Mesh: AbstractMesh) => void;
  83804. /**
  83805. * An event triggered when the material is unbound
  83806. */
  83807. readonly onUnBindObservable: Observable<Material>;
  83808. /**
  83809. * Stores the value of the alpha mode
  83810. */
  83811. private _alphaMode;
  83812. /**
  83813. * Sets the value of the alpha mode.
  83814. *
  83815. * | Value | Type | Description |
  83816. * | --- | --- | --- |
  83817. * | 0 | ALPHA_DISABLE | |
  83818. * | 1 | ALPHA_ADD | |
  83819. * | 2 | ALPHA_COMBINE | |
  83820. * | 3 | ALPHA_SUBTRACT | |
  83821. * | 4 | ALPHA_MULTIPLY | |
  83822. * | 5 | ALPHA_MAXIMIZED | |
  83823. * | 6 | ALPHA_ONEONE | |
  83824. * | 7 | ALPHA_PREMULTIPLIED | |
  83825. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83826. * | 9 | ALPHA_INTERPOLATE | |
  83827. * | 10 | ALPHA_SCREENMODE | |
  83828. *
  83829. */
  83830. /**
  83831. * Gets the value of the alpha mode
  83832. */
  83833. alphaMode: number;
  83834. /**
  83835. * Stores the state of the need depth pre-pass value
  83836. */
  83837. private _needDepthPrePass;
  83838. /**
  83839. * Sets the need depth pre-pass value
  83840. */
  83841. /**
  83842. * Gets the depth pre-pass value
  83843. */
  83844. needDepthPrePass: boolean;
  83845. /**
  83846. * Specifies if depth writing should be disabled
  83847. */
  83848. disableDepthWrite: boolean;
  83849. /**
  83850. * Specifies if depth writing should be forced
  83851. */
  83852. forceDepthWrite: boolean;
  83853. /**
  83854. * Specifies if there should be a separate pass for culling
  83855. */
  83856. separateCullingPass: boolean;
  83857. /**
  83858. * Stores the state specifing if fog should be enabled
  83859. */
  83860. private _fogEnabled;
  83861. /**
  83862. * Sets the state for enabling fog
  83863. */
  83864. /**
  83865. * Gets the value of the fog enabled state
  83866. */
  83867. fogEnabled: boolean;
  83868. /**
  83869. * Stores the size of points
  83870. */
  83871. pointSize: number;
  83872. /**
  83873. * Stores the z offset value
  83874. */
  83875. zOffset: number;
  83876. /**
  83877. * Gets a value specifying if wireframe mode is enabled
  83878. */
  83879. /**
  83880. * Sets the state of wireframe mode
  83881. */
  83882. wireframe: boolean;
  83883. /**
  83884. * Gets the value specifying if point clouds are enabled
  83885. */
  83886. /**
  83887. * Sets the state of point cloud mode
  83888. */
  83889. pointsCloud: boolean;
  83890. /**
  83891. * Gets the material fill mode
  83892. */
  83893. /**
  83894. * Sets the material fill mode
  83895. */
  83896. fillMode: number;
  83897. /**
  83898. * @hidden
  83899. * Stores the effects for the material
  83900. */
  83901. _effect: Nullable<Effect>;
  83902. /**
  83903. * @hidden
  83904. * Specifies if the material was previously ready
  83905. */
  83906. _wasPreviouslyReady: boolean;
  83907. /**
  83908. * Specifies if uniform buffers should be used
  83909. */
  83910. private _useUBO;
  83911. /**
  83912. * Stores a reference to the scene
  83913. */
  83914. private _scene;
  83915. /**
  83916. * Stores the fill mode state
  83917. */
  83918. private _fillMode;
  83919. /**
  83920. * Specifies if the depth write state should be cached
  83921. */
  83922. private _cachedDepthWriteState;
  83923. /**
  83924. * Stores the uniform buffer
  83925. */
  83926. protected _uniformBuffer: UniformBuffer;
  83927. /** @hidden */
  83928. _indexInSceneMaterialArray: number;
  83929. /** @hidden */
  83930. meshMap: Nullable<{
  83931. [id: string]: AbstractMesh | undefined;
  83932. }>;
  83933. /**
  83934. * Creates a material instance
  83935. * @param name defines the name of the material
  83936. * @param scene defines the scene to reference
  83937. * @param doNotAdd specifies if the material should be added to the scene
  83938. */
  83939. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  83940. /**
  83941. * Returns a string representation of the current material
  83942. * @param fullDetails defines a boolean indicating which levels of logging is desired
  83943. * @returns a string with material information
  83944. */
  83945. toString(fullDetails?: boolean): string;
  83946. /**
  83947. * Gets the class name of the material
  83948. * @returns a string with the class name of the material
  83949. */
  83950. getClassName(): string;
  83951. /**
  83952. * Specifies if updates for the material been locked
  83953. */
  83954. readonly isFrozen: boolean;
  83955. /**
  83956. * Locks updates for the material
  83957. */
  83958. freeze(): void;
  83959. /**
  83960. * Unlocks updates for the material
  83961. */
  83962. unfreeze(): void;
  83963. /**
  83964. * Specifies if the material is ready to be used
  83965. * @param mesh defines the mesh to check
  83966. * @param useInstances specifies if instances should be used
  83967. * @returns a boolean indicating if the material is ready to be used
  83968. */
  83969. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83970. /**
  83971. * Specifies that the submesh is ready to be used
  83972. * @param mesh defines the mesh to check
  83973. * @param subMesh defines which submesh to check
  83974. * @param useInstances specifies that instances should be used
  83975. * @returns a boolean indicating that the submesh is ready or not
  83976. */
  83977. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83978. /**
  83979. * Returns the material effect
  83980. * @returns the effect associated with the material
  83981. */
  83982. getEffect(): Nullable<Effect>;
  83983. /**
  83984. * Returns the current scene
  83985. * @returns a Scene
  83986. */
  83987. getScene(): Scene;
  83988. /**
  83989. * Specifies if the material will require alpha blending
  83990. * @returns a boolean specifying if alpha blending is needed
  83991. */
  83992. needAlphaBlending(): boolean;
  83993. /**
  83994. * Specifies if the mesh will require alpha blending
  83995. * @param mesh defines the mesh to check
  83996. * @returns a boolean specifying if alpha blending is needed for the mesh
  83997. */
  83998. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  83999. /**
  84000. * Specifies if this material should be rendered in alpha test mode
  84001. * @returns a boolean specifying if an alpha test is needed.
  84002. */
  84003. needAlphaTesting(): boolean;
  84004. /**
  84005. * Gets the texture used for the alpha test
  84006. * @returns the texture to use for alpha testing
  84007. */
  84008. getAlphaTestTexture(): Nullable<BaseTexture>;
  84009. /**
  84010. * Marks the material to indicate that it needs to be re-calculated
  84011. */
  84012. markDirty(): void;
  84013. /** @hidden */
  84014. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84015. /**
  84016. * Binds the material to the mesh
  84017. * @param world defines the world transformation matrix
  84018. * @param mesh defines the mesh to bind the material to
  84019. */
  84020. bind(world: Matrix, mesh?: Mesh): void;
  84021. /**
  84022. * Binds the submesh to the material
  84023. * @param world defines the world transformation matrix
  84024. * @param mesh defines the mesh containing the submesh
  84025. * @param subMesh defines the submesh to bind the material to
  84026. */
  84027. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84028. /**
  84029. * Binds the world matrix to the material
  84030. * @param world defines the world transformation matrix
  84031. */
  84032. bindOnlyWorldMatrix(world: Matrix): void;
  84033. /**
  84034. * Binds the scene's uniform buffer to the effect.
  84035. * @param effect defines the effect to bind to the scene uniform buffer
  84036. * @param sceneUbo defines the uniform buffer storing scene data
  84037. */
  84038. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84039. /**
  84040. * Binds the view matrix to the effect
  84041. * @param effect defines the effect to bind the view matrix to
  84042. */
  84043. bindView(effect: Effect): void;
  84044. /**
  84045. * Binds the view projection matrix to the effect
  84046. * @param effect defines the effect to bind the view projection matrix to
  84047. */
  84048. bindViewProjection(effect: Effect): void;
  84049. /**
  84050. * Specifies if material alpha testing should be turned on for the mesh
  84051. * @param mesh defines the mesh to check
  84052. */
  84053. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84054. /**
  84055. * Processes to execute after binding the material to a mesh
  84056. * @param mesh defines the rendered mesh
  84057. */
  84058. protected _afterBind(mesh?: Mesh): void;
  84059. /**
  84060. * Unbinds the material from the mesh
  84061. */
  84062. unbind(): void;
  84063. /**
  84064. * Gets the active textures from the material
  84065. * @returns an array of textures
  84066. */
  84067. getActiveTextures(): BaseTexture[];
  84068. /**
  84069. * Specifies if the material uses a texture
  84070. * @param texture defines the texture to check against the material
  84071. * @returns a boolean specifying if the material uses the texture
  84072. */
  84073. hasTexture(texture: BaseTexture): boolean;
  84074. /**
  84075. * Makes a duplicate of the material, and gives it a new name
  84076. * @param name defines the new name for the duplicated material
  84077. * @returns the cloned material
  84078. */
  84079. clone(name: string): Nullable<Material>;
  84080. /**
  84081. * Gets the meshes bound to the material
  84082. * @returns an array of meshes bound to the material
  84083. */
  84084. getBindedMeshes(): AbstractMesh[];
  84085. /**
  84086. * Force shader compilation
  84087. * @param mesh defines the mesh associated with this material
  84088. * @param onCompiled defines a function to execute once the material is compiled
  84089. * @param options defines the options to configure the compilation
  84090. */
  84091. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84092. clipPlane: boolean;
  84093. }>): void;
  84094. /**
  84095. * Force shader compilation
  84096. * @param mesh defines the mesh that will use this material
  84097. * @param options defines additional options for compiling the shaders
  84098. * @returns a promise that resolves when the compilation completes
  84099. */
  84100. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84101. clipPlane: boolean;
  84102. }>): Promise<void>;
  84103. private static readonly _AllDirtyCallBack;
  84104. private static readonly _ImageProcessingDirtyCallBack;
  84105. private static readonly _TextureDirtyCallBack;
  84106. private static readonly _FresnelDirtyCallBack;
  84107. private static readonly _MiscDirtyCallBack;
  84108. private static readonly _LightsDirtyCallBack;
  84109. private static readonly _AttributeDirtyCallBack;
  84110. private static _FresnelAndMiscDirtyCallBack;
  84111. private static _TextureAndMiscDirtyCallBack;
  84112. private static readonly _DirtyCallbackArray;
  84113. private static readonly _RunDirtyCallBacks;
  84114. /**
  84115. * Marks a define in the material to indicate that it needs to be re-computed
  84116. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84117. */
  84118. markAsDirty(flag: number): void;
  84119. /**
  84120. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84121. * @param func defines a function which checks material defines against the submeshes
  84122. */
  84123. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84124. /**
  84125. * Indicates that we need to re-calculated for all submeshes
  84126. */
  84127. protected _markAllSubMeshesAsAllDirty(): void;
  84128. /**
  84129. * Indicates that image processing needs to be re-calculated for all submeshes
  84130. */
  84131. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84132. /**
  84133. * Indicates that textures need to be re-calculated for all submeshes
  84134. */
  84135. protected _markAllSubMeshesAsTexturesDirty(): void;
  84136. /**
  84137. * Indicates that fresnel needs to be re-calculated for all submeshes
  84138. */
  84139. protected _markAllSubMeshesAsFresnelDirty(): void;
  84140. /**
  84141. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84142. */
  84143. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84144. /**
  84145. * Indicates that lights need to be re-calculated for all submeshes
  84146. */
  84147. protected _markAllSubMeshesAsLightsDirty(): void;
  84148. /**
  84149. * Indicates that attributes need to be re-calculated for all submeshes
  84150. */
  84151. protected _markAllSubMeshesAsAttributesDirty(): void;
  84152. /**
  84153. * Indicates that misc needs to be re-calculated for all submeshes
  84154. */
  84155. protected _markAllSubMeshesAsMiscDirty(): void;
  84156. /**
  84157. * Indicates that textures and misc need to be re-calculated for all submeshes
  84158. */
  84159. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84160. /**
  84161. * Disposes the material
  84162. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84163. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84164. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84165. */
  84166. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84167. /** @hidden */
  84168. private releaseVertexArrayObject;
  84169. /**
  84170. * Serializes this material
  84171. * @returns the serialized material object
  84172. */
  84173. serialize(): any;
  84174. /**
  84175. * Creates a material from parsed material data
  84176. * @param parsedMaterial defines parsed material data
  84177. * @param scene defines the hosting scene
  84178. * @param rootUrl defines the root URL to use to load textures
  84179. * @returns a new material
  84180. */
  84181. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84182. }
  84183. }
  84184. declare module BABYLON {
  84185. /**
  84186. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84187. * separate meshes. This can be use to improve performances.
  84188. * @see http://doc.babylonjs.com/how_to/multi_materials
  84189. */
  84190. export class MultiMaterial extends Material {
  84191. private _subMaterials;
  84192. /**
  84193. * Gets or Sets the list of Materials used within the multi material.
  84194. * They need to be ordered according to the submeshes order in the associated mesh
  84195. */
  84196. subMaterials: Nullable<Material>[];
  84197. /**
  84198. * Function used to align with Node.getChildren()
  84199. * @returns the list of Materials used within the multi material
  84200. */
  84201. getChildren(): Nullable<Material>[];
  84202. /**
  84203. * Instantiates a new Multi Material
  84204. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84205. * separate meshes. This can be use to improve performances.
  84206. * @see http://doc.babylonjs.com/how_to/multi_materials
  84207. * @param name Define the name in the scene
  84208. * @param scene Define the scene the material belongs to
  84209. */
  84210. constructor(name: string, scene: Scene);
  84211. private _hookArray;
  84212. /**
  84213. * Get one of the submaterial by its index in the submaterials array
  84214. * @param index The index to look the sub material at
  84215. * @returns The Material if the index has been defined
  84216. */
  84217. getSubMaterial(index: number): Nullable<Material>;
  84218. /**
  84219. * Get the list of active textures for the whole sub materials list.
  84220. * @returns All the textures that will be used during the rendering
  84221. */
  84222. getActiveTextures(): BaseTexture[];
  84223. /**
  84224. * Gets the current class name of the material e.g. "MultiMaterial"
  84225. * Mainly use in serialization.
  84226. * @returns the class name
  84227. */
  84228. getClassName(): string;
  84229. /**
  84230. * Checks if the material is ready to render the requested sub mesh
  84231. * @param mesh Define the mesh the submesh belongs to
  84232. * @param subMesh Define the sub mesh to look readyness for
  84233. * @param useInstances Define whether or not the material is used with instances
  84234. * @returns true if ready, otherwise false
  84235. */
  84236. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84237. /**
  84238. * Clones the current material and its related sub materials
  84239. * @param name Define the name of the newly cloned material
  84240. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84241. * @returns the cloned material
  84242. */
  84243. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84244. /**
  84245. * Serializes the materials into a JSON representation.
  84246. * @returns the JSON representation
  84247. */
  84248. serialize(): any;
  84249. /**
  84250. * Dispose the material and release its associated resources
  84251. * @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)
  84252. * @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)
  84253. * @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)
  84254. */
  84255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84256. /**
  84257. * Creates a MultiMaterial from parsed MultiMaterial data.
  84258. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84259. * @param scene defines the hosting scene
  84260. * @returns a new MultiMaterial
  84261. */
  84262. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84263. }
  84264. }
  84265. declare module BABYLON {
  84266. /**
  84267. * Base class for submeshes
  84268. */
  84269. export class BaseSubMesh {
  84270. /** @hidden */
  84271. _materialDefines: Nullable<MaterialDefines>;
  84272. /** @hidden */
  84273. _materialEffect: Nullable<Effect>;
  84274. /**
  84275. * Gets associated effect
  84276. */
  84277. readonly effect: Nullable<Effect>;
  84278. /**
  84279. * Sets associated effect (effect used to render this submesh)
  84280. * @param effect defines the effect to associate with
  84281. * @param defines defines the set of defines used to compile this effect
  84282. */
  84283. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84284. }
  84285. /**
  84286. * Defines a subdivision inside a mesh
  84287. */
  84288. export class SubMesh extends BaseSubMesh implements ICullable {
  84289. /** the material index to use */
  84290. materialIndex: number;
  84291. /** vertex index start */
  84292. verticesStart: number;
  84293. /** vertices count */
  84294. verticesCount: number;
  84295. /** index start */
  84296. indexStart: number;
  84297. /** indices count */
  84298. indexCount: number;
  84299. /** @hidden */
  84300. _linesIndexCount: number;
  84301. private _mesh;
  84302. private _renderingMesh;
  84303. private _boundingInfo;
  84304. private _linesIndexBuffer;
  84305. /** @hidden */
  84306. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84307. /** @hidden */
  84308. _trianglePlanes: Plane[];
  84309. /** @hidden */
  84310. _lastColliderTransformMatrix: Nullable<Matrix>;
  84311. /** @hidden */
  84312. _renderId: number;
  84313. /** @hidden */
  84314. _alphaIndex: number;
  84315. /** @hidden */
  84316. _distanceToCamera: number;
  84317. /** @hidden */
  84318. _id: number;
  84319. private _currentMaterial;
  84320. /**
  84321. * Add a new submesh to a mesh
  84322. * @param materialIndex defines the material index to use
  84323. * @param verticesStart defines vertex index start
  84324. * @param verticesCount defines vertices count
  84325. * @param indexStart defines index start
  84326. * @param indexCount defines indices count
  84327. * @param mesh defines the parent mesh
  84328. * @param renderingMesh defines an optional rendering mesh
  84329. * @param createBoundingBox defines if bounding box should be created for this submesh
  84330. * @returns the new submesh
  84331. */
  84332. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84333. /**
  84334. * Creates a new submesh
  84335. * @param materialIndex defines the material index to use
  84336. * @param verticesStart defines vertex index start
  84337. * @param verticesCount defines vertices count
  84338. * @param indexStart defines index start
  84339. * @param indexCount defines indices count
  84340. * @param mesh defines the parent mesh
  84341. * @param renderingMesh defines an optional rendering mesh
  84342. * @param createBoundingBox defines if bounding box should be created for this submesh
  84343. */
  84344. constructor(
  84345. /** the material index to use */
  84346. materialIndex: number,
  84347. /** vertex index start */
  84348. verticesStart: number,
  84349. /** vertices count */
  84350. verticesCount: number,
  84351. /** index start */
  84352. indexStart: number,
  84353. /** indices count */
  84354. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84355. /**
  84356. * Returns true if this submesh covers the entire parent mesh
  84357. * @ignorenaming
  84358. */
  84359. readonly IsGlobal: boolean;
  84360. /**
  84361. * Returns the submesh BoudingInfo object
  84362. * @returns current bounding info (or mesh's one if the submesh is global)
  84363. */
  84364. getBoundingInfo(): BoundingInfo;
  84365. /**
  84366. * Sets the submesh BoundingInfo
  84367. * @param boundingInfo defines the new bounding info to use
  84368. * @returns the SubMesh
  84369. */
  84370. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84371. /**
  84372. * Returns the mesh of the current submesh
  84373. * @return the parent mesh
  84374. */
  84375. getMesh(): AbstractMesh;
  84376. /**
  84377. * Returns the rendering mesh of the submesh
  84378. * @returns the rendering mesh (could be different from parent mesh)
  84379. */
  84380. getRenderingMesh(): Mesh;
  84381. /**
  84382. * Returns the submesh material
  84383. * @returns null or the current material
  84384. */
  84385. getMaterial(): Nullable<Material>;
  84386. /**
  84387. * Sets a new updated BoundingInfo object to the submesh
  84388. * @param data defines an optional position array to use to determine the bounding info
  84389. * @returns the SubMesh
  84390. */
  84391. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84392. /** @hidden */
  84393. _checkCollision(collider: Collider): boolean;
  84394. /**
  84395. * Updates the submesh BoundingInfo
  84396. * @param world defines the world matrix to use to update the bounding info
  84397. * @returns the submesh
  84398. */
  84399. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84400. /**
  84401. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84402. * @param frustumPlanes defines the frustum planes
  84403. * @returns true if the submesh is intersecting with the frustum
  84404. */
  84405. isInFrustum(frustumPlanes: Plane[]): boolean;
  84406. /**
  84407. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84408. * @param frustumPlanes defines the frustum planes
  84409. * @returns true if the submesh is inside the frustum
  84410. */
  84411. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84412. /**
  84413. * Renders the submesh
  84414. * @param enableAlphaMode defines if alpha needs to be used
  84415. * @returns the submesh
  84416. */
  84417. render(enableAlphaMode: boolean): SubMesh;
  84418. /**
  84419. * @hidden
  84420. */
  84421. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84422. /**
  84423. * Checks if the submesh intersects with a ray
  84424. * @param ray defines the ray to test
  84425. * @returns true is the passed ray intersects the submesh bounding box
  84426. */
  84427. canIntersects(ray: Ray): boolean;
  84428. /**
  84429. * Intersects current submesh with a ray
  84430. * @param ray defines the ray to test
  84431. * @param positions defines mesh's positions array
  84432. * @param indices defines mesh's indices array
  84433. * @param fastCheck defines if only bounding info should be used
  84434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84435. * @returns intersection info or null if no intersection
  84436. */
  84437. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84438. /** @hidden */
  84439. private _intersectLines;
  84440. /** @hidden */
  84441. private _intersectUnIndexedLines;
  84442. /** @hidden */
  84443. private _intersectTriangles;
  84444. /** @hidden */
  84445. private _intersectUnIndexedTriangles;
  84446. /** @hidden */
  84447. _rebuild(): void;
  84448. /**
  84449. * Creates a new submesh from the passed mesh
  84450. * @param newMesh defines the new hosting mesh
  84451. * @param newRenderingMesh defines an optional rendering mesh
  84452. * @returns the new submesh
  84453. */
  84454. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84455. /**
  84456. * Release associated resources
  84457. */
  84458. dispose(): void;
  84459. /**
  84460. * Gets the class name
  84461. * @returns the string "SubMesh".
  84462. */
  84463. getClassName(): string;
  84464. /**
  84465. * Creates a new submesh from indices data
  84466. * @param materialIndex the index of the main mesh material
  84467. * @param startIndex the index where to start the copy in the mesh indices array
  84468. * @param indexCount the number of indices to copy then from the startIndex
  84469. * @param mesh the main mesh to create the submesh from
  84470. * @param renderingMesh the optional rendering mesh
  84471. * @returns a new submesh
  84472. */
  84473. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84474. }
  84475. }
  84476. declare module BABYLON {
  84477. /**
  84478. * Class used to represent data loading progression
  84479. */
  84480. export class SceneLoaderFlags {
  84481. private static _ForceFullSceneLoadingForIncremental;
  84482. private static _ShowLoadingScreen;
  84483. private static _CleanBoneMatrixWeights;
  84484. private static _loggingLevel;
  84485. /**
  84486. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84487. */
  84488. static ForceFullSceneLoadingForIncremental: boolean;
  84489. /**
  84490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84491. */
  84492. static ShowLoadingScreen: boolean;
  84493. /**
  84494. * Defines the current logging level (while loading the scene)
  84495. * @ignorenaming
  84496. */
  84497. static loggingLevel: number;
  84498. /**
  84499. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84500. */
  84501. static CleanBoneMatrixWeights: boolean;
  84502. }
  84503. }
  84504. declare module BABYLON {
  84505. /**
  84506. * Class used to store geometry data (vertex buffers + index buffer)
  84507. */
  84508. export class Geometry implements IGetSetVerticesData {
  84509. /**
  84510. * Gets or sets the ID of the geometry
  84511. */
  84512. id: string;
  84513. /**
  84514. * Gets or sets the unique ID of the geometry
  84515. */
  84516. uniqueId: number;
  84517. /**
  84518. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84519. */
  84520. delayLoadState: number;
  84521. /**
  84522. * Gets the file containing the data to load when running in delay load state
  84523. */
  84524. delayLoadingFile: Nullable<string>;
  84525. /**
  84526. * Callback called when the geometry is updated
  84527. */
  84528. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84529. private _scene;
  84530. private _engine;
  84531. private _meshes;
  84532. private _totalVertices;
  84533. /** @hidden */
  84534. _indices: IndicesArray;
  84535. /** @hidden */
  84536. _vertexBuffers: {
  84537. [key: string]: VertexBuffer;
  84538. };
  84539. private _isDisposed;
  84540. private _extend;
  84541. private _boundingBias;
  84542. /** @hidden */
  84543. _delayInfo: Array<string>;
  84544. private _indexBuffer;
  84545. private _indexBufferIsUpdatable;
  84546. /** @hidden */
  84547. _boundingInfo: Nullable<BoundingInfo>;
  84548. /** @hidden */
  84549. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84550. /** @hidden */
  84551. _softwareSkinningFrameId: number;
  84552. private _vertexArrayObjects;
  84553. private _updatable;
  84554. /** @hidden */
  84555. _positions: Nullable<Vector3[]>;
  84556. /**
  84557. * 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
  84558. */
  84559. /**
  84560. * 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
  84561. */
  84562. boundingBias: Vector2;
  84563. /**
  84564. * Static function used to attach a new empty geometry to a mesh
  84565. * @param mesh defines the mesh to attach the geometry to
  84566. * @returns the new Geometry
  84567. */
  84568. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84569. /**
  84570. * Creates a new geometry
  84571. * @param id defines the unique ID
  84572. * @param scene defines the hosting scene
  84573. * @param vertexData defines the VertexData used to get geometry data
  84574. * @param updatable defines if geometry must be updatable (false by default)
  84575. * @param mesh defines the mesh that will be associated with the geometry
  84576. */
  84577. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84578. /**
  84579. * Gets the current extend of the geometry
  84580. */
  84581. readonly extend: {
  84582. minimum: Vector3;
  84583. maximum: Vector3;
  84584. };
  84585. /**
  84586. * Gets the hosting scene
  84587. * @returns the hosting Scene
  84588. */
  84589. getScene(): Scene;
  84590. /**
  84591. * Gets the hosting engine
  84592. * @returns the hosting Engine
  84593. */
  84594. getEngine(): Engine;
  84595. /**
  84596. * Defines if the geometry is ready to use
  84597. * @returns true if the geometry is ready to be used
  84598. */
  84599. isReady(): boolean;
  84600. /**
  84601. * Gets a value indicating that the geometry should not be serialized
  84602. */
  84603. readonly doNotSerialize: boolean;
  84604. /** @hidden */
  84605. _rebuild(): void;
  84606. /**
  84607. * Affects all geometry data in one call
  84608. * @param vertexData defines the geometry data
  84609. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84610. */
  84611. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84612. /**
  84613. * Set specific vertex data
  84614. * @param kind defines the data kind (Position, normal, etc...)
  84615. * @param data defines the vertex data to use
  84616. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84617. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84618. */
  84619. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84620. /**
  84621. * Removes a specific vertex data
  84622. * @param kind defines the data kind (Position, normal, etc...)
  84623. */
  84624. removeVerticesData(kind: string): void;
  84625. /**
  84626. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84627. * @param buffer defines the vertex buffer to use
  84628. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84629. */
  84630. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84631. /**
  84632. * Update a specific vertex buffer
  84633. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84634. * It will do nothing if the buffer is not updatable
  84635. * @param kind defines the data kind (Position, normal, etc...)
  84636. * @param data defines the data to use
  84637. * @param offset defines the offset in the target buffer where to store the data
  84638. * @param useBytes set to true if the offset is in bytes
  84639. */
  84640. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84641. /**
  84642. * Update a specific vertex buffer
  84643. * This function will create a new buffer if the current one is not updatable
  84644. * @param kind defines the data kind (Position, normal, etc...)
  84645. * @param data defines the data to use
  84646. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84647. */
  84648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84649. private _updateBoundingInfo;
  84650. /** @hidden */
  84651. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84652. /**
  84653. * Gets total number of vertices
  84654. * @returns the total number of vertices
  84655. */
  84656. getTotalVertices(): number;
  84657. /**
  84658. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84659. * @param kind defines the data kind (Position, normal, etc...)
  84660. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84662. * @returns a float array containing vertex data
  84663. */
  84664. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84665. /**
  84666. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84667. * @param kind defines the data kind (Position, normal, etc...)
  84668. * @returns true if the vertex buffer with the specified kind is updatable
  84669. */
  84670. isVertexBufferUpdatable(kind: string): boolean;
  84671. /**
  84672. * Gets a specific vertex buffer
  84673. * @param kind defines the data kind (Position, normal, etc...)
  84674. * @returns a VertexBuffer
  84675. */
  84676. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84677. /**
  84678. * Returns all vertex buffers
  84679. * @return an object holding all vertex buffers indexed by kind
  84680. */
  84681. getVertexBuffers(): Nullable<{
  84682. [key: string]: VertexBuffer;
  84683. }>;
  84684. /**
  84685. * Gets a boolean indicating if specific vertex buffer is present
  84686. * @param kind defines the data kind (Position, normal, etc...)
  84687. * @returns true if data is present
  84688. */
  84689. isVerticesDataPresent(kind: string): boolean;
  84690. /**
  84691. * Gets a list of all attached data kinds (Position, normal, etc...)
  84692. * @returns a list of string containing all kinds
  84693. */
  84694. getVerticesDataKinds(): string[];
  84695. /**
  84696. * Update index buffer
  84697. * @param indices defines the indices to store in the index buffer
  84698. * @param offset defines the offset in the target buffer where to store the data
  84699. * @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)
  84700. */
  84701. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84702. /**
  84703. * Creates a new index buffer
  84704. * @param indices defines the indices to store in the index buffer
  84705. * @param totalVertices defines the total number of vertices (could be null)
  84706. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84707. */
  84708. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84709. /**
  84710. * Return the total number of indices
  84711. * @returns the total number of indices
  84712. */
  84713. getTotalIndices(): number;
  84714. /**
  84715. * Gets the index buffer array
  84716. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84717. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84718. * @returns the index buffer array
  84719. */
  84720. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84721. /**
  84722. * Gets the index buffer
  84723. * @return the index buffer
  84724. */
  84725. getIndexBuffer(): Nullable<DataBuffer>;
  84726. /** @hidden */
  84727. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84728. /**
  84729. * Release the associated resources for a specific mesh
  84730. * @param mesh defines the source mesh
  84731. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84732. */
  84733. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84734. /**
  84735. * Apply current geometry to a given mesh
  84736. * @param mesh defines the mesh to apply geometry to
  84737. */
  84738. applyToMesh(mesh: Mesh): void;
  84739. private _updateExtend;
  84740. private _applyToMesh;
  84741. private notifyUpdate;
  84742. /**
  84743. * Load the geometry if it was flagged as delay loaded
  84744. * @param scene defines the hosting scene
  84745. * @param onLoaded defines a callback called when the geometry is loaded
  84746. */
  84747. load(scene: Scene, onLoaded?: () => void): void;
  84748. private _queueLoad;
  84749. /**
  84750. * Invert the geometry to move from a right handed system to a left handed one.
  84751. */
  84752. toLeftHanded(): void;
  84753. /** @hidden */
  84754. _resetPointsArrayCache(): void;
  84755. /** @hidden */
  84756. _generatePointsArray(): boolean;
  84757. /**
  84758. * Gets a value indicating if the geometry is disposed
  84759. * @returns true if the geometry was disposed
  84760. */
  84761. isDisposed(): boolean;
  84762. private _disposeVertexArrayObjects;
  84763. /**
  84764. * Free all associated resources
  84765. */
  84766. dispose(): void;
  84767. /**
  84768. * Clone the current geometry into a new geometry
  84769. * @param id defines the unique ID of the new geometry
  84770. * @returns a new geometry object
  84771. */
  84772. copy(id: string): Geometry;
  84773. /**
  84774. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84775. * @return a JSON representation of the current geometry data (without the vertices data)
  84776. */
  84777. serialize(): any;
  84778. private toNumberArray;
  84779. /**
  84780. * Serialize all vertices data into a JSON oject
  84781. * @returns a JSON representation of the current geometry data
  84782. */
  84783. serializeVerticeData(): any;
  84784. /**
  84785. * Extracts a clone of a mesh geometry
  84786. * @param mesh defines the source mesh
  84787. * @param id defines the unique ID of the new geometry object
  84788. * @returns the new geometry object
  84789. */
  84790. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84791. /**
  84792. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84793. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84794. * Be aware Math.random() could cause collisions, but:
  84795. * "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"
  84796. * @returns a string containing a new GUID
  84797. */
  84798. static RandomId(): string;
  84799. /** @hidden */
  84800. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84801. private static _CleanMatricesWeights;
  84802. /**
  84803. * Create a new geometry from persisted data (Using .babylon file format)
  84804. * @param parsedVertexData defines the persisted data
  84805. * @param scene defines the hosting scene
  84806. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84807. * @returns the new geometry object
  84808. */
  84809. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84810. }
  84811. }
  84812. declare module BABYLON {
  84813. /**
  84814. * Define an interface for all classes that will get and set the data on vertices
  84815. */
  84816. export interface IGetSetVerticesData {
  84817. /**
  84818. * Gets a boolean indicating if specific vertex data is present
  84819. * @param kind defines the vertex data kind to use
  84820. * @returns true is data kind is present
  84821. */
  84822. isVerticesDataPresent(kind: string): boolean;
  84823. /**
  84824. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84825. * @param kind defines the data kind (Position, normal, etc...)
  84826. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84827. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84828. * @returns a float array containing vertex data
  84829. */
  84830. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84831. /**
  84832. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84833. * @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.
  84834. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84835. * @returns the indices array or an empty array if the mesh has no geometry
  84836. */
  84837. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84838. /**
  84839. * Set specific vertex data
  84840. * @param kind defines the data kind (Position, normal, etc...)
  84841. * @param data defines the vertex data to use
  84842. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84843. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84844. */
  84845. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84846. /**
  84847. * Update a specific associated vertex buffer
  84848. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84849. * - VertexBuffer.PositionKind
  84850. * - VertexBuffer.UVKind
  84851. * - VertexBuffer.UV2Kind
  84852. * - VertexBuffer.UV3Kind
  84853. * - VertexBuffer.UV4Kind
  84854. * - VertexBuffer.UV5Kind
  84855. * - VertexBuffer.UV6Kind
  84856. * - VertexBuffer.ColorKind
  84857. * - VertexBuffer.MatricesIndicesKind
  84858. * - VertexBuffer.MatricesIndicesExtraKind
  84859. * - VertexBuffer.MatricesWeightsKind
  84860. * - VertexBuffer.MatricesWeightsExtraKind
  84861. * @param data defines the data source
  84862. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84863. * @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)
  84864. */
  84865. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  84866. /**
  84867. * Creates a new index buffer
  84868. * @param indices defines the indices to store in the index buffer
  84869. * @param totalVertices defines the total number of vertices (could be null)
  84870. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84871. */
  84872. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  84873. }
  84874. /**
  84875. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  84876. */
  84877. export class VertexData {
  84878. /**
  84879. * Mesh side orientation : usually the external or front surface
  84880. */
  84881. static readonly FRONTSIDE: number;
  84882. /**
  84883. * Mesh side orientation : usually the internal or back surface
  84884. */
  84885. static readonly BACKSIDE: number;
  84886. /**
  84887. * Mesh side orientation : both internal and external or front and back surfaces
  84888. */
  84889. static readonly DOUBLESIDE: number;
  84890. /**
  84891. * Mesh side orientation : by default, `FRONTSIDE`
  84892. */
  84893. static readonly DEFAULTSIDE: number;
  84894. /**
  84895. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  84896. */
  84897. positions: Nullable<FloatArray>;
  84898. /**
  84899. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  84900. */
  84901. normals: Nullable<FloatArray>;
  84902. /**
  84903. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  84904. */
  84905. tangents: Nullable<FloatArray>;
  84906. /**
  84907. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84908. */
  84909. uvs: Nullable<FloatArray>;
  84910. /**
  84911. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84912. */
  84913. uvs2: Nullable<FloatArray>;
  84914. /**
  84915. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84916. */
  84917. uvs3: Nullable<FloatArray>;
  84918. /**
  84919. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84920. */
  84921. uvs4: Nullable<FloatArray>;
  84922. /**
  84923. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84924. */
  84925. uvs5: Nullable<FloatArray>;
  84926. /**
  84927. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84928. */
  84929. uvs6: Nullable<FloatArray>;
  84930. /**
  84931. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  84932. */
  84933. colors: Nullable<FloatArray>;
  84934. /**
  84935. * 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).
  84936. */
  84937. matricesIndices: Nullable<FloatArray>;
  84938. /**
  84939. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  84940. */
  84941. matricesWeights: Nullable<FloatArray>;
  84942. /**
  84943. * An array extending the number of possible indices
  84944. */
  84945. matricesIndicesExtra: Nullable<FloatArray>;
  84946. /**
  84947. * An array extending the number of possible weights when the number of indices is extended
  84948. */
  84949. matricesWeightsExtra: Nullable<FloatArray>;
  84950. /**
  84951. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  84952. */
  84953. indices: Nullable<IndicesArray>;
  84954. /**
  84955. * Uses the passed data array to set the set the values for the specified kind of data
  84956. * @param data a linear array of floating numbers
  84957. * @param kind the type of data that is being set, eg positions, colors etc
  84958. */
  84959. set(data: FloatArray, kind: string): void;
  84960. /**
  84961. * Associates the vertexData to the passed Mesh.
  84962. * Sets it as updatable or not (default `false`)
  84963. * @param mesh the mesh the vertexData is applied to
  84964. * @param updatable when used and having the value true allows new data to update the vertexData
  84965. * @returns the VertexData
  84966. */
  84967. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  84968. /**
  84969. * Associates the vertexData to the passed Geometry.
  84970. * Sets it as updatable or not (default `false`)
  84971. * @param geometry the geometry the vertexData is applied to
  84972. * @param updatable when used and having the value true allows new data to update the vertexData
  84973. * @returns VertexData
  84974. */
  84975. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  84976. /**
  84977. * Updates the associated mesh
  84978. * @param mesh the mesh to be updated
  84979. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84980. * @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
  84981. * @returns VertexData
  84982. */
  84983. updateMesh(mesh: Mesh): VertexData;
  84984. /**
  84985. * Updates the associated geometry
  84986. * @param geometry the geometry to be updated
  84987. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84988. * @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
  84989. * @returns VertexData.
  84990. */
  84991. updateGeometry(geometry: Geometry): VertexData;
  84992. private _applyTo;
  84993. private _update;
  84994. /**
  84995. * Transforms each position and each normal of the vertexData according to the passed Matrix
  84996. * @param matrix the transforming matrix
  84997. * @returns the VertexData
  84998. */
  84999. transform(matrix: Matrix): VertexData;
  85000. /**
  85001. * Merges the passed VertexData into the current one
  85002. * @param other the VertexData to be merged into the current one
  85003. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85004. * @returns the modified VertexData
  85005. */
  85006. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85007. private _mergeElement;
  85008. private _validate;
  85009. /**
  85010. * Serializes the VertexData
  85011. * @returns a serialized object
  85012. */
  85013. serialize(): any;
  85014. /**
  85015. * Extracts the vertexData from a mesh
  85016. * @param mesh the mesh from which to extract the VertexData
  85017. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85018. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85019. * @returns the object VertexData associated to the passed mesh
  85020. */
  85021. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85022. /**
  85023. * Extracts the vertexData from the geometry
  85024. * @param geometry the geometry from which to extract the VertexData
  85025. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85026. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85027. * @returns the object VertexData associated to the passed mesh
  85028. */
  85029. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85030. private static _ExtractFrom;
  85031. /**
  85032. * Creates the VertexData for a Ribbon
  85033. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85034. * * pathArray array of paths, each of which an array of successive Vector3
  85035. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85036. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85037. * * 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
  85038. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85039. * * 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)
  85040. * * 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)
  85041. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85042. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85043. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85044. * @returns the VertexData of the ribbon
  85045. */
  85046. static CreateRibbon(options: {
  85047. pathArray: Vector3[][];
  85048. closeArray?: boolean;
  85049. closePath?: boolean;
  85050. offset?: number;
  85051. sideOrientation?: number;
  85052. frontUVs?: Vector4;
  85053. backUVs?: Vector4;
  85054. invertUV?: boolean;
  85055. uvs?: Vector2[];
  85056. colors?: Color4[];
  85057. }): VertexData;
  85058. /**
  85059. * Creates the VertexData for a box
  85060. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85061. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85062. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85063. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85064. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85065. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85066. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85068. * * 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)
  85069. * * 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)
  85070. * @returns the VertexData of the box
  85071. */
  85072. static CreateBox(options: {
  85073. size?: number;
  85074. width?: number;
  85075. height?: number;
  85076. depth?: number;
  85077. faceUV?: Vector4[];
  85078. faceColors?: Color4[];
  85079. sideOrientation?: number;
  85080. frontUVs?: Vector4;
  85081. backUVs?: Vector4;
  85082. }): VertexData;
  85083. /**
  85084. * Creates the VertexData for a tiled box
  85085. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85086. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85087. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85088. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85089. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85090. * @returns the VertexData of the box
  85091. */
  85092. static CreateTiledBox(options: {
  85093. pattern?: number;
  85094. width?: number;
  85095. height?: number;
  85096. depth?: number;
  85097. tileSize?: number;
  85098. tileWidth?: number;
  85099. tileHeight?: number;
  85100. alignHorizontal?: number;
  85101. alignVertical?: number;
  85102. faceUV?: Vector4[];
  85103. faceColors?: Color4[];
  85104. sideOrientation?: number;
  85105. }): VertexData;
  85106. /**
  85107. * Creates the VertexData for a tiled plane
  85108. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85109. * * pattern a limited pattern arrangement depending on the number
  85110. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85111. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85112. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85114. * * 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)
  85115. * * 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)
  85116. * @returns the VertexData of the tiled plane
  85117. */
  85118. static CreateTiledPlane(options: {
  85119. pattern?: number;
  85120. tileSize?: number;
  85121. tileWidth?: number;
  85122. tileHeight?: number;
  85123. size?: number;
  85124. width?: number;
  85125. height?: number;
  85126. alignHorizontal?: number;
  85127. alignVertical?: number;
  85128. sideOrientation?: number;
  85129. frontUVs?: Vector4;
  85130. backUVs?: Vector4;
  85131. }): VertexData;
  85132. /**
  85133. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85134. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85135. * * segments sets the number of horizontal strips optional, default 32
  85136. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85137. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85138. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85139. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85140. * * 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
  85141. * * 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
  85142. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85143. * * 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)
  85144. * * 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)
  85145. * @returns the VertexData of the ellipsoid
  85146. */
  85147. static CreateSphere(options: {
  85148. segments?: number;
  85149. diameter?: number;
  85150. diameterX?: number;
  85151. diameterY?: number;
  85152. diameterZ?: number;
  85153. arc?: number;
  85154. slice?: number;
  85155. sideOrientation?: number;
  85156. frontUVs?: Vector4;
  85157. backUVs?: Vector4;
  85158. }): VertexData;
  85159. /**
  85160. * Creates the VertexData for a cylinder, cone or prism
  85161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85162. * * height sets the height (y direction) of the cylinder, optional, default 2
  85163. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85164. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85165. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85166. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85167. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85168. * * 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
  85169. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85170. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85171. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85172. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85174. * * 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)
  85175. * * 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)
  85176. * @returns the VertexData of the cylinder, cone or prism
  85177. */
  85178. static CreateCylinder(options: {
  85179. height?: number;
  85180. diameterTop?: number;
  85181. diameterBottom?: number;
  85182. diameter?: number;
  85183. tessellation?: number;
  85184. subdivisions?: number;
  85185. arc?: number;
  85186. faceColors?: Color4[];
  85187. faceUV?: Vector4[];
  85188. hasRings?: boolean;
  85189. enclose?: boolean;
  85190. sideOrientation?: number;
  85191. frontUVs?: Vector4;
  85192. backUVs?: Vector4;
  85193. }): VertexData;
  85194. /**
  85195. * Creates the VertexData for a torus
  85196. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85197. * * diameter the diameter of the torus, optional default 1
  85198. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85199. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85200. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85201. * * 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)
  85202. * * 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)
  85203. * @returns the VertexData of the torus
  85204. */
  85205. static CreateTorus(options: {
  85206. diameter?: number;
  85207. thickness?: number;
  85208. tessellation?: number;
  85209. sideOrientation?: number;
  85210. frontUVs?: Vector4;
  85211. backUVs?: Vector4;
  85212. }): VertexData;
  85213. /**
  85214. * Creates the VertexData of the LineSystem
  85215. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85216. * - lines an array of lines, each line being an array of successive Vector3
  85217. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85218. * @returns the VertexData of the LineSystem
  85219. */
  85220. static CreateLineSystem(options: {
  85221. lines: Vector3[][];
  85222. colors?: Nullable<Color4[][]>;
  85223. }): VertexData;
  85224. /**
  85225. * Create the VertexData for a DashedLines
  85226. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85227. * - points an array successive Vector3
  85228. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85229. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85230. * - dashNb the intended total number of dashes, optional, default 200
  85231. * @returns the VertexData for the DashedLines
  85232. */
  85233. static CreateDashedLines(options: {
  85234. points: Vector3[];
  85235. dashSize?: number;
  85236. gapSize?: number;
  85237. dashNb?: number;
  85238. }): VertexData;
  85239. /**
  85240. * Creates the VertexData for a Ground
  85241. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85242. * - width the width (x direction) of the ground, optional, default 1
  85243. * - height the height (z direction) of the ground, optional, default 1
  85244. * - subdivisions the number of subdivisions per side, optional, default 1
  85245. * @returns the VertexData of the Ground
  85246. */
  85247. static CreateGround(options: {
  85248. width?: number;
  85249. height?: number;
  85250. subdivisions?: number;
  85251. subdivisionsX?: number;
  85252. subdivisionsY?: number;
  85253. }): VertexData;
  85254. /**
  85255. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85256. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85257. * * xmin the ground minimum X coordinate, optional, default -1
  85258. * * zmin the ground minimum Z coordinate, optional, default -1
  85259. * * xmax the ground maximum X coordinate, optional, default 1
  85260. * * zmax the ground maximum Z coordinate, optional, default 1
  85261. * * 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}
  85262. * * 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}
  85263. * @returns the VertexData of the TiledGround
  85264. */
  85265. static CreateTiledGround(options: {
  85266. xmin: number;
  85267. zmin: number;
  85268. xmax: number;
  85269. zmax: number;
  85270. subdivisions?: {
  85271. w: number;
  85272. h: number;
  85273. };
  85274. precision?: {
  85275. w: number;
  85276. h: number;
  85277. };
  85278. }): VertexData;
  85279. /**
  85280. * Creates the VertexData of the Ground designed from a heightmap
  85281. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85282. * * width the width (x direction) of the ground
  85283. * * height the height (z direction) of the ground
  85284. * * subdivisions the number of subdivisions per side
  85285. * * minHeight the minimum altitude on the ground, optional, default 0
  85286. * * maxHeight the maximum altitude on the ground, optional default 1
  85287. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85288. * * buffer the array holding the image color data
  85289. * * bufferWidth the width of image
  85290. * * bufferHeight the height of image
  85291. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85292. * @returns the VertexData of the Ground designed from a heightmap
  85293. */
  85294. static CreateGroundFromHeightMap(options: {
  85295. width: number;
  85296. height: number;
  85297. subdivisions: number;
  85298. minHeight: number;
  85299. maxHeight: number;
  85300. colorFilter: Color3;
  85301. buffer: Uint8Array;
  85302. bufferWidth: number;
  85303. bufferHeight: number;
  85304. alphaFilter: number;
  85305. }): VertexData;
  85306. /**
  85307. * Creates the VertexData for a Plane
  85308. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85309. * * size sets the width and height of the plane to the value of size, optional default 1
  85310. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85311. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85313. * * 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)
  85314. * * 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)
  85315. * @returns the VertexData of the box
  85316. */
  85317. static CreatePlane(options: {
  85318. size?: number;
  85319. width?: number;
  85320. height?: number;
  85321. sideOrientation?: number;
  85322. frontUVs?: Vector4;
  85323. backUVs?: Vector4;
  85324. }): VertexData;
  85325. /**
  85326. * Creates the VertexData of the Disc or regular Polygon
  85327. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85328. * * radius the radius of the disc, optional default 0.5
  85329. * * tessellation the number of polygon sides, optional, default 64
  85330. * * 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
  85331. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85332. * * 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)
  85333. * * 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)
  85334. * @returns the VertexData of the box
  85335. */
  85336. static CreateDisc(options: {
  85337. radius?: number;
  85338. tessellation?: number;
  85339. arc?: number;
  85340. sideOrientation?: number;
  85341. frontUVs?: Vector4;
  85342. backUVs?: Vector4;
  85343. }): VertexData;
  85344. /**
  85345. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85346. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85347. * @param polygon a mesh built from polygonTriangulation.build()
  85348. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85349. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85350. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85351. * @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)
  85352. * @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)
  85353. * @returns the VertexData of the Polygon
  85354. */
  85355. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85356. /**
  85357. * Creates the VertexData of the IcoSphere
  85358. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85359. * * radius the radius of the IcoSphere, optional default 1
  85360. * * radiusX allows stretching in the x direction, optional, default radius
  85361. * * radiusY allows stretching in the y direction, optional, default radius
  85362. * * radiusZ allows stretching in the z direction, optional, default radius
  85363. * * flat when true creates a flat shaded mesh, optional, default true
  85364. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85365. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85366. * * 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)
  85367. * * 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)
  85368. * @returns the VertexData of the IcoSphere
  85369. */
  85370. static CreateIcoSphere(options: {
  85371. radius?: number;
  85372. radiusX?: number;
  85373. radiusY?: number;
  85374. radiusZ?: number;
  85375. flat?: boolean;
  85376. subdivisions?: number;
  85377. sideOrientation?: number;
  85378. frontUVs?: Vector4;
  85379. backUVs?: Vector4;
  85380. }): VertexData;
  85381. /**
  85382. * Creates the VertexData for a Polyhedron
  85383. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85384. * * type provided types are:
  85385. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85386. * * 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)
  85387. * * size the size of the IcoSphere, optional default 1
  85388. * * sizeX allows stretching in the x direction, optional, default size
  85389. * * sizeY allows stretching in the y direction, optional, default size
  85390. * * sizeZ allows stretching in the z direction, optional, default size
  85391. * * 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
  85392. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85393. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85394. * * flat when true creates a flat shaded mesh, optional, default true
  85395. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85397. * * 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)
  85398. * * 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)
  85399. * @returns the VertexData of the Polyhedron
  85400. */
  85401. static CreatePolyhedron(options: {
  85402. type?: number;
  85403. size?: number;
  85404. sizeX?: number;
  85405. sizeY?: number;
  85406. sizeZ?: number;
  85407. custom?: any;
  85408. faceUV?: Vector4[];
  85409. faceColors?: Color4[];
  85410. flat?: boolean;
  85411. sideOrientation?: number;
  85412. frontUVs?: Vector4;
  85413. backUVs?: Vector4;
  85414. }): VertexData;
  85415. /**
  85416. * Creates the VertexData for a TorusKnot
  85417. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85418. * * radius the radius of the torus knot, optional, default 2
  85419. * * tube the thickness of the tube, optional, default 0.5
  85420. * * radialSegments the number of sides on each tube segments, optional, default 32
  85421. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85422. * * p the number of windings around the z axis, optional, default 2
  85423. * * q the number of windings around the x axis, optional, default 3
  85424. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85425. * * 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)
  85426. * * 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)
  85427. * @returns the VertexData of the Torus Knot
  85428. */
  85429. static CreateTorusKnot(options: {
  85430. radius?: number;
  85431. tube?: number;
  85432. radialSegments?: number;
  85433. tubularSegments?: number;
  85434. p?: number;
  85435. q?: number;
  85436. sideOrientation?: number;
  85437. frontUVs?: Vector4;
  85438. backUVs?: Vector4;
  85439. }): VertexData;
  85440. /**
  85441. * Compute normals for given positions and indices
  85442. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85443. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85444. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85445. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85446. * * facetNormals : optional array of facet normals (vector3)
  85447. * * facetPositions : optional array of facet positions (vector3)
  85448. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85449. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85450. * * bInfo : optional bounding info, required for facetPartitioning computation
  85451. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85452. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85453. * * useRightHandedSystem: optional boolean to for right handed system computation
  85454. * * depthSort : optional boolean to enable the facet depth sort computation
  85455. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85456. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85457. */
  85458. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85459. facetNormals?: any;
  85460. facetPositions?: any;
  85461. facetPartitioning?: any;
  85462. ratio?: number;
  85463. bInfo?: any;
  85464. bbSize?: Vector3;
  85465. subDiv?: any;
  85466. useRightHandedSystem?: boolean;
  85467. depthSort?: boolean;
  85468. distanceTo?: Vector3;
  85469. depthSortedFacets?: any;
  85470. }): void;
  85471. /** @hidden */
  85472. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85473. /**
  85474. * Applies VertexData created from the imported parameters to the geometry
  85475. * @param parsedVertexData the parsed data from an imported file
  85476. * @param geometry the geometry to apply the VertexData to
  85477. */
  85478. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85479. }
  85480. }
  85481. declare module BABYLON {
  85482. /**
  85483. * Defines a target to use with MorphTargetManager
  85484. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85485. */
  85486. export class MorphTarget implements IAnimatable {
  85487. /** defines the name of the target */
  85488. name: string;
  85489. /**
  85490. * Gets or sets the list of animations
  85491. */
  85492. animations: Animation[];
  85493. private _scene;
  85494. private _positions;
  85495. private _normals;
  85496. private _tangents;
  85497. private _uvs;
  85498. private _influence;
  85499. /**
  85500. * Observable raised when the influence changes
  85501. */
  85502. onInfluenceChanged: Observable<boolean>;
  85503. /** @hidden */
  85504. _onDataLayoutChanged: Observable<void>;
  85505. /**
  85506. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85507. */
  85508. influence: number;
  85509. /**
  85510. * Gets or sets the id of the morph Target
  85511. */
  85512. id: string;
  85513. private _animationPropertiesOverride;
  85514. /**
  85515. * Gets or sets the animation properties override
  85516. */
  85517. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85518. /**
  85519. * Creates a new MorphTarget
  85520. * @param name defines the name of the target
  85521. * @param influence defines the influence to use
  85522. * @param scene defines the scene the morphtarget belongs to
  85523. */
  85524. constructor(
  85525. /** defines the name of the target */
  85526. name: string, influence?: number, scene?: Nullable<Scene>);
  85527. /**
  85528. * Gets a boolean defining if the target contains position data
  85529. */
  85530. readonly hasPositions: boolean;
  85531. /**
  85532. * Gets a boolean defining if the target contains normal data
  85533. */
  85534. readonly hasNormals: boolean;
  85535. /**
  85536. * Gets a boolean defining if the target contains tangent data
  85537. */
  85538. readonly hasTangents: boolean;
  85539. /**
  85540. * Gets a boolean defining if the target contains texture coordinates data
  85541. */
  85542. readonly hasUVs: boolean;
  85543. /**
  85544. * Affects position data to this target
  85545. * @param data defines the position data to use
  85546. */
  85547. setPositions(data: Nullable<FloatArray>): void;
  85548. /**
  85549. * Gets the position data stored in this target
  85550. * @returns a FloatArray containing the position data (or null if not present)
  85551. */
  85552. getPositions(): Nullable<FloatArray>;
  85553. /**
  85554. * Affects normal data to this target
  85555. * @param data defines the normal data to use
  85556. */
  85557. setNormals(data: Nullable<FloatArray>): void;
  85558. /**
  85559. * Gets the normal data stored in this target
  85560. * @returns a FloatArray containing the normal data (or null if not present)
  85561. */
  85562. getNormals(): Nullable<FloatArray>;
  85563. /**
  85564. * Affects tangent data to this target
  85565. * @param data defines the tangent data to use
  85566. */
  85567. setTangents(data: Nullable<FloatArray>): void;
  85568. /**
  85569. * Gets the tangent data stored in this target
  85570. * @returns a FloatArray containing the tangent data (or null if not present)
  85571. */
  85572. getTangents(): Nullable<FloatArray>;
  85573. /**
  85574. * Affects texture coordinates data to this target
  85575. * @param data defines the texture coordinates data to use
  85576. */
  85577. setUVs(data: Nullable<FloatArray>): void;
  85578. /**
  85579. * Gets the texture coordinates data stored in this target
  85580. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85581. */
  85582. getUVs(): Nullable<FloatArray>;
  85583. /**
  85584. * Serializes the current target into a Serialization object
  85585. * @returns the serialized object
  85586. */
  85587. serialize(): any;
  85588. /**
  85589. * Returns the string "MorphTarget"
  85590. * @returns "MorphTarget"
  85591. */
  85592. getClassName(): string;
  85593. /**
  85594. * Creates a new target from serialized data
  85595. * @param serializationObject defines the serialized data to use
  85596. * @returns a new MorphTarget
  85597. */
  85598. static Parse(serializationObject: any): MorphTarget;
  85599. /**
  85600. * Creates a MorphTarget from mesh data
  85601. * @param mesh defines the source mesh
  85602. * @param name defines the name to use for the new target
  85603. * @param influence defines the influence to attach to the target
  85604. * @returns a new MorphTarget
  85605. */
  85606. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85607. }
  85608. }
  85609. declare module BABYLON {
  85610. /**
  85611. * This class is used to deform meshes using morphing between different targets
  85612. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85613. */
  85614. export class MorphTargetManager {
  85615. private _targets;
  85616. private _targetInfluenceChangedObservers;
  85617. private _targetDataLayoutChangedObservers;
  85618. private _activeTargets;
  85619. private _scene;
  85620. private _influences;
  85621. private _supportsNormals;
  85622. private _supportsTangents;
  85623. private _supportsUVs;
  85624. private _vertexCount;
  85625. private _uniqueId;
  85626. private _tempInfluences;
  85627. /**
  85628. * Gets or sets a boolean indicating if normals must be morphed
  85629. */
  85630. enableNormalMorphing: boolean;
  85631. /**
  85632. * Gets or sets a boolean indicating if tangents must be morphed
  85633. */
  85634. enableTangentMorphing: boolean;
  85635. /**
  85636. * Gets or sets a boolean indicating if UV must be morphed
  85637. */
  85638. enableUVMorphing: boolean;
  85639. /**
  85640. * Creates a new MorphTargetManager
  85641. * @param scene defines the current scene
  85642. */
  85643. constructor(scene?: Nullable<Scene>);
  85644. /**
  85645. * Gets the unique ID of this manager
  85646. */
  85647. readonly uniqueId: number;
  85648. /**
  85649. * Gets the number of vertices handled by this manager
  85650. */
  85651. readonly vertexCount: number;
  85652. /**
  85653. * Gets a boolean indicating if this manager supports morphing of normals
  85654. */
  85655. readonly supportsNormals: boolean;
  85656. /**
  85657. * Gets a boolean indicating if this manager supports morphing of tangents
  85658. */
  85659. readonly supportsTangents: boolean;
  85660. /**
  85661. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85662. */
  85663. readonly supportsUVs: boolean;
  85664. /**
  85665. * Gets the number of targets stored in this manager
  85666. */
  85667. readonly numTargets: number;
  85668. /**
  85669. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85670. */
  85671. readonly numInfluencers: number;
  85672. /**
  85673. * Gets the list of influences (one per target)
  85674. */
  85675. readonly influences: Float32Array;
  85676. /**
  85677. * Gets the active target at specified index. An active target is a target with an influence > 0
  85678. * @param index defines the index to check
  85679. * @returns the requested target
  85680. */
  85681. getActiveTarget(index: number): MorphTarget;
  85682. /**
  85683. * Gets the target at specified index
  85684. * @param index defines the index to check
  85685. * @returns the requested target
  85686. */
  85687. getTarget(index: number): MorphTarget;
  85688. /**
  85689. * Add a new target to this manager
  85690. * @param target defines the target to add
  85691. */
  85692. addTarget(target: MorphTarget): void;
  85693. /**
  85694. * Removes a target from the manager
  85695. * @param target defines the target to remove
  85696. */
  85697. removeTarget(target: MorphTarget): void;
  85698. /**
  85699. * Serializes the current manager into a Serialization object
  85700. * @returns the serialized object
  85701. */
  85702. serialize(): any;
  85703. private _syncActiveTargets;
  85704. /**
  85705. * Syncrhonize the targets with all the meshes using this morph target manager
  85706. */
  85707. synchronize(): void;
  85708. /**
  85709. * Creates a new MorphTargetManager from serialized data
  85710. * @param serializationObject defines the serialized data
  85711. * @param scene defines the hosting scene
  85712. * @returns the new MorphTargetManager
  85713. */
  85714. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85715. }
  85716. }
  85717. declare module BABYLON {
  85718. /**
  85719. * Class used to represent a specific level of detail of a mesh
  85720. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85721. */
  85722. export class MeshLODLevel {
  85723. /** Defines the distance where this level should star being displayed */
  85724. distance: number;
  85725. /** Defines the mesh to use to render this level */
  85726. mesh: Nullable<Mesh>;
  85727. /**
  85728. * Creates a new LOD level
  85729. * @param distance defines the distance where this level should star being displayed
  85730. * @param mesh defines the mesh to use to render this level
  85731. */
  85732. constructor(
  85733. /** Defines the distance where this level should star being displayed */
  85734. distance: number,
  85735. /** Defines the mesh to use to render this level */
  85736. mesh: Nullable<Mesh>);
  85737. }
  85738. }
  85739. declare module BABYLON {
  85740. /**
  85741. * Mesh representing the gorund
  85742. */
  85743. export class GroundMesh extends Mesh {
  85744. /** If octree should be generated */
  85745. generateOctree: boolean;
  85746. private _heightQuads;
  85747. /** @hidden */
  85748. _subdivisionsX: number;
  85749. /** @hidden */
  85750. _subdivisionsY: number;
  85751. /** @hidden */
  85752. _width: number;
  85753. /** @hidden */
  85754. _height: number;
  85755. /** @hidden */
  85756. _minX: number;
  85757. /** @hidden */
  85758. _maxX: number;
  85759. /** @hidden */
  85760. _minZ: number;
  85761. /** @hidden */
  85762. _maxZ: number;
  85763. constructor(name: string, scene: Scene);
  85764. /**
  85765. * "GroundMesh"
  85766. * @returns "GroundMesh"
  85767. */
  85768. getClassName(): string;
  85769. /**
  85770. * The minimum of x and y subdivisions
  85771. */
  85772. readonly subdivisions: number;
  85773. /**
  85774. * X subdivisions
  85775. */
  85776. readonly subdivisionsX: number;
  85777. /**
  85778. * Y subdivisions
  85779. */
  85780. readonly subdivisionsY: number;
  85781. /**
  85782. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85783. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85784. * @param chunksCount the number of subdivisions for x and y
  85785. * @param octreeBlocksSize (Default: 32)
  85786. */
  85787. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85788. /**
  85789. * Returns a height (y) value in the Worl system :
  85790. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85791. * @param x x coordinate
  85792. * @param z z coordinate
  85793. * @returns the ground y position if (x, z) are outside the ground surface.
  85794. */
  85795. getHeightAtCoordinates(x: number, z: number): number;
  85796. /**
  85797. * Returns a normalized vector (Vector3) orthogonal to the ground
  85798. * at the ground coordinates (x, z) expressed in the World system.
  85799. * @param x x coordinate
  85800. * @param z z coordinate
  85801. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85802. */
  85803. getNormalAtCoordinates(x: number, z: number): Vector3;
  85804. /**
  85805. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85806. * at the ground coordinates (x, z) expressed in the World system.
  85807. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85808. * @param x x coordinate
  85809. * @param z z coordinate
  85810. * @param ref vector to store the result
  85811. * @returns the GroundMesh.
  85812. */
  85813. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85814. /**
  85815. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85816. * if the ground has been updated.
  85817. * This can be used in the render loop.
  85818. * @returns the GroundMesh.
  85819. */
  85820. updateCoordinateHeights(): GroundMesh;
  85821. private _getFacetAt;
  85822. private _initHeightQuads;
  85823. private _computeHeightQuads;
  85824. /**
  85825. * Serializes this ground mesh
  85826. * @param serializationObject object to write serialization to
  85827. */
  85828. serialize(serializationObject: any): void;
  85829. /**
  85830. * Parses a serialized ground mesh
  85831. * @param parsedMesh the serialized mesh
  85832. * @param scene the scene to create the ground mesh in
  85833. * @returns the created ground mesh
  85834. */
  85835. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85836. }
  85837. }
  85838. declare module BABYLON {
  85839. /**
  85840. * Interface for Physics-Joint data
  85841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85842. */
  85843. export interface PhysicsJointData {
  85844. /**
  85845. * The main pivot of the joint
  85846. */
  85847. mainPivot?: Vector3;
  85848. /**
  85849. * The connected pivot of the joint
  85850. */
  85851. connectedPivot?: Vector3;
  85852. /**
  85853. * The main axis of the joint
  85854. */
  85855. mainAxis?: Vector3;
  85856. /**
  85857. * The connected axis of the joint
  85858. */
  85859. connectedAxis?: Vector3;
  85860. /**
  85861. * The collision of the joint
  85862. */
  85863. collision?: boolean;
  85864. /**
  85865. * Native Oimo/Cannon/Energy data
  85866. */
  85867. nativeParams?: any;
  85868. }
  85869. /**
  85870. * This is a holder class for the physics joint created by the physics plugin
  85871. * It holds a set of functions to control the underlying joint
  85872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85873. */
  85874. export class PhysicsJoint {
  85875. /**
  85876. * The type of the physics joint
  85877. */
  85878. type: number;
  85879. /**
  85880. * The data for the physics joint
  85881. */
  85882. jointData: PhysicsJointData;
  85883. private _physicsJoint;
  85884. protected _physicsPlugin: IPhysicsEnginePlugin;
  85885. /**
  85886. * Initializes the physics joint
  85887. * @param type The type of the physics joint
  85888. * @param jointData The data for the physics joint
  85889. */
  85890. constructor(
  85891. /**
  85892. * The type of the physics joint
  85893. */
  85894. type: number,
  85895. /**
  85896. * The data for the physics joint
  85897. */
  85898. jointData: PhysicsJointData);
  85899. /**
  85900. * Gets the physics joint
  85901. */
  85902. /**
  85903. * Sets the physics joint
  85904. */
  85905. physicsJoint: any;
  85906. /**
  85907. * Sets the physics plugin
  85908. */
  85909. physicsPlugin: IPhysicsEnginePlugin;
  85910. /**
  85911. * Execute a function that is physics-plugin specific.
  85912. * @param {Function} func the function that will be executed.
  85913. * It accepts two parameters: the physics world and the physics joint
  85914. */
  85915. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  85916. /**
  85917. * Distance-Joint type
  85918. */
  85919. static DistanceJoint: number;
  85920. /**
  85921. * Hinge-Joint type
  85922. */
  85923. static HingeJoint: number;
  85924. /**
  85925. * Ball-and-Socket joint type
  85926. */
  85927. static BallAndSocketJoint: number;
  85928. /**
  85929. * Wheel-Joint type
  85930. */
  85931. static WheelJoint: number;
  85932. /**
  85933. * Slider-Joint type
  85934. */
  85935. static SliderJoint: number;
  85936. /**
  85937. * Prismatic-Joint type
  85938. */
  85939. static PrismaticJoint: number;
  85940. /**
  85941. * Universal-Joint type
  85942. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  85943. */
  85944. static UniversalJoint: number;
  85945. /**
  85946. * Hinge-Joint 2 type
  85947. */
  85948. static Hinge2Joint: number;
  85949. /**
  85950. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  85951. */
  85952. static PointToPointJoint: number;
  85953. /**
  85954. * Spring-Joint type
  85955. */
  85956. static SpringJoint: number;
  85957. /**
  85958. * Lock-Joint type
  85959. */
  85960. static LockJoint: number;
  85961. }
  85962. /**
  85963. * A class representing a physics distance joint
  85964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85965. */
  85966. export class DistanceJoint extends PhysicsJoint {
  85967. /**
  85968. *
  85969. * @param jointData The data for the Distance-Joint
  85970. */
  85971. constructor(jointData: DistanceJointData);
  85972. /**
  85973. * Update the predefined distance.
  85974. * @param maxDistance The maximum preferred distance
  85975. * @param minDistance The minimum preferred distance
  85976. */
  85977. updateDistance(maxDistance: number, minDistance?: number): void;
  85978. }
  85979. /**
  85980. * Represents a Motor-Enabled Joint
  85981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85982. */
  85983. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  85984. /**
  85985. * Initializes the Motor-Enabled Joint
  85986. * @param type The type of the joint
  85987. * @param jointData The physica joint data for the joint
  85988. */
  85989. constructor(type: number, jointData: PhysicsJointData);
  85990. /**
  85991. * Set the motor values.
  85992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85993. * @param force the force to apply
  85994. * @param maxForce max force for this motor.
  85995. */
  85996. setMotor(force?: number, maxForce?: number): void;
  85997. /**
  85998. * Set the motor's limits.
  85999. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86000. * @param upperLimit The upper limit of the motor
  86001. * @param lowerLimit The lower limit of the motor
  86002. */
  86003. setLimit(upperLimit: number, lowerLimit?: number): void;
  86004. }
  86005. /**
  86006. * This class represents a single physics Hinge-Joint
  86007. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86008. */
  86009. export class HingeJoint extends MotorEnabledJoint {
  86010. /**
  86011. * Initializes the Hinge-Joint
  86012. * @param jointData The joint data for the Hinge-Joint
  86013. */
  86014. constructor(jointData: PhysicsJointData);
  86015. /**
  86016. * Set the motor values.
  86017. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86018. * @param {number} force the force to apply
  86019. * @param {number} maxForce max force for this motor.
  86020. */
  86021. setMotor(force?: number, maxForce?: number): void;
  86022. /**
  86023. * Set the motor's limits.
  86024. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86025. * @param upperLimit The upper limit of the motor
  86026. * @param lowerLimit The lower limit of the motor
  86027. */
  86028. setLimit(upperLimit: number, lowerLimit?: number): void;
  86029. }
  86030. /**
  86031. * This class represents a dual hinge physics joint (same as wheel joint)
  86032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86033. */
  86034. export class Hinge2Joint extends MotorEnabledJoint {
  86035. /**
  86036. * Initializes the Hinge2-Joint
  86037. * @param jointData The joint data for the Hinge2-Joint
  86038. */
  86039. constructor(jointData: PhysicsJointData);
  86040. /**
  86041. * Set the motor values.
  86042. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86043. * @param {number} targetSpeed the speed the motor is to reach
  86044. * @param {number} maxForce max force for this motor.
  86045. * @param {motorIndex} the motor's index, 0 or 1.
  86046. */
  86047. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86048. /**
  86049. * Set the motor limits.
  86050. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86051. * @param {number} upperLimit the upper limit
  86052. * @param {number} lowerLimit lower limit
  86053. * @param {motorIndex} the motor's index, 0 or 1.
  86054. */
  86055. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86056. }
  86057. /**
  86058. * Interface for a motor enabled joint
  86059. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86060. */
  86061. export interface IMotorEnabledJoint {
  86062. /**
  86063. * Physics joint
  86064. */
  86065. physicsJoint: any;
  86066. /**
  86067. * Sets the motor of the motor-enabled joint
  86068. * @param force The force of the motor
  86069. * @param maxForce The maximum force of the motor
  86070. * @param motorIndex The index of the motor
  86071. */
  86072. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86073. /**
  86074. * Sets the limit of the motor
  86075. * @param upperLimit The upper limit of the motor
  86076. * @param lowerLimit The lower limit of the motor
  86077. * @param motorIndex The index of the motor
  86078. */
  86079. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86080. }
  86081. /**
  86082. * Joint data for a Distance-Joint
  86083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86084. */
  86085. export interface DistanceJointData extends PhysicsJointData {
  86086. /**
  86087. * Max distance the 2 joint objects can be apart
  86088. */
  86089. maxDistance: number;
  86090. }
  86091. /**
  86092. * Joint data from a spring joint
  86093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86094. */
  86095. export interface SpringJointData extends PhysicsJointData {
  86096. /**
  86097. * Length of the spring
  86098. */
  86099. length: number;
  86100. /**
  86101. * Stiffness of the spring
  86102. */
  86103. stiffness: number;
  86104. /**
  86105. * Damping of the spring
  86106. */
  86107. damping: number;
  86108. /** this callback will be called when applying the force to the impostors. */
  86109. forceApplicationCallback: () => void;
  86110. }
  86111. }
  86112. declare module BABYLON {
  86113. /**
  86114. * Holds the data for the raycast result
  86115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86116. */
  86117. export class PhysicsRaycastResult {
  86118. private _hasHit;
  86119. private _hitDistance;
  86120. private _hitNormalWorld;
  86121. private _hitPointWorld;
  86122. private _rayFromWorld;
  86123. private _rayToWorld;
  86124. /**
  86125. * Gets if there was a hit
  86126. */
  86127. readonly hasHit: boolean;
  86128. /**
  86129. * Gets the distance from the hit
  86130. */
  86131. readonly hitDistance: number;
  86132. /**
  86133. * Gets the hit normal/direction in the world
  86134. */
  86135. readonly hitNormalWorld: Vector3;
  86136. /**
  86137. * Gets the hit point in the world
  86138. */
  86139. readonly hitPointWorld: Vector3;
  86140. /**
  86141. * Gets the ray "start point" of the ray in the world
  86142. */
  86143. readonly rayFromWorld: Vector3;
  86144. /**
  86145. * Gets the ray "end point" of the ray in the world
  86146. */
  86147. readonly rayToWorld: Vector3;
  86148. /**
  86149. * Sets the hit data (normal & point in world space)
  86150. * @param hitNormalWorld defines the normal in world space
  86151. * @param hitPointWorld defines the point in world space
  86152. */
  86153. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86154. /**
  86155. * Sets the distance from the start point to the hit point
  86156. * @param distance
  86157. */
  86158. setHitDistance(distance: number): void;
  86159. /**
  86160. * Calculates the distance manually
  86161. */
  86162. calculateHitDistance(): void;
  86163. /**
  86164. * Resets all the values to default
  86165. * @param from The from point on world space
  86166. * @param to The to point on world space
  86167. */
  86168. reset(from?: Vector3, to?: Vector3): void;
  86169. }
  86170. /**
  86171. * Interface for the size containing width and height
  86172. */
  86173. interface IXYZ {
  86174. /**
  86175. * X
  86176. */
  86177. x: number;
  86178. /**
  86179. * Y
  86180. */
  86181. y: number;
  86182. /**
  86183. * Z
  86184. */
  86185. z: number;
  86186. }
  86187. }
  86188. declare module BABYLON {
  86189. /**
  86190. * Interface used to describe a physics joint
  86191. */
  86192. export interface PhysicsImpostorJoint {
  86193. /** Defines the main impostor to which the joint is linked */
  86194. mainImpostor: PhysicsImpostor;
  86195. /** Defines the impostor that is connected to the main impostor using this joint */
  86196. connectedImpostor: PhysicsImpostor;
  86197. /** Defines the joint itself */
  86198. joint: PhysicsJoint;
  86199. }
  86200. /** @hidden */
  86201. export interface IPhysicsEnginePlugin {
  86202. world: any;
  86203. name: string;
  86204. setGravity(gravity: Vector3): void;
  86205. setTimeStep(timeStep: number): void;
  86206. getTimeStep(): number;
  86207. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86208. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86209. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86210. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86211. removePhysicsBody(impostor: PhysicsImpostor): void;
  86212. generateJoint(joint: PhysicsImpostorJoint): void;
  86213. removeJoint(joint: PhysicsImpostorJoint): void;
  86214. isSupported(): boolean;
  86215. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86216. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86217. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86218. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86219. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86220. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86221. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86222. getBodyMass(impostor: PhysicsImpostor): number;
  86223. getBodyFriction(impostor: PhysicsImpostor): number;
  86224. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86225. getBodyRestitution(impostor: PhysicsImpostor): number;
  86226. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86227. getBodyPressure?(impostor: PhysicsImpostor): number;
  86228. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86229. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86230. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86231. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86232. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86233. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86234. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86235. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86236. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86237. sleepBody(impostor: PhysicsImpostor): void;
  86238. wakeUpBody(impostor: PhysicsImpostor): void;
  86239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86240. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86241. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86242. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86243. getRadius(impostor: PhysicsImpostor): number;
  86244. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86245. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86246. dispose(): void;
  86247. }
  86248. /**
  86249. * Interface used to define a physics engine
  86250. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86251. */
  86252. export interface IPhysicsEngine {
  86253. /**
  86254. * Gets the gravity vector used by the simulation
  86255. */
  86256. gravity: Vector3;
  86257. /**
  86258. * Sets the gravity vector used by the simulation
  86259. * @param gravity defines the gravity vector to use
  86260. */
  86261. setGravity(gravity: Vector3): void;
  86262. /**
  86263. * Set the time step of the physics engine.
  86264. * Default is 1/60.
  86265. * To slow it down, enter 1/600 for example.
  86266. * To speed it up, 1/30
  86267. * @param newTimeStep the new timestep to apply to this world.
  86268. */
  86269. setTimeStep(newTimeStep: number): void;
  86270. /**
  86271. * Get the time step of the physics engine.
  86272. * @returns the current time step
  86273. */
  86274. getTimeStep(): number;
  86275. /**
  86276. * Release all resources
  86277. */
  86278. dispose(): void;
  86279. /**
  86280. * Gets the name of the current physics plugin
  86281. * @returns the name of the plugin
  86282. */
  86283. getPhysicsPluginName(): string;
  86284. /**
  86285. * Adding a new impostor for the impostor tracking.
  86286. * This will be done by the impostor itself.
  86287. * @param impostor the impostor to add
  86288. */
  86289. addImpostor(impostor: PhysicsImpostor): void;
  86290. /**
  86291. * Remove an impostor from the engine.
  86292. * This impostor and its mesh will not longer be updated by the physics engine.
  86293. * @param impostor the impostor to remove
  86294. */
  86295. removeImpostor(impostor: PhysicsImpostor): void;
  86296. /**
  86297. * Add a joint to the physics engine
  86298. * @param mainImpostor defines the main impostor to which the joint is added.
  86299. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86300. * @param joint defines the joint that will connect both impostors.
  86301. */
  86302. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86303. /**
  86304. * Removes a joint from the simulation
  86305. * @param mainImpostor defines the impostor used with the joint
  86306. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86307. * @param joint defines the joint to remove
  86308. */
  86309. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86310. /**
  86311. * Gets the current plugin used to run the simulation
  86312. * @returns current plugin
  86313. */
  86314. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86315. /**
  86316. * Gets the list of physic impostors
  86317. * @returns an array of PhysicsImpostor
  86318. */
  86319. getImpostors(): Array<PhysicsImpostor>;
  86320. /**
  86321. * Gets the impostor for a physics enabled object
  86322. * @param object defines the object impersonated by the impostor
  86323. * @returns the PhysicsImpostor or null if not found
  86324. */
  86325. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86326. /**
  86327. * Gets the impostor for a physics body object
  86328. * @param body defines physics body used by the impostor
  86329. * @returns the PhysicsImpostor or null if not found
  86330. */
  86331. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86332. /**
  86333. * Does a raycast in the physics world
  86334. * @param from when should the ray start?
  86335. * @param to when should the ray end?
  86336. * @returns PhysicsRaycastResult
  86337. */
  86338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86339. /**
  86340. * Called by the scene. No need to call it.
  86341. * @param delta defines the timespam between frames
  86342. */
  86343. _step(delta: number): void;
  86344. }
  86345. }
  86346. declare module BABYLON {
  86347. /**
  86348. * The interface for the physics imposter parameters
  86349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86350. */
  86351. export interface PhysicsImpostorParameters {
  86352. /**
  86353. * The mass of the physics imposter
  86354. */
  86355. mass: number;
  86356. /**
  86357. * The friction of the physics imposter
  86358. */
  86359. friction?: number;
  86360. /**
  86361. * The coefficient of restitution of the physics imposter
  86362. */
  86363. restitution?: number;
  86364. /**
  86365. * The native options of the physics imposter
  86366. */
  86367. nativeOptions?: any;
  86368. /**
  86369. * Specifies if the parent should be ignored
  86370. */
  86371. ignoreParent?: boolean;
  86372. /**
  86373. * Specifies if bi-directional transformations should be disabled
  86374. */
  86375. disableBidirectionalTransformation?: boolean;
  86376. /**
  86377. * The pressure inside the physics imposter, soft object only
  86378. */
  86379. pressure?: number;
  86380. /**
  86381. * The stiffness the physics imposter, soft object only
  86382. */
  86383. stiffness?: number;
  86384. /**
  86385. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86386. */
  86387. velocityIterations?: number;
  86388. /**
  86389. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86390. */
  86391. positionIterations?: number;
  86392. /**
  86393. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86394. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86395. * Add to fix multiple points
  86396. */
  86397. fixedPoints?: number;
  86398. /**
  86399. * The collision margin around a soft object
  86400. */
  86401. margin?: number;
  86402. /**
  86403. * The collision margin around a soft object
  86404. */
  86405. damping?: number;
  86406. /**
  86407. * The path for a rope based on an extrusion
  86408. */
  86409. path?: any;
  86410. /**
  86411. * The shape of an extrusion used for a rope based on an extrusion
  86412. */
  86413. shape?: any;
  86414. }
  86415. /**
  86416. * Interface for a physics-enabled object
  86417. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86418. */
  86419. export interface IPhysicsEnabledObject {
  86420. /**
  86421. * The position of the physics-enabled object
  86422. */
  86423. position: Vector3;
  86424. /**
  86425. * The rotation of the physics-enabled object
  86426. */
  86427. rotationQuaternion: Nullable<Quaternion>;
  86428. /**
  86429. * The scale of the physics-enabled object
  86430. */
  86431. scaling: Vector3;
  86432. /**
  86433. * The rotation of the physics-enabled object
  86434. */
  86435. rotation?: Vector3;
  86436. /**
  86437. * The parent of the physics-enabled object
  86438. */
  86439. parent?: any;
  86440. /**
  86441. * The bounding info of the physics-enabled object
  86442. * @returns The bounding info of the physics-enabled object
  86443. */
  86444. getBoundingInfo(): BoundingInfo;
  86445. /**
  86446. * Computes the world matrix
  86447. * @param force Specifies if the world matrix should be computed by force
  86448. * @returns A world matrix
  86449. */
  86450. computeWorldMatrix(force: boolean): Matrix;
  86451. /**
  86452. * Gets the world matrix
  86453. * @returns A world matrix
  86454. */
  86455. getWorldMatrix?(): Matrix;
  86456. /**
  86457. * Gets the child meshes
  86458. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86459. * @returns An array of abstract meshes
  86460. */
  86461. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86462. /**
  86463. * Gets the vertex data
  86464. * @param kind The type of vertex data
  86465. * @returns A nullable array of numbers, or a float32 array
  86466. */
  86467. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86468. /**
  86469. * Gets the indices from the mesh
  86470. * @returns A nullable array of index arrays
  86471. */
  86472. getIndices?(): Nullable<IndicesArray>;
  86473. /**
  86474. * Gets the scene from the mesh
  86475. * @returns the indices array or null
  86476. */
  86477. getScene?(): Scene;
  86478. /**
  86479. * Gets the absolute position from the mesh
  86480. * @returns the absolute position
  86481. */
  86482. getAbsolutePosition(): Vector3;
  86483. /**
  86484. * Gets the absolute pivot point from the mesh
  86485. * @returns the absolute pivot point
  86486. */
  86487. getAbsolutePivotPoint(): Vector3;
  86488. /**
  86489. * Rotates the mesh
  86490. * @param axis The axis of rotation
  86491. * @param amount The amount of rotation
  86492. * @param space The space of the rotation
  86493. * @returns The rotation transform node
  86494. */
  86495. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86496. /**
  86497. * Translates the mesh
  86498. * @param axis The axis of translation
  86499. * @param distance The distance of translation
  86500. * @param space The space of the translation
  86501. * @returns The transform node
  86502. */
  86503. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86504. /**
  86505. * Sets the absolute position of the mesh
  86506. * @param absolutePosition The absolute position of the mesh
  86507. * @returns The transform node
  86508. */
  86509. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86510. /**
  86511. * Gets the class name of the mesh
  86512. * @returns The class name
  86513. */
  86514. getClassName(): string;
  86515. }
  86516. /**
  86517. * Represents a physics imposter
  86518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86519. */
  86520. export class PhysicsImpostor {
  86521. /**
  86522. * The physics-enabled object used as the physics imposter
  86523. */
  86524. object: IPhysicsEnabledObject;
  86525. /**
  86526. * The type of the physics imposter
  86527. */
  86528. type: number;
  86529. private _options;
  86530. private _scene?;
  86531. /**
  86532. * The default object size of the imposter
  86533. */
  86534. static DEFAULT_OBJECT_SIZE: Vector3;
  86535. /**
  86536. * The identity quaternion of the imposter
  86537. */
  86538. static IDENTITY_QUATERNION: Quaternion;
  86539. /** @hidden */
  86540. _pluginData: any;
  86541. private _physicsEngine;
  86542. private _physicsBody;
  86543. private _bodyUpdateRequired;
  86544. private _onBeforePhysicsStepCallbacks;
  86545. private _onAfterPhysicsStepCallbacks;
  86546. /** @hidden */
  86547. _onPhysicsCollideCallbacks: Array<{
  86548. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86549. otherImpostors: Array<PhysicsImpostor>;
  86550. }>;
  86551. private _deltaPosition;
  86552. private _deltaRotation;
  86553. private _deltaRotationConjugated;
  86554. /** @hidden */
  86555. _isFromLine: boolean;
  86556. private _parent;
  86557. private _isDisposed;
  86558. private static _tmpVecs;
  86559. private static _tmpQuat;
  86560. /**
  86561. * Specifies if the physics imposter is disposed
  86562. */
  86563. readonly isDisposed: boolean;
  86564. /**
  86565. * Gets the mass of the physics imposter
  86566. */
  86567. mass: number;
  86568. /**
  86569. * Gets the coefficient of friction
  86570. */
  86571. /**
  86572. * Sets the coefficient of friction
  86573. */
  86574. friction: number;
  86575. /**
  86576. * Gets the coefficient of restitution
  86577. */
  86578. /**
  86579. * Sets the coefficient of restitution
  86580. */
  86581. restitution: number;
  86582. /**
  86583. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86584. */
  86585. /**
  86586. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86587. */
  86588. pressure: number;
  86589. /**
  86590. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86591. */
  86592. /**
  86593. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86594. */
  86595. stiffness: number;
  86596. /**
  86597. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86598. */
  86599. /**
  86600. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86601. */
  86602. velocityIterations: number;
  86603. /**
  86604. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86605. */
  86606. /**
  86607. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86608. */
  86609. positionIterations: number;
  86610. /**
  86611. * The unique id of the physics imposter
  86612. * set by the physics engine when adding this impostor to the array
  86613. */
  86614. uniqueId: number;
  86615. /**
  86616. * @hidden
  86617. */
  86618. soft: boolean;
  86619. /**
  86620. * @hidden
  86621. */
  86622. segments: number;
  86623. private _joints;
  86624. /**
  86625. * Initializes the physics imposter
  86626. * @param object The physics-enabled object used as the physics imposter
  86627. * @param type The type of the physics imposter
  86628. * @param _options The options for the physics imposter
  86629. * @param _scene The Babylon scene
  86630. */
  86631. constructor(
  86632. /**
  86633. * The physics-enabled object used as the physics imposter
  86634. */
  86635. object: IPhysicsEnabledObject,
  86636. /**
  86637. * The type of the physics imposter
  86638. */
  86639. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86640. /**
  86641. * This function will completly initialize this impostor.
  86642. * It will create a new body - but only if this mesh has no parent.
  86643. * If it has, this impostor will not be used other than to define the impostor
  86644. * of the child mesh.
  86645. * @hidden
  86646. */
  86647. _init(): void;
  86648. private _getPhysicsParent;
  86649. /**
  86650. * Should a new body be generated.
  86651. * @returns boolean specifying if body initialization is required
  86652. */
  86653. isBodyInitRequired(): boolean;
  86654. /**
  86655. * Sets the updated scaling
  86656. * @param updated Specifies if the scaling is updated
  86657. */
  86658. setScalingUpdated(): void;
  86659. /**
  86660. * Force a regeneration of this or the parent's impostor's body.
  86661. * Use under cautious - This will remove all joints already implemented.
  86662. */
  86663. forceUpdate(): void;
  86664. /**
  86665. * Gets the body that holds this impostor. Either its own, or its parent.
  86666. */
  86667. /**
  86668. * Set the physics body. Used mainly by the physics engine/plugin
  86669. */
  86670. physicsBody: any;
  86671. /**
  86672. * Get the parent of the physics imposter
  86673. * @returns Physics imposter or null
  86674. */
  86675. /**
  86676. * Sets the parent of the physics imposter
  86677. */
  86678. parent: Nullable<PhysicsImpostor>;
  86679. /**
  86680. * Resets the update flags
  86681. */
  86682. resetUpdateFlags(): void;
  86683. /**
  86684. * Gets the object extend size
  86685. * @returns the object extend size
  86686. */
  86687. getObjectExtendSize(): Vector3;
  86688. /**
  86689. * Gets the object center
  86690. * @returns The object center
  86691. */
  86692. getObjectCenter(): Vector3;
  86693. /**
  86694. * Get a specific parametes from the options parameter
  86695. * @param paramName The object parameter name
  86696. * @returns The object parameter
  86697. */
  86698. getParam(paramName: string): any;
  86699. /**
  86700. * Sets a specific parameter in the options given to the physics plugin
  86701. * @param paramName The parameter name
  86702. * @param value The value of the parameter
  86703. */
  86704. setParam(paramName: string, value: number): void;
  86705. /**
  86706. * Specifically change the body's mass option. Won't recreate the physics body object
  86707. * @param mass The mass of the physics imposter
  86708. */
  86709. setMass(mass: number): void;
  86710. /**
  86711. * Gets the linear velocity
  86712. * @returns linear velocity or null
  86713. */
  86714. getLinearVelocity(): Nullable<Vector3>;
  86715. /**
  86716. * Sets the linear velocity
  86717. * @param velocity linear velocity or null
  86718. */
  86719. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86720. /**
  86721. * Gets the angular velocity
  86722. * @returns angular velocity or null
  86723. */
  86724. getAngularVelocity(): Nullable<Vector3>;
  86725. /**
  86726. * Sets the angular velocity
  86727. * @param velocity The velocity or null
  86728. */
  86729. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86730. /**
  86731. * Execute a function with the physics plugin native code
  86732. * Provide a function the will have two variables - the world object and the physics body object
  86733. * @param func The function to execute with the physics plugin native code
  86734. */
  86735. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86736. /**
  86737. * Register a function that will be executed before the physics world is stepping forward
  86738. * @param func The function to execute before the physics world is stepped forward
  86739. */
  86740. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86741. /**
  86742. * Unregister a function that will be executed before the physics world is stepping forward
  86743. * @param func The function to execute before the physics world is stepped forward
  86744. */
  86745. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86746. /**
  86747. * Register a function that will be executed after the physics step
  86748. * @param func The function to execute after physics step
  86749. */
  86750. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86751. /**
  86752. * Unregisters a function that will be executed after the physics step
  86753. * @param func The function to execute after physics step
  86754. */
  86755. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86756. /**
  86757. * register a function that will be executed when this impostor collides against a different body
  86758. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86759. * @param func Callback that is executed on collision
  86760. */
  86761. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86762. /**
  86763. * Unregisters the physics imposter on contact
  86764. * @param collideAgainst The physics object to collide against
  86765. * @param func Callback to execute on collision
  86766. */
  86767. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86768. private _tmpQuat;
  86769. private _tmpQuat2;
  86770. /**
  86771. * Get the parent rotation
  86772. * @returns The parent rotation
  86773. */
  86774. getParentsRotation(): Quaternion;
  86775. /**
  86776. * this function is executed by the physics engine.
  86777. */
  86778. beforeStep: () => void;
  86779. /**
  86780. * this function is executed by the physics engine
  86781. */
  86782. afterStep: () => void;
  86783. /**
  86784. * Legacy collision detection event support
  86785. */
  86786. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86787. /**
  86788. * event and body object due to cannon's event-based architecture.
  86789. */
  86790. onCollide: (e: {
  86791. body: any;
  86792. }) => void;
  86793. /**
  86794. * Apply a force
  86795. * @param force The force to apply
  86796. * @param contactPoint The contact point for the force
  86797. * @returns The physics imposter
  86798. */
  86799. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86800. /**
  86801. * Apply an impulse
  86802. * @param force The impulse force
  86803. * @param contactPoint The contact point for the impulse force
  86804. * @returns The physics imposter
  86805. */
  86806. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86807. /**
  86808. * A help function to create a joint
  86809. * @param otherImpostor A physics imposter used to create a joint
  86810. * @param jointType The type of joint
  86811. * @param jointData The data for the joint
  86812. * @returns The physics imposter
  86813. */
  86814. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86815. /**
  86816. * Add a joint to this impostor with a different impostor
  86817. * @param otherImpostor A physics imposter used to add a joint
  86818. * @param joint The joint to add
  86819. * @returns The physics imposter
  86820. */
  86821. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86822. /**
  86823. * Add an anchor to a cloth impostor
  86824. * @param otherImpostor rigid impostor to anchor to
  86825. * @param width ratio across width from 0 to 1
  86826. * @param height ratio up height from 0 to 1
  86827. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86828. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86829. * @returns impostor the soft imposter
  86830. */
  86831. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86832. /**
  86833. * Add a hook to a rope impostor
  86834. * @param otherImpostor rigid impostor to anchor to
  86835. * @param length ratio across rope from 0 to 1
  86836. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86837. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  86838. * @returns impostor the rope imposter
  86839. */
  86840. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86841. /**
  86842. * Will keep this body still, in a sleep mode.
  86843. * @returns the physics imposter
  86844. */
  86845. sleep(): PhysicsImpostor;
  86846. /**
  86847. * Wake the body up.
  86848. * @returns The physics imposter
  86849. */
  86850. wakeUp(): PhysicsImpostor;
  86851. /**
  86852. * Clones the physics imposter
  86853. * @param newObject The physics imposter clones to this physics-enabled object
  86854. * @returns A nullable physics imposter
  86855. */
  86856. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86857. /**
  86858. * Disposes the physics imposter
  86859. */
  86860. dispose(): void;
  86861. /**
  86862. * Sets the delta position
  86863. * @param position The delta position amount
  86864. */
  86865. setDeltaPosition(position: Vector3): void;
  86866. /**
  86867. * Sets the delta rotation
  86868. * @param rotation The delta rotation amount
  86869. */
  86870. setDeltaRotation(rotation: Quaternion): void;
  86871. /**
  86872. * Gets the box size of the physics imposter and stores the result in the input parameter
  86873. * @param result Stores the box size
  86874. * @returns The physics imposter
  86875. */
  86876. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  86877. /**
  86878. * Gets the radius of the physics imposter
  86879. * @returns Radius of the physics imposter
  86880. */
  86881. getRadius(): number;
  86882. /**
  86883. * Sync a bone with this impostor
  86884. * @param bone The bone to sync to the impostor.
  86885. * @param boneMesh The mesh that the bone is influencing.
  86886. * @param jointPivot The pivot of the joint / bone in local space.
  86887. * @param distToJoint Optional distance from the impostor to the joint.
  86888. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86889. */
  86890. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  86891. /**
  86892. * Sync impostor to a bone
  86893. * @param bone The bone that the impostor will be synced to.
  86894. * @param boneMesh The mesh that the bone is influencing.
  86895. * @param jointPivot The pivot of the joint / bone in local space.
  86896. * @param distToJoint Optional distance from the impostor to the joint.
  86897. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86898. * @param boneAxis Optional vector3 axis the bone is aligned with
  86899. */
  86900. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  86901. /**
  86902. * No-Imposter type
  86903. */
  86904. static NoImpostor: number;
  86905. /**
  86906. * Sphere-Imposter type
  86907. */
  86908. static SphereImpostor: number;
  86909. /**
  86910. * Box-Imposter type
  86911. */
  86912. static BoxImpostor: number;
  86913. /**
  86914. * Plane-Imposter type
  86915. */
  86916. static PlaneImpostor: number;
  86917. /**
  86918. * Mesh-imposter type
  86919. */
  86920. static MeshImpostor: number;
  86921. /**
  86922. * Capsule-Impostor type (Ammo.js plugin only)
  86923. */
  86924. static CapsuleImpostor: number;
  86925. /**
  86926. * Cylinder-Imposter type
  86927. */
  86928. static CylinderImpostor: number;
  86929. /**
  86930. * Particle-Imposter type
  86931. */
  86932. static ParticleImpostor: number;
  86933. /**
  86934. * Heightmap-Imposter type
  86935. */
  86936. static HeightmapImpostor: number;
  86937. /**
  86938. * ConvexHull-Impostor type (Ammo.js plugin only)
  86939. */
  86940. static ConvexHullImpostor: number;
  86941. /**
  86942. * Rope-Imposter type
  86943. */
  86944. static RopeImpostor: number;
  86945. /**
  86946. * Cloth-Imposter type
  86947. */
  86948. static ClothImpostor: number;
  86949. /**
  86950. * Softbody-Imposter type
  86951. */
  86952. static SoftbodyImpostor: number;
  86953. }
  86954. }
  86955. declare module BABYLON {
  86956. /**
  86957. * @hidden
  86958. **/
  86959. export class _CreationDataStorage {
  86960. closePath?: boolean;
  86961. closeArray?: boolean;
  86962. idx: number[];
  86963. dashSize: number;
  86964. gapSize: number;
  86965. path3D: Path3D;
  86966. pathArray: Vector3[][];
  86967. arc: number;
  86968. radius: number;
  86969. cap: number;
  86970. tessellation: number;
  86971. }
  86972. /**
  86973. * @hidden
  86974. **/
  86975. class _InstanceDataStorage {
  86976. visibleInstances: any;
  86977. batchCache: _InstancesBatch;
  86978. instancesBufferSize: number;
  86979. instancesBuffer: Nullable<Buffer>;
  86980. instancesData: Float32Array;
  86981. overridenInstanceCount: number;
  86982. isFrozen: boolean;
  86983. previousBatch: Nullable<_InstancesBatch>;
  86984. hardwareInstancedRendering: boolean;
  86985. sideOrientation: number;
  86986. }
  86987. /**
  86988. * @hidden
  86989. **/
  86990. export class _InstancesBatch {
  86991. mustReturn: boolean;
  86992. visibleInstances: Nullable<InstancedMesh[]>[];
  86993. renderSelf: boolean[];
  86994. hardwareInstancedRendering: boolean[];
  86995. }
  86996. /**
  86997. * Class used to represent renderable models
  86998. */
  86999. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  87000. /**
  87001. * Mesh side orientation : usually the external or front surface
  87002. */
  87003. static readonly FRONTSIDE: number;
  87004. /**
  87005. * Mesh side orientation : usually the internal or back surface
  87006. */
  87007. static readonly BACKSIDE: number;
  87008. /**
  87009. * Mesh side orientation : both internal and external or front and back surfaces
  87010. */
  87011. static readonly DOUBLESIDE: number;
  87012. /**
  87013. * Mesh side orientation : by default, `FRONTSIDE`
  87014. */
  87015. static readonly DEFAULTSIDE: number;
  87016. /**
  87017. * Mesh cap setting : no cap
  87018. */
  87019. static readonly NO_CAP: number;
  87020. /**
  87021. * Mesh cap setting : one cap at the beginning of the mesh
  87022. */
  87023. static readonly CAP_START: number;
  87024. /**
  87025. * Mesh cap setting : one cap at the end of the mesh
  87026. */
  87027. static readonly CAP_END: number;
  87028. /**
  87029. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87030. */
  87031. static readonly CAP_ALL: number;
  87032. /**
  87033. * Mesh pattern setting : no flip or rotate
  87034. */
  87035. static readonly NO_FLIP: number;
  87036. /**
  87037. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87038. */
  87039. static readonly FLIP_TILE: number;
  87040. /**
  87041. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87042. */
  87043. static readonly ROTATE_TILE: number;
  87044. /**
  87045. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87046. */
  87047. static readonly FLIP_ROW: number;
  87048. /**
  87049. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87050. */
  87051. static readonly ROTATE_ROW: number;
  87052. /**
  87053. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87054. */
  87055. static readonly FLIP_N_ROTATE_TILE: number;
  87056. /**
  87057. * Mesh pattern setting : rotate pattern and rotate
  87058. */
  87059. static readonly FLIP_N_ROTATE_ROW: number;
  87060. /**
  87061. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87062. */
  87063. static readonly CENTER: number;
  87064. /**
  87065. * Mesh tile positioning : part tiles on left
  87066. */
  87067. static readonly LEFT: number;
  87068. /**
  87069. * Mesh tile positioning : part tiles on right
  87070. */
  87071. static readonly RIGHT: number;
  87072. /**
  87073. * Mesh tile positioning : part tiles on top
  87074. */
  87075. static readonly TOP: number;
  87076. /**
  87077. * Mesh tile positioning : part tiles on bottom
  87078. */
  87079. static readonly BOTTOM: number;
  87080. /**
  87081. * Gets the default side orientation.
  87082. * @param orientation the orientation to value to attempt to get
  87083. * @returns the default orientation
  87084. * @hidden
  87085. */
  87086. static _GetDefaultSideOrientation(orientation?: number): number;
  87087. private _internalMeshDataInfo;
  87088. /**
  87089. * An event triggered before rendering the mesh
  87090. */
  87091. readonly onBeforeRenderObservable: Observable<Mesh>;
  87092. /**
  87093. * An event triggered before binding the mesh
  87094. */
  87095. readonly onBeforeBindObservable: Observable<Mesh>;
  87096. /**
  87097. * An event triggered after rendering the mesh
  87098. */
  87099. readonly onAfterRenderObservable: Observable<Mesh>;
  87100. /**
  87101. * An event triggered before drawing the mesh
  87102. */
  87103. readonly onBeforeDrawObservable: Observable<Mesh>;
  87104. private _onBeforeDrawObserver;
  87105. /**
  87106. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87107. */
  87108. onBeforeDraw: () => void;
  87109. /**
  87110. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87111. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87112. */
  87113. delayLoadState: number;
  87114. /**
  87115. * Gets the list of instances created from this mesh
  87116. * it is not supposed to be modified manually.
  87117. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87118. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87119. */
  87120. instances: InstancedMesh[];
  87121. /**
  87122. * Gets the file containing delay loading data for this mesh
  87123. */
  87124. delayLoadingFile: string;
  87125. /** @hidden */
  87126. _binaryInfo: any;
  87127. /**
  87128. * User defined function used to change how LOD level selection is done
  87129. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87130. */
  87131. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87132. /**
  87133. * Gets or sets the morph target manager
  87134. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87135. */
  87136. morphTargetManager: Nullable<MorphTargetManager>;
  87137. /** @hidden */
  87138. _creationDataStorage: Nullable<_CreationDataStorage>;
  87139. /** @hidden */
  87140. _geometry: Nullable<Geometry>;
  87141. /** @hidden */
  87142. _delayInfo: Array<string>;
  87143. /** @hidden */
  87144. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87145. /** @hidden */
  87146. _instanceDataStorage: _InstanceDataStorage;
  87147. private _effectiveMaterial;
  87148. /** @hidden */
  87149. _shouldGenerateFlatShading: boolean;
  87150. /** @hidden */
  87151. _originalBuilderSideOrientation: number;
  87152. /**
  87153. * Use this property to change the original side orientation defined at construction time
  87154. */
  87155. overrideMaterialSideOrientation: Nullable<number>;
  87156. /**
  87157. * Gets the source mesh (the one used to clone this one from)
  87158. */
  87159. readonly source: Nullable<Mesh>;
  87160. /**
  87161. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87162. */
  87163. isUnIndexed: boolean;
  87164. /**
  87165. * @constructor
  87166. * @param name The value used by scene.getMeshByName() to do a lookup.
  87167. * @param scene The scene to add this mesh to.
  87168. * @param parent The parent of this mesh, if it has one
  87169. * @param source An optional Mesh from which geometry is shared, cloned.
  87170. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87171. * When false, achieved by calling a clone(), also passing False.
  87172. * This will make creation of children, recursive.
  87173. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87174. */
  87175. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87176. /**
  87177. * Gets the class name
  87178. * @returns the string "Mesh".
  87179. */
  87180. getClassName(): string;
  87181. /** @hidden */
  87182. readonly _isMesh: boolean;
  87183. /**
  87184. * Returns a description of this mesh
  87185. * @param fullDetails define if full details about this mesh must be used
  87186. * @returns a descriptive string representing this mesh
  87187. */
  87188. toString(fullDetails?: boolean): string;
  87189. /** @hidden */
  87190. _unBindEffect(): void;
  87191. /**
  87192. * Gets a boolean indicating if this mesh has LOD
  87193. */
  87194. readonly hasLODLevels: boolean;
  87195. /**
  87196. * Gets the list of MeshLODLevel associated with the current mesh
  87197. * @returns an array of MeshLODLevel
  87198. */
  87199. getLODLevels(): MeshLODLevel[];
  87200. private _sortLODLevels;
  87201. /**
  87202. * Add a mesh as LOD level triggered at the given distance.
  87203. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87204. * @param distance The distance from the center of the object to show this level
  87205. * @param mesh The mesh to be added as LOD level (can be null)
  87206. * @return This mesh (for chaining)
  87207. */
  87208. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87209. /**
  87210. * Returns the LOD level mesh at the passed distance or null if not found.
  87211. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87212. * @param distance The distance from the center of the object to show this level
  87213. * @returns a Mesh or `null`
  87214. */
  87215. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87216. /**
  87217. * Remove a mesh from the LOD array
  87218. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87219. * @param mesh defines the mesh to be removed
  87220. * @return This mesh (for chaining)
  87221. */
  87222. removeLODLevel(mesh: Mesh): Mesh;
  87223. /**
  87224. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87225. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87226. * @param camera defines the camera to use to compute distance
  87227. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87228. * @return This mesh (for chaining)
  87229. */
  87230. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87231. /**
  87232. * Gets the mesh internal Geometry object
  87233. */
  87234. readonly geometry: Nullable<Geometry>;
  87235. /**
  87236. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87237. * @returns the total number of vertices
  87238. */
  87239. getTotalVertices(): number;
  87240. /**
  87241. * Returns the content of an associated vertex buffer
  87242. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87243. * - VertexBuffer.PositionKind
  87244. * - VertexBuffer.UVKind
  87245. * - VertexBuffer.UV2Kind
  87246. * - VertexBuffer.UV3Kind
  87247. * - VertexBuffer.UV4Kind
  87248. * - VertexBuffer.UV5Kind
  87249. * - VertexBuffer.UV6Kind
  87250. * - VertexBuffer.ColorKind
  87251. * - VertexBuffer.MatricesIndicesKind
  87252. * - VertexBuffer.MatricesIndicesExtraKind
  87253. * - VertexBuffer.MatricesWeightsKind
  87254. * - VertexBuffer.MatricesWeightsExtraKind
  87255. * @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
  87256. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87257. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87258. */
  87259. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87260. /**
  87261. * Returns the mesh VertexBuffer object from the requested `kind`
  87262. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87263. * - VertexBuffer.PositionKind
  87264. * - VertexBuffer.NormalKind
  87265. * - VertexBuffer.UVKind
  87266. * - VertexBuffer.UV2Kind
  87267. * - VertexBuffer.UV3Kind
  87268. * - VertexBuffer.UV4Kind
  87269. * - VertexBuffer.UV5Kind
  87270. * - VertexBuffer.UV6Kind
  87271. * - VertexBuffer.ColorKind
  87272. * - VertexBuffer.MatricesIndicesKind
  87273. * - VertexBuffer.MatricesIndicesExtraKind
  87274. * - VertexBuffer.MatricesWeightsKind
  87275. * - VertexBuffer.MatricesWeightsExtraKind
  87276. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87277. */
  87278. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87279. /**
  87280. * Tests if a specific vertex buffer is associated with this mesh
  87281. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87282. * - VertexBuffer.PositionKind
  87283. * - VertexBuffer.NormalKind
  87284. * - VertexBuffer.UVKind
  87285. * - VertexBuffer.UV2Kind
  87286. * - VertexBuffer.UV3Kind
  87287. * - VertexBuffer.UV4Kind
  87288. * - VertexBuffer.UV5Kind
  87289. * - VertexBuffer.UV6Kind
  87290. * - VertexBuffer.ColorKind
  87291. * - VertexBuffer.MatricesIndicesKind
  87292. * - VertexBuffer.MatricesIndicesExtraKind
  87293. * - VertexBuffer.MatricesWeightsKind
  87294. * - VertexBuffer.MatricesWeightsExtraKind
  87295. * @returns a boolean
  87296. */
  87297. isVerticesDataPresent(kind: string): boolean;
  87298. /**
  87299. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87300. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87301. * - VertexBuffer.PositionKind
  87302. * - VertexBuffer.UVKind
  87303. * - VertexBuffer.UV2Kind
  87304. * - VertexBuffer.UV3Kind
  87305. * - VertexBuffer.UV4Kind
  87306. * - VertexBuffer.UV5Kind
  87307. * - VertexBuffer.UV6Kind
  87308. * - VertexBuffer.ColorKind
  87309. * - VertexBuffer.MatricesIndicesKind
  87310. * - VertexBuffer.MatricesIndicesExtraKind
  87311. * - VertexBuffer.MatricesWeightsKind
  87312. * - VertexBuffer.MatricesWeightsExtraKind
  87313. * @returns a boolean
  87314. */
  87315. isVertexBufferUpdatable(kind: string): boolean;
  87316. /**
  87317. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87318. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87319. * - VertexBuffer.PositionKind
  87320. * - VertexBuffer.NormalKind
  87321. * - VertexBuffer.UVKind
  87322. * - VertexBuffer.UV2Kind
  87323. * - VertexBuffer.UV3Kind
  87324. * - VertexBuffer.UV4Kind
  87325. * - VertexBuffer.UV5Kind
  87326. * - VertexBuffer.UV6Kind
  87327. * - VertexBuffer.ColorKind
  87328. * - VertexBuffer.MatricesIndicesKind
  87329. * - VertexBuffer.MatricesIndicesExtraKind
  87330. * - VertexBuffer.MatricesWeightsKind
  87331. * - VertexBuffer.MatricesWeightsExtraKind
  87332. * @returns an array of strings
  87333. */
  87334. getVerticesDataKinds(): string[];
  87335. /**
  87336. * Returns a positive integer : the total number of indices in this mesh geometry.
  87337. * @returns the numner of indices or zero if the mesh has no geometry.
  87338. */
  87339. getTotalIndices(): number;
  87340. /**
  87341. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87342. * @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.
  87343. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87344. * @returns the indices array or an empty array if the mesh has no geometry
  87345. */
  87346. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87347. readonly isBlocked: boolean;
  87348. /**
  87349. * Determine if the current mesh is ready to be rendered
  87350. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87351. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87352. * @returns true if all associated assets are ready (material, textures, shaders)
  87353. */
  87354. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87355. /**
  87356. * 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.
  87357. */
  87358. readonly areNormalsFrozen: boolean;
  87359. /**
  87360. * 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.
  87361. * @returns the current mesh
  87362. */
  87363. freezeNormals(): Mesh;
  87364. /**
  87365. * 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
  87366. * @returns the current mesh
  87367. */
  87368. unfreezeNormals(): Mesh;
  87369. /**
  87370. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87371. */
  87372. overridenInstanceCount: number;
  87373. /** @hidden */
  87374. _preActivate(): Mesh;
  87375. /** @hidden */
  87376. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87377. /** @hidden */
  87378. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87379. /**
  87380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87381. * This means the mesh underlying bounding box and sphere are recomputed.
  87382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87383. * @returns the current mesh
  87384. */
  87385. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87386. /** @hidden */
  87387. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87388. /**
  87389. * This function will subdivide the mesh into multiple submeshes
  87390. * @param count defines the expected number of submeshes
  87391. */
  87392. subdivide(count: number): void;
  87393. /**
  87394. * Copy a FloatArray into a specific associated vertex buffer
  87395. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87396. * - VertexBuffer.PositionKind
  87397. * - VertexBuffer.UVKind
  87398. * - VertexBuffer.UV2Kind
  87399. * - VertexBuffer.UV3Kind
  87400. * - VertexBuffer.UV4Kind
  87401. * - VertexBuffer.UV5Kind
  87402. * - VertexBuffer.UV6Kind
  87403. * - VertexBuffer.ColorKind
  87404. * - VertexBuffer.MatricesIndicesKind
  87405. * - VertexBuffer.MatricesIndicesExtraKind
  87406. * - VertexBuffer.MatricesWeightsKind
  87407. * - VertexBuffer.MatricesWeightsExtraKind
  87408. * @param data defines the data source
  87409. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87410. * @param stride defines the data stride size (can be null)
  87411. * @returns the current mesh
  87412. */
  87413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87414. /**
  87415. * Flags an associated vertex buffer as updatable
  87416. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87417. * - VertexBuffer.PositionKind
  87418. * - VertexBuffer.UVKind
  87419. * - VertexBuffer.UV2Kind
  87420. * - VertexBuffer.UV3Kind
  87421. * - VertexBuffer.UV4Kind
  87422. * - VertexBuffer.UV5Kind
  87423. * - VertexBuffer.UV6Kind
  87424. * - VertexBuffer.ColorKind
  87425. * - VertexBuffer.MatricesIndicesKind
  87426. * - VertexBuffer.MatricesIndicesExtraKind
  87427. * - VertexBuffer.MatricesWeightsKind
  87428. * - VertexBuffer.MatricesWeightsExtraKind
  87429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87430. */
  87431. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87432. /**
  87433. * Sets the mesh global Vertex Buffer
  87434. * @param buffer defines the buffer to use
  87435. * @returns the current mesh
  87436. */
  87437. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87438. /**
  87439. * Update a specific associated vertex buffer
  87440. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87441. * - VertexBuffer.PositionKind
  87442. * - VertexBuffer.UVKind
  87443. * - VertexBuffer.UV2Kind
  87444. * - VertexBuffer.UV3Kind
  87445. * - VertexBuffer.UV4Kind
  87446. * - VertexBuffer.UV5Kind
  87447. * - VertexBuffer.UV6Kind
  87448. * - VertexBuffer.ColorKind
  87449. * - VertexBuffer.MatricesIndicesKind
  87450. * - VertexBuffer.MatricesIndicesExtraKind
  87451. * - VertexBuffer.MatricesWeightsKind
  87452. * - VertexBuffer.MatricesWeightsExtraKind
  87453. * @param data defines the data source
  87454. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87455. * @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)
  87456. * @returns the current mesh
  87457. */
  87458. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87459. /**
  87460. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87461. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87462. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87463. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87464. * @returns the current mesh
  87465. */
  87466. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87467. /**
  87468. * Creates a un-shared specific occurence of the geometry for the mesh.
  87469. * @returns the current mesh
  87470. */
  87471. makeGeometryUnique(): Mesh;
  87472. /**
  87473. * Set the index buffer of this mesh
  87474. * @param indices defines the source data
  87475. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87476. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87477. * @returns the current mesh
  87478. */
  87479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87480. /**
  87481. * Update the current index buffer
  87482. * @param indices defines the source data
  87483. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87484. * @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)
  87485. * @returns the current mesh
  87486. */
  87487. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87488. /**
  87489. * Invert the geometry to move from a right handed system to a left handed one.
  87490. * @returns the current mesh
  87491. */
  87492. toLeftHanded(): Mesh;
  87493. /** @hidden */
  87494. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87495. /** @hidden */
  87496. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87497. /**
  87498. * Registers for this mesh a javascript function called just before the rendering process
  87499. * @param func defines the function to call before rendering this mesh
  87500. * @returns the current mesh
  87501. */
  87502. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87503. /**
  87504. * Disposes a previously registered javascript function called before the rendering
  87505. * @param func defines the function to remove
  87506. * @returns the current mesh
  87507. */
  87508. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87509. /**
  87510. * Registers for this mesh a javascript function called just after the rendering is complete
  87511. * @param func defines the function to call after rendering this mesh
  87512. * @returns the current mesh
  87513. */
  87514. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87515. /**
  87516. * Disposes a previously registered javascript function called after the rendering.
  87517. * @param func defines the function to remove
  87518. * @returns the current mesh
  87519. */
  87520. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87521. /** @hidden */
  87522. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87523. /** @hidden */
  87524. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87525. /** @hidden */
  87526. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87527. /** @hidden */
  87528. _rebuild(): void;
  87529. /** @hidden */
  87530. _freeze(): void;
  87531. /** @hidden */
  87532. _unFreeze(): void;
  87533. /**
  87534. * 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
  87535. * @param subMesh defines the subMesh to render
  87536. * @param enableAlphaMode defines if alpha mode can be changed
  87537. * @returns the current mesh
  87538. */
  87539. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87540. private _onBeforeDraw;
  87541. /**
  87542. * Renormalize the mesh and patch it up if there are no weights
  87543. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87544. * However in the case of zero weights then we set just a single influence to 1.
  87545. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87546. */
  87547. cleanMatrixWeights(): void;
  87548. private normalizeSkinFourWeights;
  87549. private normalizeSkinWeightsAndExtra;
  87550. /**
  87551. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87552. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87553. * the user know there was an issue with importing the mesh
  87554. * @returns a validation object with skinned, valid and report string
  87555. */
  87556. validateSkinning(): {
  87557. skinned: boolean;
  87558. valid: boolean;
  87559. report: string;
  87560. };
  87561. /** @hidden */
  87562. _checkDelayState(): Mesh;
  87563. private _queueLoad;
  87564. /**
  87565. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87566. * A mesh is in the frustum if its bounding box intersects the frustum
  87567. * @param frustumPlanes defines the frustum to test
  87568. * @returns true if the mesh is in the frustum planes
  87569. */
  87570. isInFrustum(frustumPlanes: Plane[]): boolean;
  87571. /**
  87572. * Sets the mesh material by the material or multiMaterial `id` property
  87573. * @param id is a string identifying the material or the multiMaterial
  87574. * @returns the current mesh
  87575. */
  87576. setMaterialByID(id: string): Mesh;
  87577. /**
  87578. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87579. * @returns an array of IAnimatable
  87580. */
  87581. getAnimatables(): IAnimatable[];
  87582. /**
  87583. * Modifies the mesh geometry according to the passed transformation matrix.
  87584. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87585. * The mesh normals are modified using the same transformation.
  87586. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87587. * @param transform defines the transform matrix to use
  87588. * @see http://doc.babylonjs.com/resources/baking_transformations
  87589. * @returns the current mesh
  87590. */
  87591. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87592. /**
  87593. * Modifies the mesh geometry according to its own current World Matrix.
  87594. * The mesh World Matrix is then reset.
  87595. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87596. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87597. * @see http://doc.babylonjs.com/resources/baking_transformations
  87598. * @returns the current mesh
  87599. */
  87600. bakeCurrentTransformIntoVertices(): Mesh;
  87601. /** @hidden */
  87602. readonly _positions: Nullable<Vector3[]>;
  87603. /** @hidden */
  87604. _resetPointsArrayCache(): Mesh;
  87605. /** @hidden */
  87606. _generatePointsArray(): boolean;
  87607. /**
  87608. * Returns a new Mesh object generated from the current mesh properties.
  87609. * This method must not get confused with createInstance()
  87610. * @param name is a string, the name given to the new mesh
  87611. * @param newParent can be any Node object (default `null`)
  87612. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87613. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87614. * @returns a new mesh
  87615. */
  87616. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87617. /**
  87618. * Releases resources associated with this mesh.
  87619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87621. */
  87622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87623. /**
  87624. * Modifies the mesh geometry according to a displacement map.
  87625. * 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.
  87626. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87627. * @param url is a string, the URL from the image file is to be downloaded.
  87628. * @param minHeight is the lower limit of the displacement.
  87629. * @param maxHeight is the upper limit of the displacement.
  87630. * @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.
  87631. * @param uvOffset is an optional vector2 used to offset UV.
  87632. * @param uvScale is an optional vector2 used to scale UV.
  87633. * @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.
  87634. * @returns the Mesh.
  87635. */
  87636. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87637. /**
  87638. * Modifies the mesh geometry according to a displacementMap buffer.
  87639. * 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.
  87640. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87641. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87642. * @param heightMapWidth is the width of the buffer image.
  87643. * @param heightMapHeight is the height of the buffer image.
  87644. * @param minHeight is the lower limit of the displacement.
  87645. * @param maxHeight is the upper limit of the displacement.
  87646. * @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.
  87647. * @param uvOffset is an optional vector2 used to offset UV.
  87648. * @param uvScale is an optional vector2 used to scale UV.
  87649. * @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.
  87650. * @returns the Mesh.
  87651. */
  87652. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87653. /**
  87654. * Modify the mesh to get a flat shading rendering.
  87655. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87656. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87657. * @returns current mesh
  87658. */
  87659. convertToFlatShadedMesh(): Mesh;
  87660. /**
  87661. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87662. * In other words, more vertices, no more indices and a single bigger VBO.
  87663. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87664. * @returns current mesh
  87665. */
  87666. convertToUnIndexedMesh(): Mesh;
  87667. /**
  87668. * Inverses facet orientations.
  87669. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87670. * @param flipNormals will also inverts the normals
  87671. * @returns current mesh
  87672. */
  87673. flipFaces(flipNormals?: boolean): Mesh;
  87674. /**
  87675. * Increase the number of facets and hence vertices in a mesh
  87676. * Vertex normals are interpolated from existing vertex normals
  87677. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87678. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87679. */
  87680. increaseVertices(numberPerEdge: number): void;
  87681. /**
  87682. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87683. * This will undo any application of covertToFlatShadedMesh
  87684. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87685. */
  87686. forceSharedVertices(): void;
  87687. /** @hidden */
  87688. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87689. /** @hidden */
  87690. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87691. /**
  87692. * Creates a new InstancedMesh object from the mesh model.
  87693. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87694. * @param name defines the name of the new instance
  87695. * @returns a new InstancedMesh
  87696. */
  87697. createInstance(name: string): InstancedMesh;
  87698. /**
  87699. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87700. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87701. * @returns the current mesh
  87702. */
  87703. synchronizeInstances(): Mesh;
  87704. /**
  87705. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87706. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87707. * This should be used together with the simplification to avoid disappearing triangles.
  87708. * @param successCallback an optional success callback to be called after the optimization finished.
  87709. * @returns the current mesh
  87710. */
  87711. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87712. /**
  87713. * Serialize current mesh
  87714. * @param serializationObject defines the object which will receive the serialization data
  87715. */
  87716. serialize(serializationObject: any): void;
  87717. /** @hidden */
  87718. _syncGeometryWithMorphTargetManager(): void;
  87719. /** @hidden */
  87720. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87721. /**
  87722. * Returns a new Mesh object parsed from the source provided.
  87723. * @param parsedMesh is the source
  87724. * @param scene defines the hosting scene
  87725. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87726. * @returns a new Mesh
  87727. */
  87728. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87729. /**
  87730. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87731. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87732. * @param name defines the name of the mesh to create
  87733. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87734. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87735. * @param closePath creates a seam between the first and the last points of each path of the path array
  87736. * @param offset is taken in account only if the `pathArray` is containing a single path
  87737. * @param scene defines the hosting scene
  87738. * @param updatable defines if the mesh must be flagged as updatable
  87739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87740. * @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)
  87741. * @returns a new Mesh
  87742. */
  87743. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87744. /**
  87745. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87746. * @param name defines the name of the mesh to create
  87747. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87748. * @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
  87749. * @param scene defines the hosting scene
  87750. * @param updatable defines if the mesh must be flagged as updatable
  87751. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87752. * @returns a new Mesh
  87753. */
  87754. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87755. /**
  87756. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87757. * @param name defines the name of the mesh to create
  87758. * @param size sets the size (float) of each box side (default 1)
  87759. * @param scene defines the hosting scene
  87760. * @param updatable defines if the mesh must be flagged as updatable
  87761. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87762. * @returns a new Mesh
  87763. */
  87764. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87765. /**
  87766. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87767. * @param name defines the name of the mesh to create
  87768. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87769. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87770. * @param scene defines the hosting scene
  87771. * @param updatable defines if the mesh must be flagged as updatable
  87772. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87773. * @returns a new Mesh
  87774. */
  87775. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87776. /**
  87777. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87778. * @param name defines the name of the mesh to create
  87779. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87780. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87781. * @param scene defines the hosting scene
  87782. * @returns a new Mesh
  87783. */
  87784. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87785. /**
  87786. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87787. * @param name defines the name of the mesh to create
  87788. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87789. * @param diameterTop set the top cap diameter (floats, default 1)
  87790. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87791. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87792. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87793. * @param scene defines the hosting scene
  87794. * @param updatable defines if the mesh must be flagged as updatable
  87795. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87796. * @returns a new Mesh
  87797. */
  87798. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87799. /**
  87800. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87801. * @param name defines the name of the mesh to create
  87802. * @param diameter sets the diameter size (float) of the torus (default 1)
  87803. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87804. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87805. * @param scene defines the hosting scene
  87806. * @param updatable defines if the mesh must be flagged as updatable
  87807. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87808. * @returns a new Mesh
  87809. */
  87810. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87811. /**
  87812. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87813. * @param name defines the name of the mesh to create
  87814. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87815. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87816. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87817. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87818. * @param p the number of windings on X axis (positive integers, default 2)
  87819. * @param q the number of windings on Y axis (positive integers, default 3)
  87820. * @param scene defines the hosting scene
  87821. * @param updatable defines if the mesh must be flagged as updatable
  87822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87823. * @returns a new Mesh
  87824. */
  87825. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87826. /**
  87827. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87828. * @param name defines the name of the mesh to create
  87829. * @param points is an array successive Vector3
  87830. * @param scene defines the hosting scene
  87831. * @param updatable defines if the mesh must be flagged as updatable
  87832. * @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).
  87833. * @returns a new Mesh
  87834. */
  87835. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87836. /**
  87837. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87838. * @param name defines the name of the mesh to create
  87839. * @param points is an array successive Vector3
  87840. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87841. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87842. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87843. * @param scene defines the hosting scene
  87844. * @param updatable defines if the mesh must be flagged as updatable
  87845. * @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)
  87846. * @returns a new Mesh
  87847. */
  87848. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  87849. /**
  87850. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87851. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87852. * 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.
  87853. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87854. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87855. * Remember you can only change the shape positions, not their number when updating a polygon.
  87856. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87857. * @param name defines the name of the mesh to create
  87858. * @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
  87859. * @param scene defines the hosting scene
  87860. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87861. * @param updatable defines if the mesh must be flagged as updatable
  87862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87863. * @param earcutInjection can be used to inject your own earcut reference
  87864. * @returns a new Mesh
  87865. */
  87866. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87867. /**
  87868. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  87869. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  87870. * @param name defines the name of the mesh to create
  87871. * @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
  87872. * @param depth defines the height of extrusion
  87873. * @param scene defines the hosting scene
  87874. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87875. * @param updatable defines if the mesh must be flagged as updatable
  87876. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87877. * @param earcutInjection can be used to inject your own earcut reference
  87878. * @returns a new Mesh
  87879. */
  87880. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87881. /**
  87882. * Creates an extruded shape mesh.
  87883. * 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
  87884. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87886. * @param name defines the name of the mesh to create
  87887. * @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
  87888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87889. * @param scale is the value to scale the shape
  87890. * @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
  87891. * @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
  87892. * @param scene defines the hosting scene
  87893. * @param updatable defines if the mesh must be flagged as updatable
  87894. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87895. * @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)
  87896. * @returns a new Mesh
  87897. */
  87898. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87899. /**
  87900. * Creates an custom extruded shape mesh.
  87901. * The custom extrusion is a parametric shape.
  87902. * It has no predefined shape. Its final shape will depend on the input parameters.
  87903. * Please consider using the same method from the MeshBuilder class instead
  87904. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87905. * @param name defines the name of the mesh to create
  87906. * @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
  87907. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87908. * @param scaleFunction is a custom Javascript function called on each path point
  87909. * @param rotationFunction is a custom Javascript function called on each path point
  87910. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  87911. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  87912. * @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
  87913. * @param scene defines the hosting scene
  87914. * @param updatable defines if the mesh must be flagged as updatable
  87915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87916. * @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)
  87917. * @returns a new Mesh
  87918. */
  87919. 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;
  87920. /**
  87921. * Creates lathe mesh.
  87922. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  87923. * Please consider using the same method from the MeshBuilder class instead
  87924. * @param name defines the name of the mesh to create
  87925. * @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
  87926. * @param radius is the radius value of the lathe
  87927. * @param tessellation is the side number of the lathe.
  87928. * @param scene defines the hosting scene
  87929. * @param updatable defines if the mesh must be flagged as updatable
  87930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87931. * @returns a new Mesh
  87932. */
  87933. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87934. /**
  87935. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  87936. * @param name defines the name of the mesh to create
  87937. * @param size sets the size (float) of both sides of the plane at once (default 1)
  87938. * @param scene defines the hosting scene
  87939. * @param updatable defines if the mesh must be flagged as updatable
  87940. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87941. * @returns a new Mesh
  87942. */
  87943. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87944. /**
  87945. * Creates a ground mesh.
  87946. * Please consider using the same method from the MeshBuilder class instead
  87947. * @param name defines the name of the mesh to create
  87948. * @param width set the width of the ground
  87949. * @param height set the height of the ground
  87950. * @param subdivisions sets the number of subdivisions per side
  87951. * @param scene defines the hosting scene
  87952. * @param updatable defines if the mesh must be flagged as updatable
  87953. * @returns a new Mesh
  87954. */
  87955. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  87956. /**
  87957. * Creates a tiled ground mesh.
  87958. * Please consider using the same method from the MeshBuilder class instead
  87959. * @param name defines the name of the mesh to create
  87960. * @param xmin set the ground minimum X coordinate
  87961. * @param zmin set the ground minimum Y coordinate
  87962. * @param xmax set the ground maximum X coordinate
  87963. * @param zmax set the ground maximum Z coordinate
  87964. * @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
  87965. * @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
  87966. * @param scene defines the hosting scene
  87967. * @param updatable defines if the mesh must be flagged as updatable
  87968. * @returns a new Mesh
  87969. */
  87970. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  87971. w: number;
  87972. h: number;
  87973. }, precision: {
  87974. w: number;
  87975. h: number;
  87976. }, scene: Scene, updatable?: boolean): Mesh;
  87977. /**
  87978. * Creates a ground mesh from a height map.
  87979. * Please consider using the same method from the MeshBuilder class instead
  87980. * @see http://doc.babylonjs.com/babylon101/height_map
  87981. * @param name defines the name of the mesh to create
  87982. * @param url sets the URL of the height map image resource
  87983. * @param width set the ground width size
  87984. * @param height set the ground height size
  87985. * @param subdivisions sets the number of subdivision per side
  87986. * @param minHeight is the minimum altitude on the ground
  87987. * @param maxHeight is the maximum altitude on the ground
  87988. * @param scene defines the hosting scene
  87989. * @param updatable defines if the mesh must be flagged as updatable
  87990. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  87991. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87992. * @returns a new Mesh
  87993. */
  87994. 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;
  87995. /**
  87996. * Creates a tube mesh.
  87997. * The tube is a parametric shape.
  87998. * It has no predefined shape. Its final shape will depend on the input parameters.
  87999. * Please consider using the same method from the MeshBuilder class instead
  88000. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  88001. * @param name defines the name of the mesh to create
  88002. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  88003. * @param radius sets the tube radius size
  88004. * @param tessellation is the number of sides on the tubular surface
  88005. * @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
  88006. * @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
  88007. * @param scene defines the hosting scene
  88008. * @param updatable defines if the mesh must be flagged as updatable
  88009. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  88010. * @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)
  88011. * @returns a new Mesh
  88012. */
  88013. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  88014. (i: number, distance: number): number;
  88015. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  88016. /**
  88017. * Creates a polyhedron mesh.
  88018. * Please consider using the same method from the MeshBuilder class instead.
  88019. * * 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
  88020. * * The parameter `size` (positive float, default 1) sets the polygon size
  88021. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  88022. * * 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`
  88023. * * 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
  88024. * * 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)`)
  88025. * * 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
  88026. * * 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
  88027. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88028. * * If you create a double-sided mesh, you can choose what parts of 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
  88029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88030. * @param name defines the name of the mesh to create
  88031. * @param options defines the options used to create the mesh
  88032. * @param scene defines the hosting scene
  88033. * @returns a new Mesh
  88034. */
  88035. static CreatePolyhedron(name: string, options: {
  88036. type?: number;
  88037. size?: number;
  88038. sizeX?: number;
  88039. sizeY?: number;
  88040. sizeZ?: number;
  88041. custom?: any;
  88042. faceUV?: Vector4[];
  88043. faceColors?: Color4[];
  88044. updatable?: boolean;
  88045. sideOrientation?: number;
  88046. }, scene: Scene): Mesh;
  88047. /**
  88048. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88049. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88050. * * 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`)
  88051. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88052. * * 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
  88053. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88054. * * If you create a double-sided mesh, you can choose what parts of 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
  88055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88056. * @param name defines the name of the mesh
  88057. * @param options defines the options used to create the mesh
  88058. * @param scene defines the hosting scene
  88059. * @returns a new Mesh
  88060. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88061. */
  88062. static CreateIcoSphere(name: string, options: {
  88063. radius?: number;
  88064. flat?: boolean;
  88065. subdivisions?: number;
  88066. sideOrientation?: number;
  88067. updatable?: boolean;
  88068. }, scene: Scene): Mesh;
  88069. /**
  88070. * Creates a decal mesh.
  88071. * Please consider using the same method from the MeshBuilder class instead.
  88072. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88073. * @param name defines the name of the mesh
  88074. * @param sourceMesh defines the mesh receiving the decal
  88075. * @param position sets the position of the decal in world coordinates
  88076. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88077. * @param size sets the decal scaling
  88078. * @param angle sets the angle to rotate the decal
  88079. * @returns a new Mesh
  88080. */
  88081. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88082. /**
  88083. * Prepare internal position array for software CPU skinning
  88084. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88085. */
  88086. setPositionsForCPUSkinning(): Float32Array;
  88087. /**
  88088. * Prepare internal normal array for software CPU skinning
  88089. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88090. */
  88091. setNormalsForCPUSkinning(): Float32Array;
  88092. /**
  88093. * Updates the vertex buffer by applying transformation from the bones
  88094. * @param skeleton defines the skeleton to apply to current mesh
  88095. * @returns the current mesh
  88096. */
  88097. applySkeleton(skeleton: Skeleton): Mesh;
  88098. /**
  88099. * 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
  88100. * @param meshes defines the list of meshes to scan
  88101. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88102. */
  88103. static MinMax(meshes: AbstractMesh[]): {
  88104. min: Vector3;
  88105. max: Vector3;
  88106. };
  88107. /**
  88108. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88109. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88110. * @returns a vector3
  88111. */
  88112. static Center(meshesOrMinMaxVector: {
  88113. min: Vector3;
  88114. max: Vector3;
  88115. } | AbstractMesh[]): Vector3;
  88116. /**
  88117. * Merge the array of meshes into a single mesh for performance reasons.
  88118. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88119. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88120. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88121. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88122. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88123. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88124. * @returns a new mesh
  88125. */
  88126. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88127. /** @hidden */
  88128. addInstance(instance: InstancedMesh): void;
  88129. /** @hidden */
  88130. removeInstance(instance: InstancedMesh): void;
  88131. }
  88132. }
  88133. declare module BABYLON {
  88134. /**
  88135. * This is the base class of all the camera used in the application.
  88136. * @see http://doc.babylonjs.com/features/cameras
  88137. */
  88138. export class Camera extends Node {
  88139. /** @hidden */
  88140. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88141. /**
  88142. * This is the default projection mode used by the cameras.
  88143. * It helps recreating a feeling of perspective and better appreciate depth.
  88144. * This is the best way to simulate real life cameras.
  88145. */
  88146. static readonly PERSPECTIVE_CAMERA: number;
  88147. /**
  88148. * This helps creating camera with an orthographic mode.
  88149. * 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.
  88150. */
  88151. static readonly ORTHOGRAPHIC_CAMERA: number;
  88152. /**
  88153. * This is the default FOV mode for perspective cameras.
  88154. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88155. */
  88156. static readonly FOVMODE_VERTICAL_FIXED: number;
  88157. /**
  88158. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88159. */
  88160. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88161. /**
  88162. * This specifies ther is no need for a camera rig.
  88163. * Basically only one eye is rendered corresponding to the camera.
  88164. */
  88165. static readonly RIG_MODE_NONE: number;
  88166. /**
  88167. * Simulates a camera Rig with one blue eye and one red eye.
  88168. * This can be use with 3d blue and red glasses.
  88169. */
  88170. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88171. /**
  88172. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88173. */
  88174. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88175. /**
  88176. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88177. */
  88178. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88179. /**
  88180. * Defines that both eyes of the camera will be rendered over under each other.
  88181. */
  88182. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88183. /**
  88184. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88185. */
  88186. static readonly RIG_MODE_VR: number;
  88187. /**
  88188. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88189. */
  88190. static readonly RIG_MODE_WEBVR: number;
  88191. /**
  88192. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88193. */
  88194. static readonly RIG_MODE_CUSTOM: number;
  88195. /**
  88196. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88197. */
  88198. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88199. /**
  88200. * Define the input manager associated with the camera.
  88201. */
  88202. inputs: CameraInputsManager<Camera>;
  88203. /** @hidden */
  88204. _position: Vector3;
  88205. /**
  88206. * Define the current local position of the camera in the scene
  88207. */
  88208. position: Vector3;
  88209. /**
  88210. * The vector the camera should consider as up.
  88211. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88212. */
  88213. upVector: Vector3;
  88214. /**
  88215. * Define the current limit on the left side for an orthographic camera
  88216. * In scene unit
  88217. */
  88218. orthoLeft: Nullable<number>;
  88219. /**
  88220. * Define the current limit on the right side for an orthographic camera
  88221. * In scene unit
  88222. */
  88223. orthoRight: Nullable<number>;
  88224. /**
  88225. * Define the current limit on the bottom side for an orthographic camera
  88226. * In scene unit
  88227. */
  88228. orthoBottom: Nullable<number>;
  88229. /**
  88230. * Define the current limit on the top side for an orthographic camera
  88231. * In scene unit
  88232. */
  88233. orthoTop: Nullable<number>;
  88234. /**
  88235. * Field Of View is set in Radians. (default is 0.8)
  88236. */
  88237. fov: number;
  88238. /**
  88239. * Define the minimum distance the camera can see from.
  88240. * This is important to note that the depth buffer are not infinite and the closer it starts
  88241. * the more your scene might encounter depth fighting issue.
  88242. */
  88243. minZ: number;
  88244. /**
  88245. * Define the maximum distance the camera can see to.
  88246. * This is important to note that the depth buffer are not infinite and the further it end
  88247. * the more your scene might encounter depth fighting issue.
  88248. */
  88249. maxZ: number;
  88250. /**
  88251. * Define the default inertia of the camera.
  88252. * This helps giving a smooth feeling to the camera movement.
  88253. */
  88254. inertia: number;
  88255. /**
  88256. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88257. */
  88258. mode: number;
  88259. /**
  88260. * Define wether the camera is intermediate.
  88261. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88262. */
  88263. isIntermediate: boolean;
  88264. /**
  88265. * Define the viewport of the camera.
  88266. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88267. */
  88268. viewport: Viewport;
  88269. /**
  88270. * Restricts the camera to viewing objects with the same layerMask.
  88271. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88272. */
  88273. layerMask: number;
  88274. /**
  88275. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88276. */
  88277. fovMode: number;
  88278. /**
  88279. * Rig mode of the camera.
  88280. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88281. * This is normally controlled byt the camera themselves as internal use.
  88282. */
  88283. cameraRigMode: number;
  88284. /**
  88285. * Defines the distance between both "eyes" in case of a RIG
  88286. */
  88287. interaxialDistance: number;
  88288. /**
  88289. * Defines if stereoscopic rendering is done side by side or over under.
  88290. */
  88291. isStereoscopicSideBySide: boolean;
  88292. /**
  88293. * 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
  88294. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88295. * else in the scene. (Eg. security camera)
  88296. *
  88297. * 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)
  88298. */
  88299. customRenderTargets: RenderTargetTexture[];
  88300. /**
  88301. * When set, the camera will render to this render target instead of the default canvas
  88302. *
  88303. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88304. */
  88305. outputRenderTarget: Nullable<RenderTargetTexture>;
  88306. /**
  88307. * Observable triggered when the camera view matrix has changed.
  88308. */
  88309. onViewMatrixChangedObservable: Observable<Camera>;
  88310. /**
  88311. * Observable triggered when the camera Projection matrix has changed.
  88312. */
  88313. onProjectionMatrixChangedObservable: Observable<Camera>;
  88314. /**
  88315. * Observable triggered when the inputs have been processed.
  88316. */
  88317. onAfterCheckInputsObservable: Observable<Camera>;
  88318. /**
  88319. * Observable triggered when reset has been called and applied to the camera.
  88320. */
  88321. onRestoreStateObservable: Observable<Camera>;
  88322. /** @hidden */
  88323. _cameraRigParams: any;
  88324. /** @hidden */
  88325. _rigCameras: Camera[];
  88326. /** @hidden */
  88327. _rigPostProcess: Nullable<PostProcess>;
  88328. protected _webvrViewMatrix: Matrix;
  88329. /** @hidden */
  88330. _skipRendering: boolean;
  88331. /** @hidden */
  88332. _projectionMatrix: Matrix;
  88333. /** @hidden */
  88334. _postProcesses: Nullable<PostProcess>[];
  88335. /** @hidden */
  88336. _activeMeshes: SmartArray<AbstractMesh>;
  88337. protected _globalPosition: Vector3;
  88338. /** @hidden */
  88339. _computedViewMatrix: Matrix;
  88340. private _doNotComputeProjectionMatrix;
  88341. private _transformMatrix;
  88342. private _frustumPlanes;
  88343. private _refreshFrustumPlanes;
  88344. private _storedFov;
  88345. private _stateStored;
  88346. /**
  88347. * Instantiates a new camera object.
  88348. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88349. * @see http://doc.babylonjs.com/features/cameras
  88350. * @param name Defines the name of the camera in the scene
  88351. * @param position Defines the position of the camera
  88352. * @param scene Defines the scene the camera belongs too
  88353. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88354. */
  88355. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88356. /**
  88357. * Store current camera state (fov, position, etc..)
  88358. * @returns the camera
  88359. */
  88360. storeState(): Camera;
  88361. /**
  88362. * Restores the camera state values if it has been stored. You must call storeState() first
  88363. */
  88364. protected _restoreStateValues(): boolean;
  88365. /**
  88366. * Restored camera state. You must call storeState() first.
  88367. * @returns true if restored and false otherwise
  88368. */
  88369. restoreState(): boolean;
  88370. /**
  88371. * Gets the class name of the camera.
  88372. * @returns the class name
  88373. */
  88374. getClassName(): string;
  88375. /** @hidden */
  88376. readonly _isCamera: boolean;
  88377. /**
  88378. * Gets a string representation of the camera useful for debug purpose.
  88379. * @param fullDetails Defines that a more verboe level of logging is required
  88380. * @returns the string representation
  88381. */
  88382. toString(fullDetails?: boolean): string;
  88383. /**
  88384. * Gets the current world space position of the camera.
  88385. */
  88386. readonly globalPosition: Vector3;
  88387. /**
  88388. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88389. * @returns the active meshe list
  88390. */
  88391. getActiveMeshes(): SmartArray<AbstractMesh>;
  88392. /**
  88393. * Check wether a mesh is part of the current active mesh list of the camera
  88394. * @param mesh Defines the mesh to check
  88395. * @returns true if active, false otherwise
  88396. */
  88397. isActiveMesh(mesh: Mesh): boolean;
  88398. /**
  88399. * Is this camera ready to be used/rendered
  88400. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88401. * @return true if the camera is ready
  88402. */
  88403. isReady(completeCheck?: boolean): boolean;
  88404. /** @hidden */
  88405. _initCache(): void;
  88406. /** @hidden */
  88407. _updateCache(ignoreParentClass?: boolean): void;
  88408. /** @hidden */
  88409. _isSynchronized(): boolean;
  88410. /** @hidden */
  88411. _isSynchronizedViewMatrix(): boolean;
  88412. /** @hidden */
  88413. _isSynchronizedProjectionMatrix(): boolean;
  88414. /**
  88415. * Attach the input controls to a specific dom element to get the input from.
  88416. * @param element Defines the element the controls should be listened from
  88417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88418. */
  88419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88420. /**
  88421. * Detach the current controls from the specified dom element.
  88422. * @param element Defines the element to stop listening the inputs from
  88423. */
  88424. detachControl(element: HTMLElement): void;
  88425. /**
  88426. * Update the camera state according to the different inputs gathered during the frame.
  88427. */
  88428. update(): void;
  88429. /** @hidden */
  88430. _checkInputs(): void;
  88431. /** @hidden */
  88432. readonly rigCameras: Camera[];
  88433. /**
  88434. * Gets the post process used by the rig cameras
  88435. */
  88436. readonly rigPostProcess: Nullable<PostProcess>;
  88437. /**
  88438. * Internal, gets the first post proces.
  88439. * @returns the first post process to be run on this camera.
  88440. */
  88441. _getFirstPostProcess(): Nullable<PostProcess>;
  88442. private _cascadePostProcessesToRigCams;
  88443. /**
  88444. * Attach a post process to the camera.
  88445. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88446. * @param postProcess The post process to attach to the camera
  88447. * @param insertAt The position of the post process in case several of them are in use in the scene
  88448. * @returns the position the post process has been inserted at
  88449. */
  88450. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88451. /**
  88452. * Detach a post process to the camera.
  88453. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88454. * @param postProcess The post process to detach from the camera
  88455. */
  88456. detachPostProcess(postProcess: PostProcess): void;
  88457. /**
  88458. * Gets the current world matrix of the camera
  88459. */
  88460. getWorldMatrix(): Matrix;
  88461. /** @hidden */
  88462. _getViewMatrix(): Matrix;
  88463. /**
  88464. * Gets the current view matrix of the camera.
  88465. * @param force forces the camera to recompute the matrix without looking at the cached state
  88466. * @returns the view matrix
  88467. */
  88468. getViewMatrix(force?: boolean): Matrix;
  88469. /**
  88470. * Freeze the projection matrix.
  88471. * It will prevent the cache check of the camera projection compute and can speed up perf
  88472. * if no parameter of the camera are meant to change
  88473. * @param projection Defines manually a projection if necessary
  88474. */
  88475. freezeProjectionMatrix(projection?: Matrix): void;
  88476. /**
  88477. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88478. */
  88479. unfreezeProjectionMatrix(): void;
  88480. /**
  88481. * Gets the current projection matrix of the camera.
  88482. * @param force forces the camera to recompute the matrix without looking at the cached state
  88483. * @returns the projection matrix
  88484. */
  88485. getProjectionMatrix(force?: boolean): Matrix;
  88486. /**
  88487. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88488. * @returns a Matrix
  88489. */
  88490. getTransformationMatrix(): Matrix;
  88491. private _updateFrustumPlanes;
  88492. /**
  88493. * Checks if a cullable object (mesh...) is in the camera frustum
  88494. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88495. * @param target The object to check
  88496. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88497. * @returns true if the object is in frustum otherwise false
  88498. */
  88499. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88500. /**
  88501. * Checks if a cullable object (mesh...) is in the camera frustum
  88502. * Unlike isInFrustum this cheks the full bounding box
  88503. * @param target The object to check
  88504. * @returns true if the object is in frustum otherwise false
  88505. */
  88506. isCompletelyInFrustum(target: ICullable): boolean;
  88507. /**
  88508. * Gets a ray in the forward direction from the camera.
  88509. * @param length Defines the length of the ray to create
  88510. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88511. * @param origin Defines the start point of the ray which defaults to the camera position
  88512. * @returns the forward ray
  88513. */
  88514. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88515. /**
  88516. * Releases resources associated with this node.
  88517. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88518. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88519. */
  88520. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88521. /** @hidden */
  88522. _isLeftCamera: boolean;
  88523. /**
  88524. * Gets the left camera of a rig setup in case of Rigged Camera
  88525. */
  88526. readonly isLeftCamera: boolean;
  88527. /** @hidden */
  88528. _isRightCamera: boolean;
  88529. /**
  88530. * Gets the right camera of a rig setup in case of Rigged Camera
  88531. */
  88532. readonly isRightCamera: boolean;
  88533. /**
  88534. * Gets the left camera of a rig setup in case of Rigged Camera
  88535. */
  88536. readonly leftCamera: Nullable<FreeCamera>;
  88537. /**
  88538. * Gets the right camera of a rig setup in case of Rigged Camera
  88539. */
  88540. readonly rightCamera: Nullable<FreeCamera>;
  88541. /**
  88542. * Gets the left camera target of a rig setup in case of Rigged Camera
  88543. * @returns the target position
  88544. */
  88545. getLeftTarget(): Nullable<Vector3>;
  88546. /**
  88547. * Gets the right camera target of a rig setup in case of Rigged Camera
  88548. * @returns the target position
  88549. */
  88550. getRightTarget(): Nullable<Vector3>;
  88551. /**
  88552. * @hidden
  88553. */
  88554. setCameraRigMode(mode: number, rigParams: any): void;
  88555. /** @hidden */
  88556. static _setStereoscopicRigMode(camera: Camera): void;
  88557. /** @hidden */
  88558. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88559. /** @hidden */
  88560. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88561. /** @hidden */
  88562. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88563. /** @hidden */
  88564. _getVRProjectionMatrix(): Matrix;
  88565. protected _updateCameraRotationMatrix(): void;
  88566. protected _updateWebVRCameraRotationMatrix(): void;
  88567. /**
  88568. * This function MUST be overwritten by the different WebVR cameras available.
  88569. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88570. * @hidden
  88571. */
  88572. _getWebVRProjectionMatrix(): Matrix;
  88573. /**
  88574. * This function MUST be overwritten by the different WebVR cameras available.
  88575. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88576. * @hidden
  88577. */
  88578. _getWebVRViewMatrix(): Matrix;
  88579. /** @hidden */
  88580. setCameraRigParameter(name: string, value: any): void;
  88581. /**
  88582. * needs to be overridden by children so sub has required properties to be copied
  88583. * @hidden
  88584. */
  88585. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88586. /**
  88587. * May need to be overridden by children
  88588. * @hidden
  88589. */
  88590. _updateRigCameras(): void;
  88591. /** @hidden */
  88592. _setupInputs(): void;
  88593. /**
  88594. * Serialiaze the camera setup to a json represention
  88595. * @returns the JSON representation
  88596. */
  88597. serialize(): any;
  88598. /**
  88599. * Clones the current camera.
  88600. * @param name The cloned camera name
  88601. * @returns the cloned camera
  88602. */
  88603. clone(name: string): Camera;
  88604. /**
  88605. * Gets the direction of the camera relative to a given local axis.
  88606. * @param localAxis Defines the reference axis to provide a relative direction.
  88607. * @return the direction
  88608. */
  88609. getDirection(localAxis: Vector3): Vector3;
  88610. /**
  88611. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88612. * @param localAxis Defines the reference axis to provide a relative direction.
  88613. * @param result Defines the vector to store the result in
  88614. */
  88615. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88616. /**
  88617. * Gets a camera constructor for a given camera type
  88618. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88619. * @param name The name of the camera the result will be able to instantiate
  88620. * @param scene The scene the result will construct the camera in
  88621. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88622. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88623. * @returns a factory method to construc the camera
  88624. */
  88625. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88626. /**
  88627. * Compute the world matrix of the camera.
  88628. * @returns the camera workd matrix
  88629. */
  88630. computeWorldMatrix(): Matrix;
  88631. /**
  88632. * Parse a JSON and creates the camera from the parsed information
  88633. * @param parsedCamera The JSON to parse
  88634. * @param scene The scene to instantiate the camera in
  88635. * @returns the newly constructed camera
  88636. */
  88637. static Parse(parsedCamera: any, scene: Scene): Camera;
  88638. }
  88639. }
  88640. declare module BABYLON {
  88641. /**
  88642. * Class containing static functions to help procedurally build meshes
  88643. */
  88644. export class DiscBuilder {
  88645. /**
  88646. * Creates a plane polygonal mesh. By default, this is a disc
  88647. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88648. * * 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
  88649. * * 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
  88650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88653. * @param name defines the name of the mesh
  88654. * @param options defines the options used to create the mesh
  88655. * @param scene defines the hosting scene
  88656. * @returns the plane polygonal mesh
  88657. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88658. */
  88659. static CreateDisc(name: string, options: {
  88660. radius?: number;
  88661. tessellation?: number;
  88662. arc?: number;
  88663. updatable?: boolean;
  88664. sideOrientation?: number;
  88665. frontUVs?: Vector4;
  88666. backUVs?: Vector4;
  88667. }, scene?: Nullable<Scene>): Mesh;
  88668. }
  88669. }
  88670. declare module BABYLON {
  88671. /**
  88672. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88673. *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.
  88674. * The SPS is also a particle system. It provides some methods to manage the particles.
  88675. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88676. *
  88677. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  88678. */
  88679. export class SolidParticleSystem implements IDisposable {
  88680. /**
  88681. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88682. * Example : var p = SPS.particles[i];
  88683. */
  88684. particles: SolidParticle[];
  88685. /**
  88686. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88687. */
  88688. nbParticles: number;
  88689. /**
  88690. * If the particles must ever face the camera (default false). Useful for planar particles.
  88691. */
  88692. billboard: boolean;
  88693. /**
  88694. * Recompute normals when adding a shape
  88695. */
  88696. recomputeNormals: boolean;
  88697. /**
  88698. * This a counter ofr your own usage. It's not set by any SPS functions.
  88699. */
  88700. counter: number;
  88701. /**
  88702. * The SPS name. This name is also given to the underlying mesh.
  88703. */
  88704. name: string;
  88705. /**
  88706. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88707. */
  88708. mesh: Mesh;
  88709. /**
  88710. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88711. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  88712. */
  88713. vars: any;
  88714. /**
  88715. * This array is populated when the SPS is set as 'pickable'.
  88716. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88717. * Each element of this array is an object `{idx: int, faceId: int}`.
  88718. * `idx` is the picked particle index in the `SPS.particles` array
  88719. * `faceId` is the picked face index counted within this particle.
  88720. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  88721. */
  88722. pickedParticles: {
  88723. idx: number;
  88724. faceId: number;
  88725. }[];
  88726. /**
  88727. * This array is populated when `enableDepthSort` is set to true.
  88728. * Each element of this array is an instance of the class DepthSortedParticle.
  88729. */
  88730. depthSortedParticles: DepthSortedParticle[];
  88731. /**
  88732. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88733. * @hidden
  88734. */
  88735. _bSphereOnly: boolean;
  88736. /**
  88737. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88738. * @hidden
  88739. */
  88740. _bSphereRadiusFactor: number;
  88741. private _scene;
  88742. private _positions;
  88743. private _indices;
  88744. private _normals;
  88745. private _colors;
  88746. private _uvs;
  88747. private _indices32;
  88748. private _positions32;
  88749. private _normals32;
  88750. private _fixedNormal32;
  88751. private _colors32;
  88752. private _uvs32;
  88753. private _index;
  88754. private _updatable;
  88755. private _pickable;
  88756. private _isVisibilityBoxLocked;
  88757. private _alwaysVisible;
  88758. private _depthSort;
  88759. private _shapeCounter;
  88760. private _copy;
  88761. private _color;
  88762. private _computeParticleColor;
  88763. private _computeParticleTexture;
  88764. private _computeParticleRotation;
  88765. private _computeParticleVertex;
  88766. private _computeBoundingBox;
  88767. private _depthSortParticles;
  88768. private _camera;
  88769. private _mustUnrotateFixedNormals;
  88770. private _particlesIntersect;
  88771. private _needs32Bits;
  88772. /**
  88773. * Creates a SPS (Solid Particle System) object.
  88774. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88775. * @param scene (Scene) is the scene in which the SPS is added.
  88776. * @param options defines the options of the sps e.g.
  88777. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88778. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88779. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88780. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88781. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88782. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88783. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88784. */
  88785. constructor(name: string, scene: Scene, options?: {
  88786. updatable?: boolean;
  88787. isPickable?: boolean;
  88788. enableDepthSort?: boolean;
  88789. particleIntersection?: boolean;
  88790. boundingSphereOnly?: boolean;
  88791. bSphereRadiusFactor?: number;
  88792. });
  88793. /**
  88794. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88795. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88796. * @returns the created mesh
  88797. */
  88798. buildMesh(): Mesh;
  88799. /**
  88800. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88801. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88802. * Thus the particles generated from `digest()` have their property `position` set yet.
  88803. * @param mesh ( Mesh ) is the mesh to be digested
  88804. * @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
  88805. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88806. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88807. * @returns the current SPS
  88808. */
  88809. digest(mesh: Mesh, options?: {
  88810. facetNb?: number;
  88811. number?: number;
  88812. delta?: number;
  88813. }): SolidParticleSystem;
  88814. private _unrotateFixedNormals;
  88815. private _resetCopy;
  88816. private _meshBuilder;
  88817. private _posToShape;
  88818. private _uvsToShapeUV;
  88819. private _addParticle;
  88820. /**
  88821. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88822. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  88823. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88824. * @param nb (positive integer) the number of particles to be created from this model
  88825. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88826. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88827. * @returns the number of shapes in the system
  88828. */
  88829. addShape(mesh: Mesh, nb: number, options?: {
  88830. positionFunction?: any;
  88831. vertexFunction?: any;
  88832. }): number;
  88833. private _rebuildParticle;
  88834. /**
  88835. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88836. * @returns the SPS.
  88837. */
  88838. rebuildMesh(): SolidParticleSystem;
  88839. /**
  88840. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  88841. * This method calls `updateParticle()` for each particle of the SPS.
  88842. * For an animated SPS, it is usually called within the render loop.
  88843. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  88844. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  88845. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  88846. * @returns the SPS.
  88847. */
  88848. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  88849. /**
  88850. * Disposes the SPS.
  88851. */
  88852. dispose(): void;
  88853. /**
  88854. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  88855. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88856. * @returns the SPS.
  88857. */
  88858. refreshVisibleSize(): SolidParticleSystem;
  88859. /**
  88860. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  88861. * @param size the size (float) of the visibility box
  88862. * note : this doesn't lock the SPS mesh bounding box.
  88863. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88864. */
  88865. setVisibilityBox(size: number): void;
  88866. /**
  88867. * Gets whether the SPS as always visible or not
  88868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88869. */
  88870. /**
  88871. * Sets the SPS as always visible or not
  88872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88873. */
  88874. isAlwaysVisible: boolean;
  88875. /**
  88876. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88877. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88878. */
  88879. /**
  88880. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88882. */
  88883. isVisibilityBoxLocked: boolean;
  88884. /**
  88885. * Tells to `setParticles()` to compute the particle rotations or not.
  88886. * Default value : true. The SPS is faster when it's set to false.
  88887. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88888. */
  88889. /**
  88890. * Gets if `setParticles()` computes the particle rotations or not.
  88891. * Default value : true. The SPS is faster when it's set to false.
  88892. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88893. */
  88894. computeParticleRotation: boolean;
  88895. /**
  88896. * Tells to `setParticles()` to compute the particle colors or not.
  88897. * Default value : true. The SPS is faster when it's set to false.
  88898. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88899. */
  88900. /**
  88901. * Gets if `setParticles()` computes the particle colors or not.
  88902. * Default value : true. The SPS is faster when it's set to false.
  88903. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88904. */
  88905. computeParticleColor: boolean;
  88906. /**
  88907. * Gets if `setParticles()` computes the particle textures or not.
  88908. * Default value : true. The SPS is faster when it's set to false.
  88909. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  88910. */
  88911. computeParticleTexture: boolean;
  88912. /**
  88913. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  88914. * Default value : false. The SPS is faster when it's set to false.
  88915. * Note : the particle custom vertex positions aren't stored values.
  88916. */
  88917. /**
  88918. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  88919. * Default value : false. The SPS is faster when it's set to false.
  88920. * Note : the particle custom vertex positions aren't stored values.
  88921. */
  88922. computeParticleVertex: boolean;
  88923. /**
  88924. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  88925. */
  88926. /**
  88927. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  88928. */
  88929. computeBoundingBox: boolean;
  88930. /**
  88931. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  88932. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88933. * Default : `true`
  88934. */
  88935. /**
  88936. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  88937. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88938. * Default : `true`
  88939. */
  88940. depthSortParticles: boolean;
  88941. /**
  88942. * This function does nothing. It may be overwritten to set all the particle first values.
  88943. * The SPS doesn't call this function, you may have to call it by your own.
  88944. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88945. */
  88946. initParticles(): void;
  88947. /**
  88948. * This function does nothing. It may be overwritten to recycle a particle.
  88949. * The SPS doesn't call this function, you may have to call it by your own.
  88950. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88951. * @param particle The particle to recycle
  88952. * @returns the recycled particle
  88953. */
  88954. recycleParticle(particle: SolidParticle): SolidParticle;
  88955. /**
  88956. * Updates a particle : this function should be overwritten by the user.
  88957. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  88958. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88959. * @example : just set a particle position or velocity and recycle conditions
  88960. * @param particle The particle to update
  88961. * @returns the updated particle
  88962. */
  88963. updateParticle(particle: SolidParticle): SolidParticle;
  88964. /**
  88965. * Updates a vertex of a particle : it can be overwritten by the user.
  88966. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  88967. * @param particle the current particle
  88968. * @param vertex the current index of the current particle
  88969. * @param pt the index of the current vertex in the particle shape
  88970. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  88971. * @example : just set a vertex particle position
  88972. * @returns the updated vertex
  88973. */
  88974. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  88975. /**
  88976. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  88977. * This does nothing and may be overwritten by the user.
  88978. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88979. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88980. * @param update the boolean update value actually passed to setParticles()
  88981. */
  88982. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88983. /**
  88984. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  88985. * This will be passed three parameters.
  88986. * This does nothing and may be overwritten by the user.
  88987. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88988. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88989. * @param update the boolean update value actually passed to setParticles()
  88990. */
  88991. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88992. }
  88993. }
  88994. declare module BABYLON {
  88995. /**
  88996. * Represents one particle of a solid particle system.
  88997. */
  88998. export class SolidParticle {
  88999. /**
  89000. * particle global index
  89001. */
  89002. idx: number;
  89003. /**
  89004. * The color of the particle
  89005. */
  89006. color: Nullable<Color4>;
  89007. /**
  89008. * The world space position of the particle.
  89009. */
  89010. position: Vector3;
  89011. /**
  89012. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  89013. */
  89014. rotation: Vector3;
  89015. /**
  89016. * The world space rotation quaternion of the particle.
  89017. */
  89018. rotationQuaternion: Nullable<Quaternion>;
  89019. /**
  89020. * The scaling of the particle.
  89021. */
  89022. scaling: Vector3;
  89023. /**
  89024. * The uvs of the particle.
  89025. */
  89026. uvs: Vector4;
  89027. /**
  89028. * The current speed of the particle.
  89029. */
  89030. velocity: Vector3;
  89031. /**
  89032. * The pivot point in the particle local space.
  89033. */
  89034. pivot: Vector3;
  89035. /**
  89036. * Must the particle be translated from its pivot point in its local space ?
  89037. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89038. * Default : false
  89039. */
  89040. translateFromPivot: boolean;
  89041. /**
  89042. * Is the particle active or not ?
  89043. */
  89044. alive: boolean;
  89045. /**
  89046. * Is the particle visible or not ?
  89047. */
  89048. isVisible: boolean;
  89049. /**
  89050. * Index of this particle in the global "positions" array (Internal use)
  89051. * @hidden
  89052. */
  89053. _pos: number;
  89054. /**
  89055. * @hidden Index of this particle in the global "indices" array (Internal use)
  89056. */
  89057. _ind: number;
  89058. /**
  89059. * @hidden ModelShape of this particle (Internal use)
  89060. */
  89061. _model: ModelShape;
  89062. /**
  89063. * ModelShape id of this particle
  89064. */
  89065. shapeId: number;
  89066. /**
  89067. * Index of the particle in its shape id (Internal use)
  89068. */
  89069. idxInShape: number;
  89070. /**
  89071. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89072. */
  89073. _modelBoundingInfo: BoundingInfo;
  89074. /**
  89075. * @hidden Particle BoundingInfo object (Internal use)
  89076. */
  89077. _boundingInfo: BoundingInfo;
  89078. /**
  89079. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89080. */
  89081. _sps: SolidParticleSystem;
  89082. /**
  89083. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89084. */
  89085. _stillInvisible: boolean;
  89086. /**
  89087. * @hidden Last computed particle rotation matrix
  89088. */
  89089. _rotationMatrix: number[];
  89090. /**
  89091. * Parent particle Id, if any.
  89092. * Default null.
  89093. */
  89094. parentId: Nullable<number>;
  89095. /**
  89096. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89097. * The possible values are :
  89098. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89099. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89100. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89101. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89102. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89103. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89104. * */
  89105. cullingStrategy: number;
  89106. /**
  89107. * @hidden Internal global position in the SPS.
  89108. */
  89109. _globalPosition: Vector3;
  89110. /**
  89111. * Creates a Solid Particle object.
  89112. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89113. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89114. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89115. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89116. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89117. * @param shapeId (integer) is the model shape identifier in the SPS.
  89118. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89119. * @param sps defines the sps it is associated to
  89120. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89121. */
  89122. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89123. /**
  89124. * Legacy support, changed scale to scaling
  89125. */
  89126. /**
  89127. * Legacy support, changed scale to scaling
  89128. */
  89129. scale: Vector3;
  89130. /**
  89131. * Legacy support, changed quaternion to rotationQuaternion
  89132. */
  89133. /**
  89134. * Legacy support, changed quaternion to rotationQuaternion
  89135. */
  89136. quaternion: Nullable<Quaternion>;
  89137. /**
  89138. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89139. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89140. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89141. * @returns true if it intersects
  89142. */
  89143. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89144. /**
  89145. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89146. * A particle is in the frustum if its bounding box intersects the frustum
  89147. * @param frustumPlanes defines the frustum to test
  89148. * @returns true if the particle is in the frustum planes
  89149. */
  89150. isInFrustum(frustumPlanes: Plane[]): boolean;
  89151. /**
  89152. * get the rotation matrix of the particle
  89153. * @hidden
  89154. */
  89155. getRotationMatrix(m: Matrix): void;
  89156. }
  89157. /**
  89158. * Represents the shape of the model used by one particle of a solid particle system.
  89159. * SPS internal tool, don't use it manually.
  89160. */
  89161. export class ModelShape {
  89162. /**
  89163. * The shape id
  89164. * @hidden
  89165. */
  89166. shapeID: number;
  89167. /**
  89168. * flat array of model positions (internal use)
  89169. * @hidden
  89170. */
  89171. _shape: Vector3[];
  89172. /**
  89173. * flat array of model UVs (internal use)
  89174. * @hidden
  89175. */
  89176. _shapeUV: number[];
  89177. /**
  89178. * length of the shape in the model indices array (internal use)
  89179. * @hidden
  89180. */
  89181. _indicesLength: number;
  89182. /**
  89183. * Custom position function (internal use)
  89184. * @hidden
  89185. */
  89186. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89187. /**
  89188. * Custom vertex function (internal use)
  89189. * @hidden
  89190. */
  89191. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89192. /**
  89193. * 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.
  89194. * SPS internal tool, don't use it manually.
  89195. * @hidden
  89196. */
  89197. 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>);
  89198. }
  89199. /**
  89200. * Represents a Depth Sorted Particle in the solid particle system.
  89201. */
  89202. export class DepthSortedParticle {
  89203. /**
  89204. * Index of the particle in the "indices" array
  89205. */
  89206. ind: number;
  89207. /**
  89208. * Length of the particle shape in the "indices" array
  89209. */
  89210. indicesLength: number;
  89211. /**
  89212. * Squared distance from the particle to the camera
  89213. */
  89214. sqDistance: number;
  89215. }
  89216. }
  89217. declare module BABYLON {
  89218. /**
  89219. * @hidden
  89220. */
  89221. export class _MeshCollisionData {
  89222. _checkCollisions: boolean;
  89223. _collisionMask: number;
  89224. _collisionGroup: number;
  89225. _collider: Nullable<Collider>;
  89226. _oldPositionForCollisions: Vector3;
  89227. _diffPositionForCollisions: Vector3;
  89228. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89229. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89230. }
  89231. }
  89232. declare module BABYLON {
  89233. /** @hidden */
  89234. class _FacetDataStorage {
  89235. facetPositions: Vector3[];
  89236. facetNormals: Vector3[];
  89237. facetPartitioning: number[][];
  89238. facetNb: number;
  89239. partitioningSubdivisions: number;
  89240. partitioningBBoxRatio: number;
  89241. facetDataEnabled: boolean;
  89242. facetParameters: any;
  89243. bbSize: Vector3;
  89244. subDiv: {
  89245. max: number;
  89246. X: number;
  89247. Y: number;
  89248. Z: number;
  89249. };
  89250. facetDepthSort: boolean;
  89251. facetDepthSortEnabled: boolean;
  89252. depthSortedIndices: IndicesArray;
  89253. depthSortedFacets: {
  89254. ind: number;
  89255. sqDistance: number;
  89256. }[];
  89257. facetDepthSortFunction: (f1: {
  89258. ind: number;
  89259. sqDistance: number;
  89260. }, f2: {
  89261. ind: number;
  89262. sqDistance: number;
  89263. }) => number;
  89264. facetDepthSortFrom: Vector3;
  89265. facetDepthSortOrigin: Vector3;
  89266. invertedMatrix: Matrix;
  89267. }
  89268. /**
  89269. * @hidden
  89270. **/
  89271. class _InternalAbstractMeshDataInfo {
  89272. _hasVertexAlpha: boolean;
  89273. _useVertexColors: boolean;
  89274. _numBoneInfluencers: number;
  89275. _applyFog: boolean;
  89276. _receiveShadows: boolean;
  89277. _facetData: _FacetDataStorage;
  89278. _visibility: number;
  89279. _skeleton: Nullable<Skeleton>;
  89280. _layerMask: number;
  89281. _computeBonesUsingShaders: boolean;
  89282. _isActive: boolean;
  89283. _onlyForInstances: boolean;
  89284. _isActiveIntermediate: boolean;
  89285. _onlyForInstancesIntermediate: boolean;
  89286. }
  89287. /**
  89288. * Class used to store all common mesh properties
  89289. */
  89290. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89291. /** No occlusion */
  89292. static OCCLUSION_TYPE_NONE: number;
  89293. /** Occlusion set to optimisitic */
  89294. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89295. /** Occlusion set to strict */
  89296. static OCCLUSION_TYPE_STRICT: number;
  89297. /** Use an accurante occlusion algorithm */
  89298. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89299. /** Use a conservative occlusion algorithm */
  89300. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89301. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89302. * Test order :
  89303. * Is the bounding sphere outside the frustum ?
  89304. * If not, are the bounding box vertices outside the frustum ?
  89305. * It not, then the cullable object is in the frustum.
  89306. */
  89307. static readonly CULLINGSTRATEGY_STANDARD: number;
  89308. /** Culling strategy : Bounding Sphere Only.
  89309. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89310. * It's also less accurate than the standard because some not visible objects can still be selected.
  89311. * Test : is the bounding sphere outside the frustum ?
  89312. * If not, then the cullable object is in the frustum.
  89313. */
  89314. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89315. /** Culling strategy : Optimistic Inclusion.
  89316. * This in an inclusion test first, then the standard exclusion test.
  89317. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89318. * 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.
  89319. * Anyway, it's as accurate as the standard strategy.
  89320. * Test :
  89321. * Is the cullable object bounding sphere center in the frustum ?
  89322. * If not, apply the default culling strategy.
  89323. */
  89324. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89325. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89326. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89327. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89328. * 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.
  89329. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89330. * Test :
  89331. * Is the cullable object bounding sphere center in the frustum ?
  89332. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89333. */
  89334. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89335. /**
  89336. * No billboard
  89337. */
  89338. static readonly BILLBOARDMODE_NONE: number;
  89339. /** Billboard on X axis */
  89340. static readonly BILLBOARDMODE_X: number;
  89341. /** Billboard on Y axis */
  89342. static readonly BILLBOARDMODE_Y: number;
  89343. /** Billboard on Z axis */
  89344. static readonly BILLBOARDMODE_Z: number;
  89345. /** Billboard on all axes */
  89346. static readonly BILLBOARDMODE_ALL: number;
  89347. /** @hidden */
  89348. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89349. /**
  89350. * The culling strategy to use to check whether the mesh must be rendered or not.
  89351. * This value can be changed at any time and will be used on the next render mesh selection.
  89352. * The possible values are :
  89353. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89354. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89355. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89356. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89357. * Please read each static variable documentation to get details about the culling process.
  89358. * */
  89359. cullingStrategy: number;
  89360. /**
  89361. * Gets the number of facets in the mesh
  89362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89363. */
  89364. readonly facetNb: number;
  89365. /**
  89366. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89368. */
  89369. partitioningSubdivisions: number;
  89370. /**
  89371. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89372. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89373. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89374. */
  89375. partitioningBBoxRatio: number;
  89376. /**
  89377. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89378. * Works only for updatable meshes.
  89379. * Doesn't work with multi-materials
  89380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89381. */
  89382. mustDepthSortFacets: boolean;
  89383. /**
  89384. * The location (Vector3) where the facet depth sort must be computed from.
  89385. * By default, the active camera position.
  89386. * Used only when facet depth sort is enabled
  89387. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89388. */
  89389. facetDepthSortFrom: Vector3;
  89390. /**
  89391. * gets a boolean indicating if facetData is enabled
  89392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89393. */
  89394. readonly isFacetDataEnabled: boolean;
  89395. /** @hidden */
  89396. _updateNonUniformScalingState(value: boolean): boolean;
  89397. /**
  89398. * An event triggered when this mesh collides with another one
  89399. */
  89400. onCollideObservable: Observable<AbstractMesh>;
  89401. /** Set a function to call when this mesh collides with another one */
  89402. onCollide: () => void;
  89403. /**
  89404. * An event triggered when the collision's position changes
  89405. */
  89406. onCollisionPositionChangeObservable: Observable<Vector3>;
  89407. /** Set a function to call when the collision's position changes */
  89408. onCollisionPositionChange: () => void;
  89409. /**
  89410. * An event triggered when material is changed
  89411. */
  89412. onMaterialChangedObservable: Observable<AbstractMesh>;
  89413. /**
  89414. * Gets or sets the orientation for POV movement & rotation
  89415. */
  89416. definedFacingForward: boolean;
  89417. /** @hidden */
  89418. _occlusionQuery: Nullable<WebGLQuery>;
  89419. /** @hidden */
  89420. _renderingGroup: Nullable<RenderingGroup>;
  89421. /**
  89422. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89423. */
  89424. /**
  89425. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89426. */
  89427. visibility: number;
  89428. /** Gets or sets the alpha index used to sort transparent meshes
  89429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89430. */
  89431. alphaIndex: number;
  89432. /**
  89433. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89434. */
  89435. isVisible: boolean;
  89436. /**
  89437. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89438. */
  89439. isPickable: boolean;
  89440. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89441. showSubMeshesBoundingBox: boolean;
  89442. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89443. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89444. */
  89445. isBlocker: boolean;
  89446. /**
  89447. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89448. */
  89449. enablePointerMoveEvents: boolean;
  89450. /**
  89451. * Specifies the rendering group id for this mesh (0 by default)
  89452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89453. */
  89454. renderingGroupId: number;
  89455. private _material;
  89456. /** Gets or sets current material */
  89457. material: Nullable<Material>;
  89458. /**
  89459. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89460. * @see http://doc.babylonjs.com/babylon101/shadows
  89461. */
  89462. receiveShadows: boolean;
  89463. /** Defines color to use when rendering outline */
  89464. outlineColor: Color3;
  89465. /** Define width to use when rendering outline */
  89466. outlineWidth: number;
  89467. /** Defines color to use when rendering overlay */
  89468. overlayColor: Color3;
  89469. /** Defines alpha to use when rendering overlay */
  89470. overlayAlpha: number;
  89471. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89472. hasVertexAlpha: boolean;
  89473. /** 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) */
  89474. useVertexColors: boolean;
  89475. /**
  89476. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89477. */
  89478. computeBonesUsingShaders: boolean;
  89479. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89480. numBoneInfluencers: number;
  89481. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89482. applyFog: boolean;
  89483. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89484. useOctreeForRenderingSelection: boolean;
  89485. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89486. useOctreeForPicking: boolean;
  89487. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89488. useOctreeForCollisions: boolean;
  89489. /**
  89490. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89491. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89492. */
  89493. layerMask: number;
  89494. /**
  89495. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89496. */
  89497. alwaysSelectAsActiveMesh: boolean;
  89498. /**
  89499. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89500. */
  89501. doNotSyncBoundingInfo: boolean;
  89502. /**
  89503. * Gets or sets the current action manager
  89504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89505. */
  89506. actionManager: Nullable<AbstractActionManager>;
  89507. private _meshCollisionData;
  89508. /**
  89509. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89511. */
  89512. ellipsoid: Vector3;
  89513. /**
  89514. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89515. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89516. */
  89517. ellipsoidOffset: Vector3;
  89518. /**
  89519. * Gets or sets a collision mask used to mask collisions (default is -1).
  89520. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89521. */
  89522. collisionMask: number;
  89523. /**
  89524. * Gets or sets the current collision group mask (-1 by default).
  89525. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89526. */
  89527. collisionGroup: number;
  89528. /**
  89529. * Defines edge width used when edgesRenderer is enabled
  89530. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89531. */
  89532. edgesWidth: number;
  89533. /**
  89534. * Defines edge color used when edgesRenderer is enabled
  89535. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89536. */
  89537. edgesColor: Color4;
  89538. /** @hidden */
  89539. _edgesRenderer: Nullable<IEdgesRenderer>;
  89540. /** @hidden */
  89541. _masterMesh: Nullable<AbstractMesh>;
  89542. /** @hidden */
  89543. _boundingInfo: Nullable<BoundingInfo>;
  89544. /** @hidden */
  89545. _renderId: number;
  89546. /**
  89547. * Gets or sets the list of subMeshes
  89548. * @see http://doc.babylonjs.com/how_to/multi_materials
  89549. */
  89550. subMeshes: SubMesh[];
  89551. /** @hidden */
  89552. _intersectionsInProgress: AbstractMesh[];
  89553. /** @hidden */
  89554. _unIndexed: boolean;
  89555. /** @hidden */
  89556. _lightSources: Light[];
  89557. /** Gets the list of lights affecting that mesh */
  89558. readonly lightSources: Light[];
  89559. /** @hidden */
  89560. readonly _positions: Nullable<Vector3[]>;
  89561. /** @hidden */
  89562. _waitingData: {
  89563. lods: Nullable<any>;
  89564. actions: Nullable<any>;
  89565. freezeWorldMatrix: Nullable<boolean>;
  89566. };
  89567. /** @hidden */
  89568. _bonesTransformMatrices: Nullable<Float32Array>;
  89569. /** @hidden */
  89570. _transformMatrixTexture: Nullable<RawTexture>;
  89571. /**
  89572. * Gets or sets a skeleton to apply skining transformations
  89573. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89574. */
  89575. skeleton: Nullable<Skeleton>;
  89576. /**
  89577. * An event triggered when the mesh is rebuilt.
  89578. */
  89579. onRebuildObservable: Observable<AbstractMesh>;
  89580. /**
  89581. * Creates a new AbstractMesh
  89582. * @param name defines the name of the mesh
  89583. * @param scene defines the hosting scene
  89584. */
  89585. constructor(name: string, scene?: Nullable<Scene>);
  89586. /**
  89587. * Returns the string "AbstractMesh"
  89588. * @returns "AbstractMesh"
  89589. */
  89590. getClassName(): string;
  89591. /**
  89592. * Gets a string representation of the current mesh
  89593. * @param fullDetails defines a boolean indicating if full details must be included
  89594. * @returns a string representation of the current mesh
  89595. */
  89596. toString(fullDetails?: boolean): string;
  89597. /**
  89598. * @hidden
  89599. */
  89600. protected _getEffectiveParent(): Nullable<Node>;
  89601. /** @hidden */
  89602. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89603. /** @hidden */
  89604. _rebuild(): void;
  89605. /** @hidden */
  89606. _resyncLightSources(): void;
  89607. /** @hidden */
  89608. _resyncLighSource(light: Light): void;
  89609. /** @hidden */
  89610. _unBindEffect(): void;
  89611. /** @hidden */
  89612. _removeLightSource(light: Light): void;
  89613. private _markSubMeshesAsDirty;
  89614. /** @hidden */
  89615. _markSubMeshesAsLightDirty(): void;
  89616. /** @hidden */
  89617. _markSubMeshesAsAttributesDirty(): void;
  89618. /** @hidden */
  89619. _markSubMeshesAsMiscDirty(): void;
  89620. /**
  89621. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89622. */
  89623. scaling: Vector3;
  89624. /**
  89625. * Returns true if the mesh is blocked. Implemented by child classes
  89626. */
  89627. readonly isBlocked: boolean;
  89628. /**
  89629. * Returns the mesh itself by default. Implemented by child classes
  89630. * @param camera defines the camera to use to pick the right LOD level
  89631. * @returns the currentAbstractMesh
  89632. */
  89633. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89634. /**
  89635. * Returns 0 by default. Implemented by child classes
  89636. * @returns an integer
  89637. */
  89638. getTotalVertices(): number;
  89639. /**
  89640. * Returns a positive integer : the total number of indices in this mesh geometry.
  89641. * @returns the numner of indices or zero if the mesh has no geometry.
  89642. */
  89643. getTotalIndices(): number;
  89644. /**
  89645. * Returns null by default. Implemented by child classes
  89646. * @returns null
  89647. */
  89648. getIndices(): Nullable<IndicesArray>;
  89649. /**
  89650. * Returns the array of the requested vertex data kind. Implemented by child classes
  89651. * @param kind defines the vertex data kind to use
  89652. * @returns null
  89653. */
  89654. getVerticesData(kind: string): Nullable<FloatArray>;
  89655. /**
  89656. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89657. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89658. * Note that a new underlying VertexBuffer object is created each call.
  89659. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89660. * @param kind defines vertex data kind:
  89661. * * VertexBuffer.PositionKind
  89662. * * VertexBuffer.UVKind
  89663. * * VertexBuffer.UV2Kind
  89664. * * VertexBuffer.UV3Kind
  89665. * * VertexBuffer.UV4Kind
  89666. * * VertexBuffer.UV5Kind
  89667. * * VertexBuffer.UV6Kind
  89668. * * VertexBuffer.ColorKind
  89669. * * VertexBuffer.MatricesIndicesKind
  89670. * * VertexBuffer.MatricesIndicesExtraKind
  89671. * * VertexBuffer.MatricesWeightsKind
  89672. * * VertexBuffer.MatricesWeightsExtraKind
  89673. * @param data defines the data source
  89674. * @param updatable defines if the data must be flagged as updatable (or static)
  89675. * @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
  89676. * @returns the current mesh
  89677. */
  89678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89679. /**
  89680. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89681. * If the mesh has no geometry, it is simply returned as it is.
  89682. * @param kind defines vertex data kind:
  89683. * * VertexBuffer.PositionKind
  89684. * * VertexBuffer.UVKind
  89685. * * VertexBuffer.UV2Kind
  89686. * * VertexBuffer.UV3Kind
  89687. * * VertexBuffer.UV4Kind
  89688. * * VertexBuffer.UV5Kind
  89689. * * VertexBuffer.UV6Kind
  89690. * * VertexBuffer.ColorKind
  89691. * * VertexBuffer.MatricesIndicesKind
  89692. * * VertexBuffer.MatricesIndicesExtraKind
  89693. * * VertexBuffer.MatricesWeightsKind
  89694. * * VertexBuffer.MatricesWeightsExtraKind
  89695. * @param data defines the data source
  89696. * @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
  89697. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89698. * @returns the current mesh
  89699. */
  89700. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89701. /**
  89702. * Sets the mesh indices,
  89703. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89704. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89705. * @param totalVertices Defines the total number of vertices
  89706. * @returns the current mesh
  89707. */
  89708. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89709. /**
  89710. * Gets a boolean indicating if specific vertex data is present
  89711. * @param kind defines the vertex data kind to use
  89712. * @returns true is data kind is present
  89713. */
  89714. isVerticesDataPresent(kind: string): boolean;
  89715. /**
  89716. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89717. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89718. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89719. * @returns a BoundingInfo
  89720. */
  89721. getBoundingInfo(): BoundingInfo;
  89722. /**
  89723. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89724. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89725. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89726. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89727. * @returns the current mesh
  89728. */
  89729. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89730. /**
  89731. * Overwrite the current bounding info
  89732. * @param boundingInfo defines the new bounding info
  89733. * @returns the current mesh
  89734. */
  89735. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89736. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89737. readonly useBones: boolean;
  89738. /** @hidden */
  89739. _preActivate(): void;
  89740. /** @hidden */
  89741. _preActivateForIntermediateRendering(renderId: number): void;
  89742. /** @hidden */
  89743. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89744. /** @hidden */
  89745. _postActivate(): void;
  89746. /** @hidden */
  89747. _freeze(): void;
  89748. /** @hidden */
  89749. _unFreeze(): void;
  89750. /**
  89751. * Gets the current world matrix
  89752. * @returns a Matrix
  89753. */
  89754. getWorldMatrix(): Matrix;
  89755. /** @hidden */
  89756. _getWorldMatrixDeterminant(): number;
  89757. /**
  89758. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89759. */
  89760. readonly isAnInstance: boolean;
  89761. /**
  89762. * Perform relative position change from the point of view of behind the front of the mesh.
  89763. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89764. * Supports definition of mesh facing forward or backward
  89765. * @param amountRight defines the distance on the right axis
  89766. * @param amountUp defines the distance on the up axis
  89767. * @param amountForward defines the distance on the forward axis
  89768. * @returns the current mesh
  89769. */
  89770. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89771. /**
  89772. * Calculate relative position change from the point of view of behind the front of the mesh.
  89773. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89774. * Supports definition of mesh facing forward or backward
  89775. * @param amountRight defines the distance on the right axis
  89776. * @param amountUp defines the distance on the up axis
  89777. * @param amountForward defines the distance on the forward axis
  89778. * @returns the new displacement vector
  89779. */
  89780. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89781. /**
  89782. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89783. * Supports definition of mesh facing forward or backward
  89784. * @param flipBack defines the flip
  89785. * @param twirlClockwise defines the twirl
  89786. * @param tiltRight defines the tilt
  89787. * @returns the current mesh
  89788. */
  89789. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89790. /**
  89791. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89792. * Supports definition of mesh facing forward or backward.
  89793. * @param flipBack defines the flip
  89794. * @param twirlClockwise defines the twirl
  89795. * @param tiltRight defines the tilt
  89796. * @returns the new rotation vector
  89797. */
  89798. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89799. /**
  89800. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89801. * This means the mesh underlying bounding box and sphere are recomputed.
  89802. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89803. * @returns the current mesh
  89804. */
  89805. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89806. /** @hidden */
  89807. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89808. /** @hidden */
  89809. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89810. /** @hidden */
  89811. _updateBoundingInfo(): AbstractMesh;
  89812. /** @hidden */
  89813. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89814. /** @hidden */
  89815. protected _afterComputeWorldMatrix(): void;
  89816. /** @hidden */
  89817. readonly _effectiveMesh: AbstractMesh;
  89818. /**
  89819. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89820. * A mesh is in the frustum if its bounding box intersects the frustum
  89821. * @param frustumPlanes defines the frustum to test
  89822. * @returns true if the mesh is in the frustum planes
  89823. */
  89824. isInFrustum(frustumPlanes: Plane[]): boolean;
  89825. /**
  89826. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89827. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89828. * @param frustumPlanes defines the frustum to test
  89829. * @returns true if the mesh is completely in the frustum planes
  89830. */
  89831. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89832. /**
  89833. * True if the mesh intersects another mesh or a SolidParticle object
  89834. * @param mesh defines a target mesh or SolidParticle to test
  89835. * @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)
  89836. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89837. * @returns true if there is an intersection
  89838. */
  89839. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  89840. /**
  89841. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  89842. * @param point defines the point to test
  89843. * @returns true if there is an intersection
  89844. */
  89845. intersectsPoint(point: Vector3): boolean;
  89846. /**
  89847. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  89848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89849. */
  89850. checkCollisions: boolean;
  89851. /**
  89852. * Gets Collider object used to compute collisions (not physics)
  89853. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89854. */
  89855. readonly collider: Nullable<Collider>;
  89856. /**
  89857. * Move the mesh using collision engine
  89858. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89859. * @param displacement defines the requested displacement vector
  89860. * @returns the current mesh
  89861. */
  89862. moveWithCollisions(displacement: Vector3): AbstractMesh;
  89863. private _onCollisionPositionChange;
  89864. /** @hidden */
  89865. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  89866. /** @hidden */
  89867. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  89868. /** @hidden */
  89869. _checkCollision(collider: Collider): AbstractMesh;
  89870. /** @hidden */
  89871. _generatePointsArray(): boolean;
  89872. /**
  89873. * Checks if the passed Ray intersects with the mesh
  89874. * @param ray defines the ray to use
  89875. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  89876. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89877. * @returns the picking info
  89878. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89879. */
  89880. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  89881. /**
  89882. * Clones the current mesh
  89883. * @param name defines the mesh name
  89884. * @param newParent defines the new mesh parent
  89885. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  89886. * @returns the new mesh
  89887. */
  89888. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89889. /**
  89890. * Disposes all the submeshes of the current meshnp
  89891. * @returns the current mesh
  89892. */
  89893. releaseSubMeshes(): AbstractMesh;
  89894. /**
  89895. * Releases resources associated with this abstract mesh.
  89896. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89897. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89898. */
  89899. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89900. /**
  89901. * Adds the passed mesh as a child to the current mesh
  89902. * @param mesh defines the child mesh
  89903. * @returns the current mesh
  89904. */
  89905. addChild(mesh: AbstractMesh): AbstractMesh;
  89906. /**
  89907. * Removes the passed mesh from the current mesh children list
  89908. * @param mesh defines the child mesh
  89909. * @returns the current mesh
  89910. */
  89911. removeChild(mesh: AbstractMesh): AbstractMesh;
  89912. /** @hidden */
  89913. private _initFacetData;
  89914. /**
  89915. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  89916. * This method can be called within the render loop.
  89917. * 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
  89918. * @returns the current mesh
  89919. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89920. */
  89921. updateFacetData(): AbstractMesh;
  89922. /**
  89923. * Returns the facetLocalNormals array.
  89924. * The normals are expressed in the mesh local spac
  89925. * @returns an array of Vector3
  89926. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89927. */
  89928. getFacetLocalNormals(): Vector3[];
  89929. /**
  89930. * Returns the facetLocalPositions array.
  89931. * The facet positions are expressed in the mesh local space
  89932. * @returns an array of Vector3
  89933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89934. */
  89935. getFacetLocalPositions(): Vector3[];
  89936. /**
  89937. * Returns the facetLocalPartioning array
  89938. * @returns an array of array of numbers
  89939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89940. */
  89941. getFacetLocalPartitioning(): number[][];
  89942. /**
  89943. * Returns the i-th facet position in the world system.
  89944. * This method allocates a new Vector3 per call
  89945. * @param i defines the facet index
  89946. * @returns a new Vector3
  89947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89948. */
  89949. getFacetPosition(i: number): Vector3;
  89950. /**
  89951. * Sets the reference Vector3 with the i-th facet position in the world system
  89952. * @param i defines the facet index
  89953. * @param ref defines the target vector
  89954. * @returns the current mesh
  89955. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89956. */
  89957. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  89958. /**
  89959. * Returns the i-th facet normal in the world system.
  89960. * This method allocates a new Vector3 per call
  89961. * @param i defines the facet index
  89962. * @returns a new Vector3
  89963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89964. */
  89965. getFacetNormal(i: number): Vector3;
  89966. /**
  89967. * Sets the reference Vector3 with the i-th facet normal in the world system
  89968. * @param i defines the facet index
  89969. * @param ref defines the target vector
  89970. * @returns the current mesh
  89971. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89972. */
  89973. getFacetNormalToRef(i: number, ref: Vector3): this;
  89974. /**
  89975. * 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)
  89976. * @param x defines x coordinate
  89977. * @param y defines y coordinate
  89978. * @param z defines z coordinate
  89979. * @returns the array of facet indexes
  89980. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89981. */
  89982. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  89983. /**
  89984. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  89985. * @param projected sets as the (x,y,z) world projection on the facet
  89986. * @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
  89987. * @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
  89988. * @param x defines x coordinate
  89989. * @param y defines y coordinate
  89990. * @param z defines z coordinate
  89991. * @returns the face index if found (or null instead)
  89992. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89993. */
  89994. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89995. /**
  89996. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  89997. * @param projected sets as the (x,y,z) local projection on the facet
  89998. * @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
  89999. * @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
  90000. * @param x defines x coordinate
  90001. * @param y defines y coordinate
  90002. * @param z defines z coordinate
  90003. * @returns the face index if found (or null instead)
  90004. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90005. */
  90006. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  90007. /**
  90008. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  90009. * @returns the parameters
  90010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90011. */
  90012. getFacetDataParameters(): any;
  90013. /**
  90014. * Disables the feature FacetData and frees the related memory
  90015. * @returns the current mesh
  90016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  90017. */
  90018. disableFacetData(): AbstractMesh;
  90019. /**
  90020. * Updates the AbstractMesh indices array
  90021. * @param indices defines the data source
  90022. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90023. * @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)
  90024. * @returns the current mesh
  90025. */
  90026. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90027. /**
  90028. * Creates new normals data for the mesh
  90029. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  90030. * @returns the current mesh
  90031. */
  90032. createNormals(updatable: boolean): AbstractMesh;
  90033. /**
  90034. * Align the mesh with a normal
  90035. * @param normal defines the normal to use
  90036. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90037. * @returns the current mesh
  90038. */
  90039. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90040. /** @hidden */
  90041. _checkOcclusionQuery(): boolean;
  90042. /**
  90043. * Disables the mesh edge rendering mode
  90044. * @returns the currentAbstractMesh
  90045. */
  90046. disableEdgesRendering(): AbstractMesh;
  90047. /**
  90048. * Enables the edge rendering mode on the mesh.
  90049. * This mode makes the mesh edges visible
  90050. * @param epsilon defines the maximal distance between two angles to detect a face
  90051. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90052. * @returns the currentAbstractMesh
  90053. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90054. */
  90055. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90056. }
  90057. }
  90058. declare module BABYLON {
  90059. /**
  90060. * Interface used to define ActionEvent
  90061. */
  90062. export interface IActionEvent {
  90063. /** The mesh or sprite that triggered the action */
  90064. source: any;
  90065. /** The X mouse cursor position at the time of the event */
  90066. pointerX: number;
  90067. /** The Y mouse cursor position at the time of the event */
  90068. pointerY: number;
  90069. /** The mesh that is currently pointed at (can be null) */
  90070. meshUnderPointer: Nullable<AbstractMesh>;
  90071. /** the original (browser) event that triggered the ActionEvent */
  90072. sourceEvent?: any;
  90073. /** additional data for the event */
  90074. additionalData?: any;
  90075. }
  90076. /**
  90077. * ActionEvent is the event being sent when an action is triggered.
  90078. */
  90079. export class ActionEvent implements IActionEvent {
  90080. /** The mesh or sprite that triggered the action */
  90081. source: any;
  90082. /** The X mouse cursor position at the time of the event */
  90083. pointerX: number;
  90084. /** The Y mouse cursor position at the time of the event */
  90085. pointerY: number;
  90086. /** The mesh that is currently pointed at (can be null) */
  90087. meshUnderPointer: Nullable<AbstractMesh>;
  90088. /** the original (browser) event that triggered the ActionEvent */
  90089. sourceEvent?: any;
  90090. /** additional data for the event */
  90091. additionalData?: any;
  90092. /**
  90093. * Creates a new ActionEvent
  90094. * @param source The mesh or sprite that triggered the action
  90095. * @param pointerX The X mouse cursor position at the time of the event
  90096. * @param pointerY The Y mouse cursor position at the time of the event
  90097. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90098. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90099. * @param additionalData additional data for the event
  90100. */
  90101. constructor(
  90102. /** The mesh or sprite that triggered the action */
  90103. source: any,
  90104. /** The X mouse cursor position at the time of the event */
  90105. pointerX: number,
  90106. /** The Y mouse cursor position at the time of the event */
  90107. pointerY: number,
  90108. /** The mesh that is currently pointed at (can be null) */
  90109. meshUnderPointer: Nullable<AbstractMesh>,
  90110. /** the original (browser) event that triggered the ActionEvent */
  90111. sourceEvent?: any,
  90112. /** additional data for the event */
  90113. additionalData?: any);
  90114. /**
  90115. * Helper function to auto-create an ActionEvent from a source mesh.
  90116. * @param source The source mesh that triggered the event
  90117. * @param evt The original (browser) event
  90118. * @param additionalData additional data for the event
  90119. * @returns the new ActionEvent
  90120. */
  90121. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90122. /**
  90123. * Helper function to auto-create an ActionEvent from a source sprite
  90124. * @param source The source sprite that triggered the event
  90125. * @param scene Scene associated with the sprite
  90126. * @param evt The original (browser) event
  90127. * @param additionalData additional data for the event
  90128. * @returns the new ActionEvent
  90129. */
  90130. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90131. /**
  90132. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90133. * @param scene the scene where the event occurred
  90134. * @param evt The original (browser) event
  90135. * @returns the new ActionEvent
  90136. */
  90137. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90138. /**
  90139. * Helper function to auto-create an ActionEvent from a primitive
  90140. * @param prim defines the target primitive
  90141. * @param pointerPos defines the pointer position
  90142. * @param evt The original (browser) event
  90143. * @param additionalData additional data for the event
  90144. * @returns the new ActionEvent
  90145. */
  90146. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90147. }
  90148. }
  90149. declare module BABYLON {
  90150. /**
  90151. * Abstract class used to decouple action Manager from scene and meshes.
  90152. * Do not instantiate.
  90153. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90154. */
  90155. export abstract class AbstractActionManager implements IDisposable {
  90156. /** Gets the list of active triggers */
  90157. static Triggers: {
  90158. [key: string]: number;
  90159. };
  90160. /** Gets the cursor to use when hovering items */
  90161. hoverCursor: string;
  90162. /** Gets the list of actions */
  90163. actions: IAction[];
  90164. /**
  90165. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90166. */
  90167. isRecursive: boolean;
  90168. /**
  90169. * Releases all associated resources
  90170. */
  90171. abstract dispose(): void;
  90172. /**
  90173. * Does this action manager has pointer triggers
  90174. */
  90175. abstract readonly hasPointerTriggers: boolean;
  90176. /**
  90177. * Does this action manager has pick triggers
  90178. */
  90179. abstract readonly hasPickTriggers: boolean;
  90180. /**
  90181. * Process a specific trigger
  90182. * @param trigger defines the trigger to process
  90183. * @param evt defines the event details to be processed
  90184. */
  90185. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90186. /**
  90187. * Does this action manager handles actions of any of the given triggers
  90188. * @param triggers defines the triggers to be tested
  90189. * @return a boolean indicating whether one (or more) of the triggers is handled
  90190. */
  90191. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90192. /**
  90193. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90194. * speed.
  90195. * @param triggerA defines the trigger to be tested
  90196. * @param triggerB defines the trigger to be tested
  90197. * @return a boolean indicating whether one (or more) of the triggers is handled
  90198. */
  90199. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90200. /**
  90201. * Does this action manager handles actions of a given trigger
  90202. * @param trigger defines the trigger to be tested
  90203. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90204. * @return whether the trigger is handled
  90205. */
  90206. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90207. /**
  90208. * Serialize this manager to a JSON object
  90209. * @param name defines the property name to store this manager
  90210. * @returns a JSON representation of this manager
  90211. */
  90212. abstract serialize(name: string): any;
  90213. /**
  90214. * Registers an action to this action manager
  90215. * @param action defines the action to be registered
  90216. * @return the action amended (prepared) after registration
  90217. */
  90218. abstract registerAction(action: IAction): Nullable<IAction>;
  90219. /**
  90220. * Unregisters an action to this action manager
  90221. * @param action defines the action to be unregistered
  90222. * @return a boolean indicating whether the action has been unregistered
  90223. */
  90224. abstract unregisterAction(action: IAction): Boolean;
  90225. /**
  90226. * Does exist one action manager with at least one trigger
  90227. **/
  90228. static readonly HasTriggers: boolean;
  90229. /**
  90230. * Does exist one action manager with at least one pick trigger
  90231. **/
  90232. static readonly HasPickTriggers: boolean;
  90233. /**
  90234. * Does exist one action manager that handles actions of a given trigger
  90235. * @param trigger defines the trigger to be tested
  90236. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90237. **/
  90238. static HasSpecificTrigger(trigger: number): boolean;
  90239. }
  90240. }
  90241. declare module BABYLON {
  90242. /**
  90243. * Defines how a node can be built from a string name.
  90244. */
  90245. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90246. /**
  90247. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90248. */
  90249. export class Node implements IBehaviorAware<Node> {
  90250. /** @hidden */
  90251. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90252. private static _NodeConstructors;
  90253. /**
  90254. * Add a new node constructor
  90255. * @param type defines the type name of the node to construct
  90256. * @param constructorFunc defines the constructor function
  90257. */
  90258. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90259. /**
  90260. * Returns a node constructor based on type name
  90261. * @param type defines the type name
  90262. * @param name defines the new node name
  90263. * @param scene defines the hosting scene
  90264. * @param options defines optional options to transmit to constructors
  90265. * @returns the new constructor or null
  90266. */
  90267. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90268. /**
  90269. * Gets or sets the name of the node
  90270. */
  90271. name: string;
  90272. /**
  90273. * Gets or sets the id of the node
  90274. */
  90275. id: string;
  90276. /**
  90277. * Gets or sets the unique id of the node
  90278. */
  90279. uniqueId: number;
  90280. /**
  90281. * Gets or sets a string used to store user defined state for the node
  90282. */
  90283. state: string;
  90284. /**
  90285. * Gets or sets an object used to store user defined information for the node
  90286. */
  90287. metadata: any;
  90288. /**
  90289. * For internal use only. Please do not use.
  90290. */
  90291. reservedDataStore: any;
  90292. /**
  90293. * List of inspectable custom properties (used by the Inspector)
  90294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90295. */
  90296. inspectableCustomProperties: IInspectable[];
  90297. /**
  90298. * Gets or sets a boolean used to define if the node must be serialized
  90299. */
  90300. doNotSerialize: boolean;
  90301. /** @hidden */
  90302. _isDisposed: boolean;
  90303. /**
  90304. * Gets a list of Animations associated with the node
  90305. */
  90306. animations: Animation[];
  90307. protected _ranges: {
  90308. [name: string]: Nullable<AnimationRange>;
  90309. };
  90310. /**
  90311. * Callback raised when the node is ready to be used
  90312. */
  90313. onReady: Nullable<(node: Node) => void>;
  90314. private _isEnabled;
  90315. private _isParentEnabled;
  90316. private _isReady;
  90317. /** @hidden */
  90318. _currentRenderId: number;
  90319. private _parentUpdateId;
  90320. /** @hidden */
  90321. _childUpdateId: number;
  90322. /** @hidden */
  90323. _waitingParentId: Nullable<string>;
  90324. /** @hidden */
  90325. _scene: Scene;
  90326. /** @hidden */
  90327. _cache: any;
  90328. private _parentNode;
  90329. private _children;
  90330. /** @hidden */
  90331. _worldMatrix: Matrix;
  90332. /** @hidden */
  90333. _worldMatrixDeterminant: number;
  90334. /** @hidden */
  90335. _worldMatrixDeterminantIsDirty: boolean;
  90336. /** @hidden */
  90337. private _sceneRootNodesIndex;
  90338. /**
  90339. * Gets a boolean indicating if the node has been disposed
  90340. * @returns true if the node was disposed
  90341. */
  90342. isDisposed(): boolean;
  90343. /**
  90344. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90345. * @see https://doc.babylonjs.com/how_to/parenting
  90346. */
  90347. parent: Nullable<Node>;
  90348. private addToSceneRootNodes;
  90349. private removeFromSceneRootNodes;
  90350. private _animationPropertiesOverride;
  90351. /**
  90352. * Gets or sets the animation properties override
  90353. */
  90354. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90355. /**
  90356. * Gets a string idenfifying the name of the class
  90357. * @returns "Node" string
  90358. */
  90359. getClassName(): string;
  90360. /** @hidden */
  90361. readonly _isNode: boolean;
  90362. /**
  90363. * An event triggered when the mesh is disposed
  90364. */
  90365. onDisposeObservable: Observable<Node>;
  90366. private _onDisposeObserver;
  90367. /**
  90368. * Sets a callback that will be raised when the node will be disposed
  90369. */
  90370. onDispose: () => void;
  90371. /**
  90372. * Creates a new Node
  90373. * @param name the name and id to be given to this node
  90374. * @param scene the scene this node will be added to
  90375. * @param addToRootNodes the node will be added to scene.rootNodes
  90376. */
  90377. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90378. /**
  90379. * Gets the scene of the node
  90380. * @returns a scene
  90381. */
  90382. getScene(): Scene;
  90383. /**
  90384. * Gets the engine of the node
  90385. * @returns a Engine
  90386. */
  90387. getEngine(): Engine;
  90388. private _behaviors;
  90389. /**
  90390. * Attach a behavior to the node
  90391. * @see http://doc.babylonjs.com/features/behaviour
  90392. * @param behavior defines the behavior to attach
  90393. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90394. * @returns the current Node
  90395. */
  90396. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90397. /**
  90398. * Remove an attached behavior
  90399. * @see http://doc.babylonjs.com/features/behaviour
  90400. * @param behavior defines the behavior to attach
  90401. * @returns the current Node
  90402. */
  90403. removeBehavior(behavior: Behavior<Node>): Node;
  90404. /**
  90405. * Gets the list of attached behaviors
  90406. * @see http://doc.babylonjs.com/features/behaviour
  90407. */
  90408. readonly behaviors: Behavior<Node>[];
  90409. /**
  90410. * Gets an attached behavior by name
  90411. * @param name defines the name of the behavior to look for
  90412. * @see http://doc.babylonjs.com/features/behaviour
  90413. * @returns null if behavior was not found else the requested behavior
  90414. */
  90415. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90416. /**
  90417. * Returns the latest update of the World matrix
  90418. * @returns a Matrix
  90419. */
  90420. getWorldMatrix(): Matrix;
  90421. /** @hidden */
  90422. _getWorldMatrixDeterminant(): number;
  90423. /**
  90424. * Returns directly the latest state of the mesh World matrix.
  90425. * A Matrix is returned.
  90426. */
  90427. readonly worldMatrixFromCache: Matrix;
  90428. /** @hidden */
  90429. _initCache(): void;
  90430. /** @hidden */
  90431. updateCache(force?: boolean): void;
  90432. /** @hidden */
  90433. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90434. /** @hidden */
  90435. _updateCache(ignoreParentClass?: boolean): void;
  90436. /** @hidden */
  90437. _isSynchronized(): boolean;
  90438. /** @hidden */
  90439. _markSyncedWithParent(): void;
  90440. /** @hidden */
  90441. isSynchronizedWithParent(): boolean;
  90442. /** @hidden */
  90443. isSynchronized(): boolean;
  90444. /**
  90445. * Is this node ready to be used/rendered
  90446. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90447. * @return true if the node is ready
  90448. */
  90449. isReady(completeCheck?: boolean): boolean;
  90450. /**
  90451. * Is this node enabled?
  90452. * 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
  90453. * @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
  90454. * @return whether this node (and its parent) is enabled
  90455. */
  90456. isEnabled(checkAncestors?: boolean): boolean;
  90457. /** @hidden */
  90458. protected _syncParentEnabledState(): void;
  90459. /**
  90460. * Set the enabled state of this node
  90461. * @param value defines the new enabled state
  90462. */
  90463. setEnabled(value: boolean): void;
  90464. /**
  90465. * Is this node a descendant of the given node?
  90466. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90467. * @param ancestor defines the parent node to inspect
  90468. * @returns a boolean indicating if this node is a descendant of the given node
  90469. */
  90470. isDescendantOf(ancestor: Node): boolean;
  90471. /** @hidden */
  90472. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90473. /**
  90474. * Will return all nodes that have this node as ascendant
  90475. * @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
  90476. * @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
  90477. * @return all children nodes of all types
  90478. */
  90479. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90480. /**
  90481. * Get all child-meshes of this node
  90482. * @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)
  90483. * @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
  90484. * @returns an array of AbstractMesh
  90485. */
  90486. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90487. /**
  90488. * Get all direct children of this node
  90489. * @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
  90490. * @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)
  90491. * @returns an array of Node
  90492. */
  90493. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90494. /** @hidden */
  90495. _setReady(state: boolean): void;
  90496. /**
  90497. * Get an animation by name
  90498. * @param name defines the name of the animation to look for
  90499. * @returns null if not found else the requested animation
  90500. */
  90501. getAnimationByName(name: string): Nullable<Animation>;
  90502. /**
  90503. * Creates an animation range for this node
  90504. * @param name defines the name of the range
  90505. * @param from defines the starting key
  90506. * @param to defines the end key
  90507. */
  90508. createAnimationRange(name: string, from: number, to: number): void;
  90509. /**
  90510. * Delete a specific animation range
  90511. * @param name defines the name of the range to delete
  90512. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90513. */
  90514. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90515. /**
  90516. * Get an animation range by name
  90517. * @param name defines the name of the animation range to look for
  90518. * @returns null if not found else the requested animation range
  90519. */
  90520. getAnimationRange(name: string): Nullable<AnimationRange>;
  90521. /**
  90522. * Gets the list of all animation ranges defined on this node
  90523. * @returns an array
  90524. */
  90525. getAnimationRanges(): Nullable<AnimationRange>[];
  90526. /**
  90527. * Will start the animation sequence
  90528. * @param name defines the range frames for animation sequence
  90529. * @param loop defines if the animation should loop (false by default)
  90530. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90531. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90532. * @returns the object created for this animation. If range does not exist, it will return null
  90533. */
  90534. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90535. /**
  90536. * Serialize animation ranges into a JSON compatible object
  90537. * @returns serialization object
  90538. */
  90539. serializeAnimationRanges(): any;
  90540. /**
  90541. * Computes the world matrix of the node
  90542. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90543. * @returns the world matrix
  90544. */
  90545. computeWorldMatrix(force?: boolean): Matrix;
  90546. /**
  90547. * Releases resources associated with this node.
  90548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90550. */
  90551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90552. /**
  90553. * Parse animation range data from a serialization object and store them into a given node
  90554. * @param node defines where to store the animation ranges
  90555. * @param parsedNode defines the serialization object to read data from
  90556. * @param scene defines the hosting scene
  90557. */
  90558. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90559. /**
  90560. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90561. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90562. * @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
  90563. * @returns the new bounding vectors
  90564. */
  90565. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90566. min: Vector3;
  90567. max: Vector3;
  90568. };
  90569. }
  90570. }
  90571. declare module BABYLON {
  90572. /**
  90573. * @hidden
  90574. */
  90575. export class _IAnimationState {
  90576. key: number;
  90577. repeatCount: number;
  90578. workValue?: any;
  90579. loopMode?: number;
  90580. offsetValue?: any;
  90581. highLimitValue?: any;
  90582. }
  90583. /**
  90584. * Class used to store any kind of animation
  90585. */
  90586. export class Animation {
  90587. /**Name of the animation */
  90588. name: string;
  90589. /**Property to animate */
  90590. targetProperty: string;
  90591. /**The frames per second of the animation */
  90592. framePerSecond: number;
  90593. /**The data type of the animation */
  90594. dataType: number;
  90595. /**The loop mode of the animation */
  90596. loopMode?: number | undefined;
  90597. /**Specifies if blending should be enabled */
  90598. enableBlending?: boolean | undefined;
  90599. /**
  90600. * Use matrix interpolation instead of using direct key value when animating matrices
  90601. */
  90602. static AllowMatricesInterpolation: boolean;
  90603. /**
  90604. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90605. */
  90606. static AllowMatrixDecomposeForInterpolation: boolean;
  90607. /**
  90608. * Stores the key frames of the animation
  90609. */
  90610. private _keys;
  90611. /**
  90612. * Stores the easing function of the animation
  90613. */
  90614. private _easingFunction;
  90615. /**
  90616. * @hidden Internal use only
  90617. */
  90618. _runtimeAnimations: RuntimeAnimation[];
  90619. /**
  90620. * The set of event that will be linked to this animation
  90621. */
  90622. private _events;
  90623. /**
  90624. * Stores an array of target property paths
  90625. */
  90626. targetPropertyPath: string[];
  90627. /**
  90628. * Stores the blending speed of the animation
  90629. */
  90630. blendingSpeed: number;
  90631. /**
  90632. * Stores the animation ranges for the animation
  90633. */
  90634. private _ranges;
  90635. /**
  90636. * @hidden Internal use
  90637. */
  90638. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90639. /**
  90640. * Sets up an animation
  90641. * @param property The property to animate
  90642. * @param animationType The animation type to apply
  90643. * @param framePerSecond The frames per second of the animation
  90644. * @param easingFunction The easing function used in the animation
  90645. * @returns The created animation
  90646. */
  90647. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90648. /**
  90649. * Create and start an animation on a node
  90650. * @param name defines the name of the global animation that will be run on all nodes
  90651. * @param node defines the root node where the animation will take place
  90652. * @param targetProperty defines property to animate
  90653. * @param framePerSecond defines the number of frame per second yo use
  90654. * @param totalFrame defines the number of frames in total
  90655. * @param from defines the initial value
  90656. * @param to defines the final value
  90657. * @param loopMode defines which loop mode you want to use (off by default)
  90658. * @param easingFunction defines the easing function to use (linear by default)
  90659. * @param onAnimationEnd defines the callback to call when animation end
  90660. * @returns the animatable created for this animation
  90661. */
  90662. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90663. /**
  90664. * Create and start an animation on a node and its descendants
  90665. * @param name defines the name of the global animation that will be run on all nodes
  90666. * @param node defines the root node where the animation will take place
  90667. * @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
  90668. * @param targetProperty defines property to animate
  90669. * @param framePerSecond defines the number of frame per second to use
  90670. * @param totalFrame defines the number of frames in total
  90671. * @param from defines the initial value
  90672. * @param to defines the final value
  90673. * @param loopMode defines which loop mode you want to use (off by default)
  90674. * @param easingFunction defines the easing function to use (linear by default)
  90675. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90676. * @returns the list of animatables created for all nodes
  90677. * @example https://www.babylonjs-playground.com/#MH0VLI
  90678. */
  90679. 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[]>;
  90680. /**
  90681. * Creates a new animation, merges it with the existing animations and starts it
  90682. * @param name Name of the animation
  90683. * @param node Node which contains the scene that begins the animations
  90684. * @param targetProperty Specifies which property to animate
  90685. * @param framePerSecond The frames per second of the animation
  90686. * @param totalFrame The total number of frames
  90687. * @param from The frame at the beginning of the animation
  90688. * @param to The frame at the end of the animation
  90689. * @param loopMode Specifies the loop mode of the animation
  90690. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90691. * @param onAnimationEnd Callback to run once the animation is complete
  90692. * @returns Nullable animation
  90693. */
  90694. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90695. /**
  90696. * Transition property of an host to the target Value
  90697. * @param property The property to transition
  90698. * @param targetValue The target Value of the property
  90699. * @param host The object where the property to animate belongs
  90700. * @param scene Scene used to run the animation
  90701. * @param frameRate Framerate (in frame/s) to use
  90702. * @param transition The transition type we want to use
  90703. * @param duration The duration of the animation, in milliseconds
  90704. * @param onAnimationEnd Callback trigger at the end of the animation
  90705. * @returns Nullable animation
  90706. */
  90707. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90708. /**
  90709. * Return the array of runtime animations currently using this animation
  90710. */
  90711. readonly runtimeAnimations: RuntimeAnimation[];
  90712. /**
  90713. * Specifies if any of the runtime animations are currently running
  90714. */
  90715. readonly hasRunningRuntimeAnimations: boolean;
  90716. /**
  90717. * Initializes the animation
  90718. * @param name Name of the animation
  90719. * @param targetProperty Property to animate
  90720. * @param framePerSecond The frames per second of the animation
  90721. * @param dataType The data type of the animation
  90722. * @param loopMode The loop mode of the animation
  90723. * @param enableBlending Specifies if blending should be enabled
  90724. */
  90725. constructor(
  90726. /**Name of the animation */
  90727. name: string,
  90728. /**Property to animate */
  90729. targetProperty: string,
  90730. /**The frames per second of the animation */
  90731. framePerSecond: number,
  90732. /**The data type of the animation */
  90733. dataType: number,
  90734. /**The loop mode of the animation */
  90735. loopMode?: number | undefined,
  90736. /**Specifies if blending should be enabled */
  90737. enableBlending?: boolean | undefined);
  90738. /**
  90739. * Converts the animation to a string
  90740. * @param fullDetails support for multiple levels of logging within scene loading
  90741. * @returns String form of the animation
  90742. */
  90743. toString(fullDetails?: boolean): string;
  90744. /**
  90745. * Add an event to this animation
  90746. * @param event Event to add
  90747. */
  90748. addEvent(event: AnimationEvent): void;
  90749. /**
  90750. * Remove all events found at the given frame
  90751. * @param frame The frame to remove events from
  90752. */
  90753. removeEvents(frame: number): void;
  90754. /**
  90755. * Retrieves all the events from the animation
  90756. * @returns Events from the animation
  90757. */
  90758. getEvents(): AnimationEvent[];
  90759. /**
  90760. * Creates an animation range
  90761. * @param name Name of the animation range
  90762. * @param from Starting frame of the animation range
  90763. * @param to Ending frame of the animation
  90764. */
  90765. createRange(name: string, from: number, to: number): void;
  90766. /**
  90767. * Deletes an animation range by name
  90768. * @param name Name of the animation range to delete
  90769. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90770. */
  90771. deleteRange(name: string, deleteFrames?: boolean): void;
  90772. /**
  90773. * Gets the animation range by name, or null if not defined
  90774. * @param name Name of the animation range
  90775. * @returns Nullable animation range
  90776. */
  90777. getRange(name: string): Nullable<AnimationRange>;
  90778. /**
  90779. * Gets the key frames from the animation
  90780. * @returns The key frames of the animation
  90781. */
  90782. getKeys(): Array<IAnimationKey>;
  90783. /**
  90784. * Gets the highest frame rate of the animation
  90785. * @returns Highest frame rate of the animation
  90786. */
  90787. getHighestFrame(): number;
  90788. /**
  90789. * Gets the easing function of the animation
  90790. * @returns Easing function of the animation
  90791. */
  90792. getEasingFunction(): IEasingFunction;
  90793. /**
  90794. * Sets the easing function of the animation
  90795. * @param easingFunction A custom mathematical formula for animation
  90796. */
  90797. setEasingFunction(easingFunction: EasingFunction): void;
  90798. /**
  90799. * Interpolates a scalar linearly
  90800. * @param startValue Start value of the animation curve
  90801. * @param endValue End value of the animation curve
  90802. * @param gradient Scalar amount to interpolate
  90803. * @returns Interpolated scalar value
  90804. */
  90805. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90806. /**
  90807. * Interpolates a scalar cubically
  90808. * @param startValue Start value of the animation curve
  90809. * @param outTangent End tangent of the animation
  90810. * @param endValue End value of the animation curve
  90811. * @param inTangent Start tangent of the animation curve
  90812. * @param gradient Scalar amount to interpolate
  90813. * @returns Interpolated scalar value
  90814. */
  90815. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90816. /**
  90817. * Interpolates a quaternion using a spherical linear interpolation
  90818. * @param startValue Start value of the animation curve
  90819. * @param endValue End value of the animation curve
  90820. * @param gradient Scalar amount to interpolate
  90821. * @returns Interpolated quaternion value
  90822. */
  90823. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90824. /**
  90825. * Interpolates a quaternion cubically
  90826. * @param startValue Start value of the animation curve
  90827. * @param outTangent End tangent of the animation curve
  90828. * @param endValue End value of the animation curve
  90829. * @param inTangent Start tangent of the animation curve
  90830. * @param gradient Scalar amount to interpolate
  90831. * @returns Interpolated quaternion value
  90832. */
  90833. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90834. /**
  90835. * Interpolates a Vector3 linearl
  90836. * @param startValue Start value of the animation curve
  90837. * @param endValue End value of the animation curve
  90838. * @param gradient Scalar amount to interpolate
  90839. * @returns Interpolated scalar value
  90840. */
  90841. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  90842. /**
  90843. * Interpolates a Vector3 cubically
  90844. * @param startValue Start value of the animation curve
  90845. * @param outTangent End tangent of the animation
  90846. * @param endValue End value of the animation curve
  90847. * @param inTangent Start tangent of the animation curve
  90848. * @param gradient Scalar amount to interpolate
  90849. * @returns InterpolatedVector3 value
  90850. */
  90851. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  90852. /**
  90853. * Interpolates a Vector2 linearly
  90854. * @param startValue Start value of the animation curve
  90855. * @param endValue End value of the animation curve
  90856. * @param gradient Scalar amount to interpolate
  90857. * @returns Interpolated Vector2 value
  90858. */
  90859. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  90860. /**
  90861. * Interpolates a Vector2 cubically
  90862. * @param startValue Start value of the animation curve
  90863. * @param outTangent End tangent of the animation
  90864. * @param endValue End value of the animation curve
  90865. * @param inTangent Start tangent of the animation curve
  90866. * @param gradient Scalar amount to interpolate
  90867. * @returns Interpolated Vector2 value
  90868. */
  90869. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  90870. /**
  90871. * Interpolates a size linearly
  90872. * @param startValue Start value of the animation curve
  90873. * @param endValue End value of the animation curve
  90874. * @param gradient Scalar amount to interpolate
  90875. * @returns Interpolated Size value
  90876. */
  90877. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  90878. /**
  90879. * Interpolates a Color3 linearly
  90880. * @param startValue Start value of the animation curve
  90881. * @param endValue End value of the animation curve
  90882. * @param gradient Scalar amount to interpolate
  90883. * @returns Interpolated Color3 value
  90884. */
  90885. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  90886. /**
  90887. * @hidden Internal use only
  90888. */
  90889. _getKeyValue(value: any): any;
  90890. /**
  90891. * @hidden Internal use only
  90892. */
  90893. _interpolate(currentFrame: number, state: _IAnimationState): any;
  90894. /**
  90895. * Defines the function to use to interpolate matrices
  90896. * @param startValue defines the start matrix
  90897. * @param endValue defines the end matrix
  90898. * @param gradient defines the gradient between both matrices
  90899. * @param result defines an optional target matrix where to store the interpolation
  90900. * @returns the interpolated matrix
  90901. */
  90902. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  90903. /**
  90904. * Makes a copy of the animation
  90905. * @returns Cloned animation
  90906. */
  90907. clone(): Animation;
  90908. /**
  90909. * Sets the key frames of the animation
  90910. * @param values The animation key frames to set
  90911. */
  90912. setKeys(values: Array<IAnimationKey>): void;
  90913. /**
  90914. * Serializes the animation to an object
  90915. * @returns Serialized object
  90916. */
  90917. serialize(): any;
  90918. /**
  90919. * Float animation type
  90920. */
  90921. private static _ANIMATIONTYPE_FLOAT;
  90922. /**
  90923. * Vector3 animation type
  90924. */
  90925. private static _ANIMATIONTYPE_VECTOR3;
  90926. /**
  90927. * Quaternion animation type
  90928. */
  90929. private static _ANIMATIONTYPE_QUATERNION;
  90930. /**
  90931. * Matrix animation type
  90932. */
  90933. private static _ANIMATIONTYPE_MATRIX;
  90934. /**
  90935. * Color3 animation type
  90936. */
  90937. private static _ANIMATIONTYPE_COLOR3;
  90938. /**
  90939. * Vector2 animation type
  90940. */
  90941. private static _ANIMATIONTYPE_VECTOR2;
  90942. /**
  90943. * Size animation type
  90944. */
  90945. private static _ANIMATIONTYPE_SIZE;
  90946. /**
  90947. * Relative Loop Mode
  90948. */
  90949. private static _ANIMATIONLOOPMODE_RELATIVE;
  90950. /**
  90951. * Cycle Loop Mode
  90952. */
  90953. private static _ANIMATIONLOOPMODE_CYCLE;
  90954. /**
  90955. * Constant Loop Mode
  90956. */
  90957. private static _ANIMATIONLOOPMODE_CONSTANT;
  90958. /**
  90959. * Get the float animation type
  90960. */
  90961. static readonly ANIMATIONTYPE_FLOAT: number;
  90962. /**
  90963. * Get the Vector3 animation type
  90964. */
  90965. static readonly ANIMATIONTYPE_VECTOR3: number;
  90966. /**
  90967. * Get the Vector2 animation type
  90968. */
  90969. static readonly ANIMATIONTYPE_VECTOR2: number;
  90970. /**
  90971. * Get the Size animation type
  90972. */
  90973. static readonly ANIMATIONTYPE_SIZE: number;
  90974. /**
  90975. * Get the Quaternion animation type
  90976. */
  90977. static readonly ANIMATIONTYPE_QUATERNION: number;
  90978. /**
  90979. * Get the Matrix animation type
  90980. */
  90981. static readonly ANIMATIONTYPE_MATRIX: number;
  90982. /**
  90983. * Get the Color3 animation type
  90984. */
  90985. static readonly ANIMATIONTYPE_COLOR3: number;
  90986. /**
  90987. * Get the Relative Loop Mode
  90988. */
  90989. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  90990. /**
  90991. * Get the Cycle Loop Mode
  90992. */
  90993. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  90994. /**
  90995. * Get the Constant Loop Mode
  90996. */
  90997. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  90998. /** @hidden */
  90999. static _UniversalLerp(left: any, right: any, amount: number): any;
  91000. /**
  91001. * Parses an animation object and creates an animation
  91002. * @param parsedAnimation Parsed animation object
  91003. * @returns Animation object
  91004. */
  91005. static Parse(parsedAnimation: any): Animation;
  91006. /**
  91007. * Appends the serialized animations from the source animations
  91008. * @param source Source containing the animations
  91009. * @param destination Target to store the animations
  91010. */
  91011. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91012. }
  91013. }
  91014. declare module BABYLON {
  91015. /**
  91016. * Interface containing an array of animations
  91017. */
  91018. export interface IAnimatable {
  91019. /**
  91020. * Array of animations
  91021. */
  91022. animations: Nullable<Array<Animation>>;
  91023. }
  91024. }
  91025. declare module BABYLON {
  91026. /**
  91027. * This represents all the required information to add a fresnel effect on a material:
  91028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  91029. */
  91030. export class FresnelParameters {
  91031. private _isEnabled;
  91032. /**
  91033. * Define if the fresnel effect is enable or not.
  91034. */
  91035. isEnabled: boolean;
  91036. /**
  91037. * Define the color used on edges (grazing angle)
  91038. */
  91039. leftColor: Color3;
  91040. /**
  91041. * Define the color used on center
  91042. */
  91043. rightColor: Color3;
  91044. /**
  91045. * Define bias applied to computed fresnel term
  91046. */
  91047. bias: number;
  91048. /**
  91049. * Defined the power exponent applied to fresnel term
  91050. */
  91051. power: number;
  91052. /**
  91053. * Clones the current fresnel and its valuues
  91054. * @returns a clone fresnel configuration
  91055. */
  91056. clone(): FresnelParameters;
  91057. /**
  91058. * Serializes the current fresnel parameters to a JSON representation.
  91059. * @return the JSON serialization
  91060. */
  91061. serialize(): any;
  91062. /**
  91063. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91064. * @param parsedFresnelParameters Define the JSON representation
  91065. * @returns the parsed parameters
  91066. */
  91067. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91068. }
  91069. }
  91070. declare module BABYLON {
  91071. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91072. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91073. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91074. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91075. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91076. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91077. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91078. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91079. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91080. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91081. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91082. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91083. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91084. /**
  91085. * Decorator used to define property that can be serialized as reference to a camera
  91086. * @param sourceName defines the name of the property to decorate
  91087. */
  91088. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91089. /**
  91090. * Class used to help serialization objects
  91091. */
  91092. export class SerializationHelper {
  91093. /** @hidden */
  91094. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91095. /** @hidden */
  91096. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91097. /** @hidden */
  91098. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91099. /** @hidden */
  91100. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91101. /**
  91102. * Appends the serialized animations from the source animations
  91103. * @param source Source containing the animations
  91104. * @param destination Target to store the animations
  91105. */
  91106. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91107. /**
  91108. * Static function used to serialized a specific entity
  91109. * @param entity defines the entity to serialize
  91110. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91111. * @returns a JSON compatible object representing the serialization of the entity
  91112. */
  91113. static Serialize<T>(entity: T, serializationObject?: any): any;
  91114. /**
  91115. * Creates a new entity from a serialization data object
  91116. * @param creationFunction defines a function used to instanciated the new entity
  91117. * @param source defines the source serialization data
  91118. * @param scene defines the hosting scene
  91119. * @param rootUrl defines the root url for resources
  91120. * @returns a new entity
  91121. */
  91122. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91123. /**
  91124. * Clones an object
  91125. * @param creationFunction defines the function used to instanciate the new object
  91126. * @param source defines the source object
  91127. * @returns the cloned object
  91128. */
  91129. static Clone<T>(creationFunction: () => T, source: T): T;
  91130. /**
  91131. * Instanciates a new object based on a source one (some data will be shared between both object)
  91132. * @param creationFunction defines the function used to instanciate the new object
  91133. * @param source defines the source object
  91134. * @returns the new object
  91135. */
  91136. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91137. }
  91138. }
  91139. declare module BABYLON {
  91140. /**
  91141. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91142. */
  91143. export interface CubeMapInfo {
  91144. /**
  91145. * The pixel array for the front face.
  91146. * This is stored in format, left to right, up to down format.
  91147. */
  91148. front: Nullable<ArrayBufferView>;
  91149. /**
  91150. * The pixel array for the back face.
  91151. * This is stored in format, left to right, up to down format.
  91152. */
  91153. back: Nullable<ArrayBufferView>;
  91154. /**
  91155. * The pixel array for the left face.
  91156. * This is stored in format, left to right, up to down format.
  91157. */
  91158. left: Nullable<ArrayBufferView>;
  91159. /**
  91160. * The pixel array for the right face.
  91161. * This is stored in format, left to right, up to down format.
  91162. */
  91163. right: Nullable<ArrayBufferView>;
  91164. /**
  91165. * The pixel array for the up face.
  91166. * This is stored in format, left to right, up to down format.
  91167. */
  91168. up: Nullable<ArrayBufferView>;
  91169. /**
  91170. * The pixel array for the down face.
  91171. * This is stored in format, left to right, up to down format.
  91172. */
  91173. down: Nullable<ArrayBufferView>;
  91174. /**
  91175. * The size of the cubemap stored.
  91176. *
  91177. * Each faces will be size * size pixels.
  91178. */
  91179. size: number;
  91180. /**
  91181. * The format of the texture.
  91182. *
  91183. * RGBA, RGB.
  91184. */
  91185. format: number;
  91186. /**
  91187. * The type of the texture data.
  91188. *
  91189. * UNSIGNED_INT, FLOAT.
  91190. */
  91191. type: number;
  91192. /**
  91193. * Specifies whether the texture is in gamma space.
  91194. */
  91195. gammaSpace: boolean;
  91196. }
  91197. /**
  91198. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91199. */
  91200. export class PanoramaToCubeMapTools {
  91201. private static FACE_FRONT;
  91202. private static FACE_BACK;
  91203. private static FACE_RIGHT;
  91204. private static FACE_LEFT;
  91205. private static FACE_DOWN;
  91206. private static FACE_UP;
  91207. /**
  91208. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91209. *
  91210. * @param float32Array The source data.
  91211. * @param inputWidth The width of the input panorama.
  91212. * @param inputHeight The height of the input panorama.
  91213. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91214. * @return The cubemap data
  91215. */
  91216. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91217. private static CreateCubemapTexture;
  91218. private static CalcProjectionSpherical;
  91219. }
  91220. }
  91221. declare module BABYLON {
  91222. /**
  91223. * Helper class dealing with the extraction of spherical polynomial dataArray
  91224. * from a cube map.
  91225. */
  91226. export class CubeMapToSphericalPolynomialTools {
  91227. private static FileFaces;
  91228. /**
  91229. * Converts a texture to the according Spherical Polynomial data.
  91230. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91231. *
  91232. * @param texture The texture to extract the information from.
  91233. * @return The Spherical Polynomial data.
  91234. */
  91235. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91236. /**
  91237. * Converts a cubemap to the according Spherical Polynomial data.
  91238. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91239. *
  91240. * @param cubeInfo The Cube map to extract the information from.
  91241. * @return The Spherical Polynomial data.
  91242. */
  91243. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91244. }
  91245. }
  91246. declare module BABYLON {
  91247. /**
  91248. * Class used to manipulate GUIDs
  91249. */
  91250. export class GUID {
  91251. /**
  91252. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91253. * Be aware Math.random() could cause collisions, but:
  91254. * "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"
  91255. * @returns a pseudo random id
  91256. */
  91257. static RandomId(): string;
  91258. }
  91259. }
  91260. declare module BABYLON {
  91261. /**
  91262. * Base class of all the textures in babylon.
  91263. * It groups all the common properties the materials, post process, lights... might need
  91264. * in order to make a correct use of the texture.
  91265. */
  91266. export class BaseTexture implements IAnimatable {
  91267. /**
  91268. * Default anisotropic filtering level for the application.
  91269. * It is set to 4 as a good tradeoff between perf and quality.
  91270. */
  91271. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91272. /**
  91273. * Gets or sets the unique id of the texture
  91274. */
  91275. uniqueId: number;
  91276. /**
  91277. * Define the name of the texture.
  91278. */
  91279. name: string;
  91280. /**
  91281. * Gets or sets an object used to store user defined information.
  91282. */
  91283. metadata: any;
  91284. /**
  91285. * For internal use only. Please do not use.
  91286. */
  91287. reservedDataStore: any;
  91288. private _hasAlpha;
  91289. /**
  91290. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91291. */
  91292. hasAlpha: boolean;
  91293. /**
  91294. * Defines if the alpha value should be determined via the rgb values.
  91295. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91296. */
  91297. getAlphaFromRGB: boolean;
  91298. /**
  91299. * Intensity or strength of the texture.
  91300. * It is commonly used by materials to fine tune the intensity of the texture
  91301. */
  91302. level: number;
  91303. /**
  91304. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91305. * This is part of the texture as textures usually maps to one uv set.
  91306. */
  91307. coordinatesIndex: number;
  91308. private _coordinatesMode;
  91309. /**
  91310. * How a texture is mapped.
  91311. *
  91312. * | Value | Type | Description |
  91313. * | ----- | ----------------------------------- | ----------- |
  91314. * | 0 | EXPLICIT_MODE | |
  91315. * | 1 | SPHERICAL_MODE | |
  91316. * | 2 | PLANAR_MODE | |
  91317. * | 3 | CUBIC_MODE | |
  91318. * | 4 | PROJECTION_MODE | |
  91319. * | 5 | SKYBOX_MODE | |
  91320. * | 6 | INVCUBIC_MODE | |
  91321. * | 7 | EQUIRECTANGULAR_MODE | |
  91322. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91323. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91324. */
  91325. coordinatesMode: number;
  91326. /**
  91327. * | Value | Type | Description |
  91328. * | ----- | ------------------ | ----------- |
  91329. * | 0 | CLAMP_ADDRESSMODE | |
  91330. * | 1 | WRAP_ADDRESSMODE | |
  91331. * | 2 | MIRROR_ADDRESSMODE | |
  91332. */
  91333. wrapU: number;
  91334. /**
  91335. * | Value | Type | Description |
  91336. * | ----- | ------------------ | ----------- |
  91337. * | 0 | CLAMP_ADDRESSMODE | |
  91338. * | 1 | WRAP_ADDRESSMODE | |
  91339. * | 2 | MIRROR_ADDRESSMODE | |
  91340. */
  91341. wrapV: number;
  91342. /**
  91343. * | Value | Type | Description |
  91344. * | ----- | ------------------ | ----------- |
  91345. * | 0 | CLAMP_ADDRESSMODE | |
  91346. * | 1 | WRAP_ADDRESSMODE | |
  91347. * | 2 | MIRROR_ADDRESSMODE | |
  91348. */
  91349. wrapR: number;
  91350. /**
  91351. * With compliant hardware and browser (supporting anisotropic filtering)
  91352. * this defines the level of anisotropic filtering in the texture.
  91353. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91354. */
  91355. anisotropicFilteringLevel: number;
  91356. /**
  91357. * Define if the texture is a cube texture or if false a 2d texture.
  91358. */
  91359. isCube: boolean;
  91360. /**
  91361. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91362. */
  91363. is3D: boolean;
  91364. /**
  91365. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91366. * HDR texture are usually stored in linear space.
  91367. * This only impacts the PBR and Background materials
  91368. */
  91369. gammaSpace: boolean;
  91370. /**
  91371. * Gets whether or not the texture contains RGBD data.
  91372. */
  91373. readonly isRGBD: boolean;
  91374. /**
  91375. * Is Z inverted in the texture (useful in a cube texture).
  91376. */
  91377. invertZ: boolean;
  91378. /**
  91379. * Are mip maps generated for this texture or not.
  91380. */
  91381. readonly noMipmap: boolean;
  91382. /**
  91383. * @hidden
  91384. */
  91385. lodLevelInAlpha: boolean;
  91386. /**
  91387. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91388. */
  91389. lodGenerationOffset: number;
  91390. /**
  91391. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91392. */
  91393. lodGenerationScale: number;
  91394. /**
  91395. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91396. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91397. * average roughness values.
  91398. */
  91399. linearSpecularLOD: boolean;
  91400. /**
  91401. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91402. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91403. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91404. */
  91405. irradianceTexture: Nullable<BaseTexture>;
  91406. /**
  91407. * Define if the texture is a render target.
  91408. */
  91409. isRenderTarget: boolean;
  91410. /**
  91411. * Define the unique id of the texture in the scene.
  91412. */
  91413. readonly uid: string;
  91414. /**
  91415. * Return a string representation of the texture.
  91416. * @returns the texture as a string
  91417. */
  91418. toString(): string;
  91419. /**
  91420. * Get the class name of the texture.
  91421. * @returns "BaseTexture"
  91422. */
  91423. getClassName(): string;
  91424. /**
  91425. * Define the list of animation attached to the texture.
  91426. */
  91427. animations: Animation[];
  91428. /**
  91429. * An event triggered when the texture is disposed.
  91430. */
  91431. onDisposeObservable: Observable<BaseTexture>;
  91432. private _onDisposeObserver;
  91433. /**
  91434. * Callback triggered when the texture has been disposed.
  91435. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91436. */
  91437. onDispose: () => void;
  91438. /**
  91439. * Define the current state of the loading sequence when in delayed load mode.
  91440. */
  91441. delayLoadState: number;
  91442. private _scene;
  91443. /** @hidden */
  91444. _texture: Nullable<InternalTexture>;
  91445. private _uid;
  91446. /**
  91447. * Define if the texture is preventinga material to render or not.
  91448. * If not and the texture is not ready, the engine will use a default black texture instead.
  91449. */
  91450. readonly isBlocking: boolean;
  91451. /**
  91452. * Instantiates a new BaseTexture.
  91453. * Base class of all the textures in babylon.
  91454. * It groups all the common properties the materials, post process, lights... might need
  91455. * in order to make a correct use of the texture.
  91456. * @param scene Define the scene the texture blongs to
  91457. */
  91458. constructor(scene: Nullable<Scene>);
  91459. /**
  91460. * Get the scene the texture belongs to.
  91461. * @returns the scene or null if undefined
  91462. */
  91463. getScene(): Nullable<Scene>;
  91464. /**
  91465. * Get the texture transform matrix used to offset tile the texture for istance.
  91466. * @returns the transformation matrix
  91467. */
  91468. getTextureMatrix(): Matrix;
  91469. /**
  91470. * Get the texture reflection matrix used to rotate/transform the reflection.
  91471. * @returns the reflection matrix
  91472. */
  91473. getReflectionTextureMatrix(): Matrix;
  91474. /**
  91475. * Get the underlying lower level texture from Babylon.
  91476. * @returns the insternal texture
  91477. */
  91478. getInternalTexture(): Nullable<InternalTexture>;
  91479. /**
  91480. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91481. * @returns true if ready or not blocking
  91482. */
  91483. isReadyOrNotBlocking(): boolean;
  91484. /**
  91485. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91486. * @returns true if fully ready
  91487. */
  91488. isReady(): boolean;
  91489. private _cachedSize;
  91490. /**
  91491. * Get the size of the texture.
  91492. * @returns the texture size.
  91493. */
  91494. getSize(): ISize;
  91495. /**
  91496. * Get the base size of the texture.
  91497. * It can be different from the size if the texture has been resized for POT for instance
  91498. * @returns the base size
  91499. */
  91500. getBaseSize(): ISize;
  91501. /**
  91502. * Update the sampling mode of the texture.
  91503. * Default is Trilinear mode.
  91504. *
  91505. * | Value | Type | Description |
  91506. * | ----- | ------------------ | ----------- |
  91507. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91508. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91509. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91510. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91511. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91512. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91513. * | 7 | NEAREST_LINEAR | |
  91514. * | 8 | NEAREST_NEAREST | |
  91515. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91516. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91517. * | 11 | LINEAR_LINEAR | |
  91518. * | 12 | LINEAR_NEAREST | |
  91519. *
  91520. * > _mag_: magnification filter (close to the viewer)
  91521. * > _min_: minification filter (far from the viewer)
  91522. * > _mip_: filter used between mip map levels
  91523. *@param samplingMode Define the new sampling mode of the texture
  91524. */
  91525. updateSamplingMode(samplingMode: number): void;
  91526. /**
  91527. * Scales the texture if is `canRescale()`
  91528. * @param ratio the resize factor we want to use to rescale
  91529. */
  91530. scale(ratio: number): void;
  91531. /**
  91532. * Get if the texture can rescale.
  91533. */
  91534. readonly canRescale: boolean;
  91535. /** @hidden */
  91536. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91537. /** @hidden */
  91538. _rebuild(): void;
  91539. /**
  91540. * Triggers the load sequence in delayed load mode.
  91541. */
  91542. delayLoad(): void;
  91543. /**
  91544. * Clones the texture.
  91545. * @returns the cloned texture
  91546. */
  91547. clone(): Nullable<BaseTexture>;
  91548. /**
  91549. * Get the texture underlying type (INT, FLOAT...)
  91550. */
  91551. readonly textureType: number;
  91552. /**
  91553. * Get the texture underlying format (RGB, RGBA...)
  91554. */
  91555. readonly textureFormat: number;
  91556. /**
  91557. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91558. * This will returns an RGBA array buffer containing either in values (0-255) or
  91559. * float values (0-1) depending of the underlying buffer type.
  91560. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91561. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91562. * @param buffer defines a user defined buffer to fill with data (can be null)
  91563. * @returns The Array buffer containing the pixels data.
  91564. */
  91565. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91566. /**
  91567. * Release and destroy the underlying lower level texture aka internalTexture.
  91568. */
  91569. releaseInternalTexture(): void;
  91570. /**
  91571. * Get the polynomial representation of the texture data.
  91572. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91573. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91574. */
  91575. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91576. /** @hidden */
  91577. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91578. /** @hidden */
  91579. readonly _lodTextureMid: Nullable<BaseTexture>;
  91580. /** @hidden */
  91581. readonly _lodTextureLow: Nullable<BaseTexture>;
  91582. /**
  91583. * Dispose the texture and release its associated resources.
  91584. */
  91585. dispose(): void;
  91586. /**
  91587. * Serialize the texture into a JSON representation that can be parsed later on.
  91588. * @returns the JSON representation of the texture
  91589. */
  91590. serialize(): any;
  91591. /**
  91592. * Helper function to be called back once a list of texture contains only ready textures.
  91593. * @param textures Define the list of textures to wait for
  91594. * @param callback Define the callback triggered once the entire list will be ready
  91595. */
  91596. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91597. }
  91598. }
  91599. declare module BABYLON {
  91600. /**
  91601. * Class used to store data associated with WebGL texture data for the engine
  91602. * This class should not be used directly
  91603. */
  91604. export class InternalTexture {
  91605. /** @hidden */
  91606. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91607. /**
  91608. * The source of the texture data is unknown
  91609. */
  91610. static DATASOURCE_UNKNOWN: number;
  91611. /**
  91612. * Texture data comes from an URL
  91613. */
  91614. static DATASOURCE_URL: number;
  91615. /**
  91616. * Texture data is only used for temporary storage
  91617. */
  91618. static DATASOURCE_TEMP: number;
  91619. /**
  91620. * Texture data comes from raw data (ArrayBuffer)
  91621. */
  91622. static DATASOURCE_RAW: number;
  91623. /**
  91624. * Texture content is dynamic (video or dynamic texture)
  91625. */
  91626. static DATASOURCE_DYNAMIC: number;
  91627. /**
  91628. * Texture content is generated by rendering to it
  91629. */
  91630. static DATASOURCE_RENDERTARGET: number;
  91631. /**
  91632. * Texture content is part of a multi render target process
  91633. */
  91634. static DATASOURCE_MULTIRENDERTARGET: number;
  91635. /**
  91636. * Texture data comes from a cube data file
  91637. */
  91638. static DATASOURCE_CUBE: number;
  91639. /**
  91640. * Texture data comes from a raw cube data
  91641. */
  91642. static DATASOURCE_CUBERAW: number;
  91643. /**
  91644. * Texture data come from a prefiltered cube data file
  91645. */
  91646. static DATASOURCE_CUBEPREFILTERED: number;
  91647. /**
  91648. * Texture content is raw 3D data
  91649. */
  91650. static DATASOURCE_RAW3D: number;
  91651. /**
  91652. * Texture content is a depth texture
  91653. */
  91654. static DATASOURCE_DEPTHTEXTURE: number;
  91655. /**
  91656. * Texture data comes from a raw cube data encoded with RGBD
  91657. */
  91658. static DATASOURCE_CUBERAW_RGBD: number;
  91659. /**
  91660. * Defines if the texture is ready
  91661. */
  91662. isReady: boolean;
  91663. /**
  91664. * Defines if the texture is a cube texture
  91665. */
  91666. isCube: boolean;
  91667. /**
  91668. * Defines if the texture contains 3D data
  91669. */
  91670. is3D: boolean;
  91671. /**
  91672. * Defines if the texture contains multiview data
  91673. */
  91674. isMultiview: boolean;
  91675. /**
  91676. * Gets the URL used to load this texture
  91677. */
  91678. url: string;
  91679. /**
  91680. * Gets the sampling mode of the texture
  91681. */
  91682. samplingMode: number;
  91683. /**
  91684. * Gets a boolean indicating if the texture needs mipmaps generation
  91685. */
  91686. generateMipMaps: boolean;
  91687. /**
  91688. * Gets the number of samples used by the texture (WebGL2+ only)
  91689. */
  91690. samples: number;
  91691. /**
  91692. * Gets the type of the texture (int, float...)
  91693. */
  91694. type: number;
  91695. /**
  91696. * Gets the format of the texture (RGB, RGBA...)
  91697. */
  91698. format: number;
  91699. /**
  91700. * Observable called when the texture is loaded
  91701. */
  91702. onLoadedObservable: Observable<InternalTexture>;
  91703. /**
  91704. * Gets the width of the texture
  91705. */
  91706. width: number;
  91707. /**
  91708. * Gets the height of the texture
  91709. */
  91710. height: number;
  91711. /**
  91712. * Gets the depth of the texture
  91713. */
  91714. depth: number;
  91715. /**
  91716. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91717. */
  91718. baseWidth: number;
  91719. /**
  91720. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91721. */
  91722. baseHeight: number;
  91723. /**
  91724. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91725. */
  91726. baseDepth: number;
  91727. /**
  91728. * Gets a boolean indicating if the texture is inverted on Y axis
  91729. */
  91730. invertY: boolean;
  91731. /** @hidden */
  91732. _invertVScale: boolean;
  91733. /** @hidden */
  91734. _associatedChannel: number;
  91735. /** @hidden */
  91736. _dataSource: number;
  91737. /** @hidden */
  91738. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91739. /** @hidden */
  91740. _bufferView: Nullable<ArrayBufferView>;
  91741. /** @hidden */
  91742. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91743. /** @hidden */
  91744. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91745. /** @hidden */
  91746. _size: number;
  91747. /** @hidden */
  91748. _extension: string;
  91749. /** @hidden */
  91750. _files: Nullable<string[]>;
  91751. /** @hidden */
  91752. _workingCanvas: Nullable<HTMLCanvasElement>;
  91753. /** @hidden */
  91754. _workingContext: Nullable<CanvasRenderingContext2D>;
  91755. /** @hidden */
  91756. _framebuffer: Nullable<WebGLFramebuffer>;
  91757. /** @hidden */
  91758. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91759. /** @hidden */
  91760. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91761. /** @hidden */
  91762. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91763. /** @hidden */
  91764. _attachments: Nullable<number[]>;
  91765. /** @hidden */
  91766. _cachedCoordinatesMode: Nullable<number>;
  91767. /** @hidden */
  91768. _cachedWrapU: Nullable<number>;
  91769. /** @hidden */
  91770. _cachedWrapV: Nullable<number>;
  91771. /** @hidden */
  91772. _cachedWrapR: Nullable<number>;
  91773. /** @hidden */
  91774. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91775. /** @hidden */
  91776. _isDisabled: boolean;
  91777. /** @hidden */
  91778. _compression: Nullable<string>;
  91779. /** @hidden */
  91780. _generateStencilBuffer: boolean;
  91781. /** @hidden */
  91782. _generateDepthBuffer: boolean;
  91783. /** @hidden */
  91784. _comparisonFunction: number;
  91785. /** @hidden */
  91786. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91787. /** @hidden */
  91788. _lodGenerationScale: number;
  91789. /** @hidden */
  91790. _lodGenerationOffset: number;
  91791. /** @hidden */
  91792. _colorTextureArray: Nullable<WebGLTexture>;
  91793. /** @hidden */
  91794. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91795. /** @hidden */
  91796. _lodTextureHigh: Nullable<BaseTexture>;
  91797. /** @hidden */
  91798. _lodTextureMid: Nullable<BaseTexture>;
  91799. /** @hidden */
  91800. _lodTextureLow: Nullable<BaseTexture>;
  91801. /** @hidden */
  91802. _isRGBD: boolean;
  91803. /** @hidden */
  91804. _linearSpecularLOD: boolean;
  91805. /** @hidden */
  91806. _irradianceTexture: Nullable<BaseTexture>;
  91807. /** @hidden */
  91808. _webGLTexture: Nullable<WebGLTexture>;
  91809. /** @hidden */
  91810. _references: number;
  91811. private _engine;
  91812. /**
  91813. * Gets the Engine the texture belongs to.
  91814. * @returns The babylon engine
  91815. */
  91816. getEngine(): Engine;
  91817. /**
  91818. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91819. */
  91820. readonly dataSource: number;
  91821. /**
  91822. * Creates a new InternalTexture
  91823. * @param engine defines the engine to use
  91824. * @param dataSource defines the type of data that will be used
  91825. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91826. */
  91827. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91828. /**
  91829. * Increments the number of references (ie. the number of Texture that point to it)
  91830. */
  91831. incrementReferences(): void;
  91832. /**
  91833. * Change the size of the texture (not the size of the content)
  91834. * @param width defines the new width
  91835. * @param height defines the new height
  91836. * @param depth defines the new depth (1 by default)
  91837. */
  91838. updateSize(width: int, height: int, depth?: int): void;
  91839. /** @hidden */
  91840. _rebuild(): void;
  91841. /** @hidden */
  91842. _swapAndDie(target: InternalTexture): void;
  91843. /**
  91844. * Dispose the current allocated resources
  91845. */
  91846. dispose(): void;
  91847. }
  91848. }
  91849. declare module BABYLON {
  91850. /**
  91851. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91852. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91853. */
  91854. export class EffectFallbacks {
  91855. private _defines;
  91856. private _currentRank;
  91857. private _maxRank;
  91858. private _mesh;
  91859. /**
  91860. * Removes the fallback from the bound mesh.
  91861. */
  91862. unBindMesh(): void;
  91863. /**
  91864. * Adds a fallback on the specified property.
  91865. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91866. * @param define The name of the define in the shader
  91867. */
  91868. addFallback(rank: number, define: string): void;
  91869. /**
  91870. * Sets the mesh to use CPU skinning when needing to fallback.
  91871. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91872. * @param mesh The mesh to use the fallbacks.
  91873. */
  91874. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91875. /**
  91876. * Checks to see if more fallbacks are still availible.
  91877. */
  91878. readonly isMoreFallbacks: boolean;
  91879. /**
  91880. * Removes the defines that should be removed when falling back.
  91881. * @param currentDefines defines the current define statements for the shader.
  91882. * @param effect defines the current effect we try to compile
  91883. * @returns The resulting defines with defines of the current rank removed.
  91884. */
  91885. reduce(currentDefines: string, effect: Effect): string;
  91886. }
  91887. /**
  91888. * Options to be used when creating an effect.
  91889. */
  91890. export class EffectCreationOptions {
  91891. /**
  91892. * Atrributes that will be used in the shader.
  91893. */
  91894. attributes: string[];
  91895. /**
  91896. * Uniform varible names that will be set in the shader.
  91897. */
  91898. uniformsNames: string[];
  91899. /**
  91900. * Uniform buffer varible names that will be set in the shader.
  91901. */
  91902. uniformBuffersNames: string[];
  91903. /**
  91904. * Sampler texture variable names that will be set in the shader.
  91905. */
  91906. samplers: string[];
  91907. /**
  91908. * Define statements that will be set in the shader.
  91909. */
  91910. defines: any;
  91911. /**
  91912. * Possible fallbacks for this effect to improve performance when needed.
  91913. */
  91914. fallbacks: Nullable<EffectFallbacks>;
  91915. /**
  91916. * Callback that will be called when the shader is compiled.
  91917. */
  91918. onCompiled: Nullable<(effect: Effect) => void>;
  91919. /**
  91920. * Callback that will be called if an error occurs during shader compilation.
  91921. */
  91922. onError: Nullable<(effect: Effect, errors: string) => void>;
  91923. /**
  91924. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91925. */
  91926. indexParameters: any;
  91927. /**
  91928. * Max number of lights that can be used in the shader.
  91929. */
  91930. maxSimultaneousLights: number;
  91931. /**
  91932. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91933. */
  91934. transformFeedbackVaryings: Nullable<string[]>;
  91935. }
  91936. /**
  91937. * Effect containing vertex and fragment shader that can be executed on an object.
  91938. */
  91939. export class Effect implements IDisposable {
  91940. /**
  91941. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91942. */
  91943. static ShadersRepository: string;
  91944. /**
  91945. * Name of the effect.
  91946. */
  91947. name: any;
  91948. /**
  91949. * String container all the define statements that should be set on the shader.
  91950. */
  91951. defines: string;
  91952. /**
  91953. * Callback that will be called when the shader is compiled.
  91954. */
  91955. onCompiled: Nullable<(effect: Effect) => void>;
  91956. /**
  91957. * Callback that will be called if an error occurs during shader compilation.
  91958. */
  91959. onError: Nullable<(effect: Effect, errors: string) => void>;
  91960. /**
  91961. * Callback that will be called when effect is bound.
  91962. */
  91963. onBind: Nullable<(effect: Effect) => void>;
  91964. /**
  91965. * Unique ID of the effect.
  91966. */
  91967. uniqueId: number;
  91968. /**
  91969. * Observable that will be called when the shader is compiled.
  91970. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91971. */
  91972. onCompileObservable: Observable<Effect>;
  91973. /**
  91974. * Observable that will be called if an error occurs during shader compilation.
  91975. */
  91976. onErrorObservable: Observable<Effect>;
  91977. /** @hidden */
  91978. _onBindObservable: Nullable<Observable<Effect>>;
  91979. /**
  91980. * Observable that will be called when effect is bound.
  91981. */
  91982. readonly onBindObservable: Observable<Effect>;
  91983. /** @hidden */
  91984. _bonesComputationForcedToCPU: boolean;
  91985. private static _uniqueIdSeed;
  91986. private _engine;
  91987. private _uniformBuffersNames;
  91988. private _uniformsNames;
  91989. private _samplerList;
  91990. private _samplers;
  91991. private _isReady;
  91992. private _compilationError;
  91993. private _attributesNames;
  91994. private _attributes;
  91995. private _uniforms;
  91996. /**
  91997. * Key for the effect.
  91998. * @hidden
  91999. */
  92000. _key: string;
  92001. private _indexParameters;
  92002. private _fallbacks;
  92003. private _vertexSourceCode;
  92004. private _fragmentSourceCode;
  92005. private _vertexSourceCodeOverride;
  92006. private _fragmentSourceCodeOverride;
  92007. private _transformFeedbackVaryings;
  92008. /**
  92009. * Compiled shader to webGL program.
  92010. * @hidden
  92011. */
  92012. _pipelineContext: Nullable<IPipelineContext>;
  92013. private _valueCache;
  92014. private static _baseCache;
  92015. /**
  92016. * Instantiates an effect.
  92017. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92018. * @param baseName Name of the effect.
  92019. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92020. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92021. * @param samplers List of sampler variables that will be passed to the shader.
  92022. * @param engine Engine to be used to render the effect
  92023. * @param defines Define statements to be added to the shader.
  92024. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92025. * @param onCompiled Callback that will be called when the shader is compiled.
  92026. * @param onError Callback that will be called if an error occurs during shader compilation.
  92027. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92028. */
  92029. 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);
  92030. private _useFinalCode;
  92031. /**
  92032. * Unique key for this effect
  92033. */
  92034. readonly key: string;
  92035. /**
  92036. * If the effect has been compiled and prepared.
  92037. * @returns if the effect is compiled and prepared.
  92038. */
  92039. isReady(): boolean;
  92040. /**
  92041. * The engine the effect was initialized with.
  92042. * @returns the engine.
  92043. */
  92044. getEngine(): Engine;
  92045. /**
  92046. * The pipeline context for this effect
  92047. * @returns the associated pipeline context
  92048. */
  92049. getPipelineContext(): Nullable<IPipelineContext>;
  92050. /**
  92051. * The set of names of attribute variables for the shader.
  92052. * @returns An array of attribute names.
  92053. */
  92054. getAttributesNames(): string[];
  92055. /**
  92056. * Returns the attribute at the given index.
  92057. * @param index The index of the attribute.
  92058. * @returns The location of the attribute.
  92059. */
  92060. getAttributeLocation(index: number): number;
  92061. /**
  92062. * Returns the attribute based on the name of the variable.
  92063. * @param name of the attribute to look up.
  92064. * @returns the attribute location.
  92065. */
  92066. getAttributeLocationByName(name: string): number;
  92067. /**
  92068. * The number of attributes.
  92069. * @returns the numnber of attributes.
  92070. */
  92071. getAttributesCount(): number;
  92072. /**
  92073. * Gets the index of a uniform variable.
  92074. * @param uniformName of the uniform to look up.
  92075. * @returns the index.
  92076. */
  92077. getUniformIndex(uniformName: string): number;
  92078. /**
  92079. * Returns the attribute based on the name of the variable.
  92080. * @param uniformName of the uniform to look up.
  92081. * @returns the location of the uniform.
  92082. */
  92083. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92084. /**
  92085. * Returns an array of sampler variable names
  92086. * @returns The array of sampler variable neames.
  92087. */
  92088. getSamplers(): string[];
  92089. /**
  92090. * The error from the last compilation.
  92091. * @returns the error string.
  92092. */
  92093. getCompilationError(): string;
  92094. /**
  92095. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92096. * @param func The callback to be used.
  92097. */
  92098. executeWhenCompiled(func: (effect: Effect) => void): void;
  92099. private _checkIsReady;
  92100. /** @hidden */
  92101. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92102. /** @hidden */
  92103. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92104. /** @hidden */
  92105. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92106. /**
  92107. * Recompiles the webGL program
  92108. * @param vertexSourceCode The source code for the vertex shader.
  92109. * @param fragmentSourceCode The source code for the fragment shader.
  92110. * @param onCompiled Callback called when completed.
  92111. * @param onError Callback called on error.
  92112. * @hidden
  92113. */
  92114. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92115. /**
  92116. * Prepares the effect
  92117. * @hidden
  92118. */
  92119. _prepareEffect(): void;
  92120. /**
  92121. * Checks if the effect is supported. (Must be called after compilation)
  92122. */
  92123. readonly isSupported: boolean;
  92124. /**
  92125. * Binds a texture to the engine to be used as output of the shader.
  92126. * @param channel Name of the output variable.
  92127. * @param texture Texture to bind.
  92128. * @hidden
  92129. */
  92130. _bindTexture(channel: string, texture: InternalTexture): void;
  92131. /**
  92132. * Sets a texture on the engine to be used in the shader.
  92133. * @param channel Name of the sampler variable.
  92134. * @param texture Texture to set.
  92135. */
  92136. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92137. /**
  92138. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92139. * @param channel Name of the sampler variable.
  92140. * @param texture Texture to set.
  92141. */
  92142. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92143. /**
  92144. * Sets an array of textures on the engine to be used in the shader.
  92145. * @param channel Name of the variable.
  92146. * @param textures Textures to set.
  92147. */
  92148. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92149. /**
  92150. * 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)
  92151. * @param channel Name of the sampler variable.
  92152. * @param postProcess Post process to get the input texture from.
  92153. */
  92154. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92155. /**
  92156. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92157. * 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)
  92158. * @param channel Name of the sampler variable.
  92159. * @param postProcess Post process to get the output texture from.
  92160. */
  92161. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92162. /** @hidden */
  92163. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92164. /** @hidden */
  92165. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92166. /** @hidden */
  92167. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92168. /** @hidden */
  92169. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92170. /**
  92171. * Binds a buffer to a uniform.
  92172. * @param buffer Buffer to bind.
  92173. * @param name Name of the uniform variable to bind to.
  92174. */
  92175. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92176. /**
  92177. * Binds block to a uniform.
  92178. * @param blockName Name of the block to bind.
  92179. * @param index Index to bind.
  92180. */
  92181. bindUniformBlock(blockName: string, index: number): void;
  92182. /**
  92183. * Sets an interger value on a uniform variable.
  92184. * @param uniformName Name of the variable.
  92185. * @param value Value to be set.
  92186. * @returns this effect.
  92187. */
  92188. setInt(uniformName: string, value: number): Effect;
  92189. /**
  92190. * Sets an int array on a uniform variable.
  92191. * @param uniformName Name of the variable.
  92192. * @param array array to be set.
  92193. * @returns this effect.
  92194. */
  92195. setIntArray(uniformName: string, array: Int32Array): Effect;
  92196. /**
  92197. * 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)
  92198. * @param uniformName Name of the variable.
  92199. * @param array array to be set.
  92200. * @returns this effect.
  92201. */
  92202. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92203. /**
  92204. * 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)
  92205. * @param uniformName Name of the variable.
  92206. * @param array array to be set.
  92207. * @returns this effect.
  92208. */
  92209. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92210. /**
  92211. * 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)
  92212. * @param uniformName Name of the variable.
  92213. * @param array array to be set.
  92214. * @returns this effect.
  92215. */
  92216. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92217. /**
  92218. * Sets an float array on a uniform variable.
  92219. * @param uniformName Name of the variable.
  92220. * @param array array to be set.
  92221. * @returns this effect.
  92222. */
  92223. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92224. /**
  92225. * 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)
  92226. * @param uniformName Name of the variable.
  92227. * @param array array to be set.
  92228. * @returns this effect.
  92229. */
  92230. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92231. /**
  92232. * 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)
  92233. * @param uniformName Name of the variable.
  92234. * @param array array to be set.
  92235. * @returns this effect.
  92236. */
  92237. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92238. /**
  92239. * 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)
  92240. * @param uniformName Name of the variable.
  92241. * @param array array to be set.
  92242. * @returns this effect.
  92243. */
  92244. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92245. /**
  92246. * Sets an array on a uniform variable.
  92247. * @param uniformName Name of the variable.
  92248. * @param array array to be set.
  92249. * @returns this effect.
  92250. */
  92251. setArray(uniformName: string, array: number[]): Effect;
  92252. /**
  92253. * 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)
  92254. * @param uniformName Name of the variable.
  92255. * @param array array to be set.
  92256. * @returns this effect.
  92257. */
  92258. setArray2(uniformName: string, array: number[]): Effect;
  92259. /**
  92260. * 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)
  92261. * @param uniformName Name of the variable.
  92262. * @param array array to be set.
  92263. * @returns this effect.
  92264. */
  92265. setArray3(uniformName: string, array: number[]): Effect;
  92266. /**
  92267. * 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)
  92268. * @param uniformName Name of the variable.
  92269. * @param array array to be set.
  92270. * @returns this effect.
  92271. */
  92272. setArray4(uniformName: string, array: number[]): Effect;
  92273. /**
  92274. * Sets matrices on a uniform variable.
  92275. * @param uniformName Name of the variable.
  92276. * @param matrices matrices to be set.
  92277. * @returns this effect.
  92278. */
  92279. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92280. /**
  92281. * Sets matrix on a uniform variable.
  92282. * @param uniformName Name of the variable.
  92283. * @param matrix matrix to be set.
  92284. * @returns this effect.
  92285. */
  92286. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92287. /**
  92288. * 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)
  92289. * @param uniformName Name of the variable.
  92290. * @param matrix matrix to be set.
  92291. * @returns this effect.
  92292. */
  92293. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92294. /**
  92295. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92296. * @param uniformName Name of the variable.
  92297. * @param matrix matrix to be set.
  92298. * @returns this effect.
  92299. */
  92300. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92301. /**
  92302. * Sets a float on a uniform variable.
  92303. * @param uniformName Name of the variable.
  92304. * @param value value to be set.
  92305. * @returns this effect.
  92306. */
  92307. setFloat(uniformName: string, value: number): Effect;
  92308. /**
  92309. * Sets a boolean on a uniform variable.
  92310. * @param uniformName Name of the variable.
  92311. * @param bool value to be set.
  92312. * @returns this effect.
  92313. */
  92314. setBool(uniformName: string, bool: boolean): Effect;
  92315. /**
  92316. * Sets a Vector2 on a uniform variable.
  92317. * @param uniformName Name of the variable.
  92318. * @param vector2 vector2 to be set.
  92319. * @returns this effect.
  92320. */
  92321. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92322. /**
  92323. * Sets a float2 on a uniform variable.
  92324. * @param uniformName Name of the variable.
  92325. * @param x First float in float2.
  92326. * @param y Second float in float2.
  92327. * @returns this effect.
  92328. */
  92329. setFloat2(uniformName: string, x: number, y: number): Effect;
  92330. /**
  92331. * Sets a Vector3 on a uniform variable.
  92332. * @param uniformName Name of the variable.
  92333. * @param vector3 Value to be set.
  92334. * @returns this effect.
  92335. */
  92336. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92337. /**
  92338. * Sets a float3 on a uniform variable.
  92339. * @param uniformName Name of the variable.
  92340. * @param x First float in float3.
  92341. * @param y Second float in float3.
  92342. * @param z Third float in float3.
  92343. * @returns this effect.
  92344. */
  92345. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92346. /**
  92347. * Sets a Vector4 on a uniform variable.
  92348. * @param uniformName Name of the variable.
  92349. * @param vector4 Value to be set.
  92350. * @returns this effect.
  92351. */
  92352. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92353. /**
  92354. * Sets a float4 on a uniform variable.
  92355. * @param uniformName Name of the variable.
  92356. * @param x First float in float4.
  92357. * @param y Second float in float4.
  92358. * @param z Third float in float4.
  92359. * @param w Fourth float in float4.
  92360. * @returns this effect.
  92361. */
  92362. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92363. /**
  92364. * Sets a Color3 on a uniform variable.
  92365. * @param uniformName Name of the variable.
  92366. * @param color3 Value to be set.
  92367. * @returns this effect.
  92368. */
  92369. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92370. /**
  92371. * Sets a Color4 on a uniform variable.
  92372. * @param uniformName Name of the variable.
  92373. * @param color3 Value to be set.
  92374. * @param alpha Alpha value to be set.
  92375. * @returns this effect.
  92376. */
  92377. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92378. /**
  92379. * Sets a Color4 on a uniform variable
  92380. * @param uniformName defines the name of the variable
  92381. * @param color4 defines the value to be set
  92382. * @returns this effect.
  92383. */
  92384. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92385. /** Release all associated resources */
  92386. dispose(): void;
  92387. /**
  92388. * This function will add a new shader to the shader store
  92389. * @param name the name of the shader
  92390. * @param pixelShader optional pixel shader content
  92391. * @param vertexShader optional vertex shader content
  92392. */
  92393. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92394. /**
  92395. * Store of each shader (The can be looked up using effect.key)
  92396. */
  92397. static ShadersStore: {
  92398. [key: string]: string;
  92399. };
  92400. /**
  92401. * Store of each included file for a shader (The can be looked up using effect.key)
  92402. */
  92403. static IncludesShadersStore: {
  92404. [key: string]: string;
  92405. };
  92406. /**
  92407. * Resets the cache of effects.
  92408. */
  92409. static ResetCache(): void;
  92410. }
  92411. }
  92412. declare module BABYLON {
  92413. /**
  92414. * Uniform buffer objects.
  92415. *
  92416. * Handles blocks of uniform on the GPU.
  92417. *
  92418. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92419. *
  92420. * For more information, please refer to :
  92421. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92422. */
  92423. export class UniformBuffer {
  92424. private _engine;
  92425. private _buffer;
  92426. private _data;
  92427. private _bufferData;
  92428. private _dynamic?;
  92429. private _uniformLocations;
  92430. private _uniformSizes;
  92431. private _uniformLocationPointer;
  92432. private _needSync;
  92433. private _noUBO;
  92434. private _currentEffect;
  92435. private static _MAX_UNIFORM_SIZE;
  92436. private static _tempBuffer;
  92437. /**
  92438. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92439. * This is dynamic to allow compat with webgl 1 and 2.
  92440. * You will need to pass the name of the uniform as well as the value.
  92441. */
  92442. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92443. /**
  92444. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92445. * This is dynamic to allow compat with webgl 1 and 2.
  92446. * You will need to pass the name of the uniform as well as the value.
  92447. */
  92448. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92449. /**
  92450. * Lambda to Update a single float in a uniform buffer.
  92451. * This is dynamic to allow compat with webgl 1 and 2.
  92452. * You will need to pass the name of the uniform as well as the value.
  92453. */
  92454. updateFloat: (name: string, x: number) => void;
  92455. /**
  92456. * Lambda to Update a vec2 of float in a uniform buffer.
  92457. * This is dynamic to allow compat with webgl 1 and 2.
  92458. * You will need to pass the name of the uniform as well as the value.
  92459. */
  92460. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92461. /**
  92462. * Lambda to Update a vec3 of float in a uniform buffer.
  92463. * This is dynamic to allow compat with webgl 1 and 2.
  92464. * You will need to pass the name of the uniform as well as the value.
  92465. */
  92466. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92467. /**
  92468. * Lambda to Update a vec4 of float in a uniform buffer.
  92469. * This is dynamic to allow compat with webgl 1 and 2.
  92470. * You will need to pass the name of the uniform as well as the value.
  92471. */
  92472. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92473. /**
  92474. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92475. * This is dynamic to allow compat with webgl 1 and 2.
  92476. * You will need to pass the name of the uniform as well as the value.
  92477. */
  92478. updateMatrix: (name: string, mat: Matrix) => void;
  92479. /**
  92480. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92481. * This is dynamic to allow compat with webgl 1 and 2.
  92482. * You will need to pass the name of the uniform as well as the value.
  92483. */
  92484. updateVector3: (name: string, vector: Vector3) => void;
  92485. /**
  92486. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92487. * This is dynamic to allow compat with webgl 1 and 2.
  92488. * You will need to pass the name of the uniform as well as the value.
  92489. */
  92490. updateVector4: (name: string, vector: Vector4) => void;
  92491. /**
  92492. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92493. * This is dynamic to allow compat with webgl 1 and 2.
  92494. * You will need to pass the name of the uniform as well as the value.
  92495. */
  92496. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92497. /**
  92498. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92499. * This is dynamic to allow compat with webgl 1 and 2.
  92500. * You will need to pass the name of the uniform as well as the value.
  92501. */
  92502. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92503. /**
  92504. * Instantiates a new Uniform buffer objects.
  92505. *
  92506. * Handles blocks of uniform on the GPU.
  92507. *
  92508. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92509. *
  92510. * For more information, please refer to :
  92511. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92512. * @param engine Define the engine the buffer is associated with
  92513. * @param data Define the data contained in the buffer
  92514. * @param dynamic Define if the buffer is updatable
  92515. */
  92516. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92517. /**
  92518. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92519. * or just falling back on setUniformXXX calls.
  92520. */
  92521. readonly useUbo: boolean;
  92522. /**
  92523. * Indicates if the WebGL underlying uniform buffer is in sync
  92524. * with the javascript cache data.
  92525. */
  92526. readonly isSync: boolean;
  92527. /**
  92528. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92529. * Also, a dynamic UniformBuffer will disable cache verification and always
  92530. * update the underlying WebGL uniform buffer to the GPU.
  92531. * @returns if Dynamic, otherwise false
  92532. */
  92533. isDynamic(): boolean;
  92534. /**
  92535. * The data cache on JS side.
  92536. * @returns the underlying data as a float array
  92537. */
  92538. getData(): Float32Array;
  92539. /**
  92540. * The underlying WebGL Uniform buffer.
  92541. * @returns the webgl buffer
  92542. */
  92543. getBuffer(): Nullable<DataBuffer>;
  92544. /**
  92545. * std140 layout specifies how to align data within an UBO structure.
  92546. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92547. * for specs.
  92548. */
  92549. private _fillAlignment;
  92550. /**
  92551. * Adds an uniform in the buffer.
  92552. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92553. * for the layout to be correct !
  92554. * @param name Name of the uniform, as used in the uniform block in the shader.
  92555. * @param size Data size, or data directly.
  92556. */
  92557. addUniform(name: string, size: number | number[]): void;
  92558. /**
  92559. * Adds a Matrix 4x4 to the uniform buffer.
  92560. * @param name Name of the uniform, as used in the uniform block in the shader.
  92561. * @param mat A 4x4 matrix.
  92562. */
  92563. addMatrix(name: string, mat: Matrix): void;
  92564. /**
  92565. * Adds a vec2 to the uniform buffer.
  92566. * @param name Name of the uniform, as used in the uniform block in the shader.
  92567. * @param x Define the x component value of the vec2
  92568. * @param y Define the y component value of the vec2
  92569. */
  92570. addFloat2(name: string, x: number, y: number): void;
  92571. /**
  92572. * Adds a vec3 to the uniform buffer.
  92573. * @param name Name of the uniform, as used in the uniform block in the shader.
  92574. * @param x Define the x component value of the vec3
  92575. * @param y Define the y component value of the vec3
  92576. * @param z Define the z component value of the vec3
  92577. */
  92578. addFloat3(name: string, x: number, y: number, z: number): void;
  92579. /**
  92580. * Adds a vec3 to the uniform buffer.
  92581. * @param name Name of the uniform, as used in the uniform block in the shader.
  92582. * @param color Define the vec3 from a Color
  92583. */
  92584. addColor3(name: string, color: Color3): void;
  92585. /**
  92586. * Adds a vec4 to the uniform buffer.
  92587. * @param name Name of the uniform, as used in the uniform block in the shader.
  92588. * @param color Define the rgb components from a Color
  92589. * @param alpha Define the a component of the vec4
  92590. */
  92591. addColor4(name: string, color: Color3, alpha: number): void;
  92592. /**
  92593. * Adds a vec3 to the uniform buffer.
  92594. * @param name Name of the uniform, as used in the uniform block in the shader.
  92595. * @param vector Define the vec3 components from a Vector
  92596. */
  92597. addVector3(name: string, vector: Vector3): void;
  92598. /**
  92599. * Adds a Matrix 3x3 to the uniform buffer.
  92600. * @param name Name of the uniform, as used in the uniform block in the shader.
  92601. */
  92602. addMatrix3x3(name: string): void;
  92603. /**
  92604. * Adds a Matrix 2x2 to the uniform buffer.
  92605. * @param name Name of the uniform, as used in the uniform block in the shader.
  92606. */
  92607. addMatrix2x2(name: string): void;
  92608. /**
  92609. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92610. */
  92611. create(): void;
  92612. /** @hidden */
  92613. _rebuild(): void;
  92614. /**
  92615. * Updates the WebGL Uniform Buffer on the GPU.
  92616. * If the `dynamic` flag is set to true, no cache comparison is done.
  92617. * Otherwise, the buffer will be updated only if the cache differs.
  92618. */
  92619. update(): void;
  92620. /**
  92621. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92622. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92623. * @param data Define the flattened data
  92624. * @param size Define the size of the data.
  92625. */
  92626. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92627. private _updateMatrix3x3ForUniform;
  92628. private _updateMatrix3x3ForEffect;
  92629. private _updateMatrix2x2ForEffect;
  92630. private _updateMatrix2x2ForUniform;
  92631. private _updateFloatForEffect;
  92632. private _updateFloatForUniform;
  92633. private _updateFloat2ForEffect;
  92634. private _updateFloat2ForUniform;
  92635. private _updateFloat3ForEffect;
  92636. private _updateFloat3ForUniform;
  92637. private _updateFloat4ForEffect;
  92638. private _updateFloat4ForUniform;
  92639. private _updateMatrixForEffect;
  92640. private _updateMatrixForUniform;
  92641. private _updateVector3ForEffect;
  92642. private _updateVector3ForUniform;
  92643. private _updateVector4ForEffect;
  92644. private _updateVector4ForUniform;
  92645. private _updateColor3ForEffect;
  92646. private _updateColor3ForUniform;
  92647. private _updateColor4ForEffect;
  92648. private _updateColor4ForUniform;
  92649. /**
  92650. * Sets a sampler uniform on the effect.
  92651. * @param name Define the name of the sampler.
  92652. * @param texture Define the texture to set in the sampler
  92653. */
  92654. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92655. /**
  92656. * Directly updates the value of the uniform in the cache AND on the GPU.
  92657. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92658. * @param data Define the flattened data
  92659. */
  92660. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92661. /**
  92662. * Binds this uniform buffer to an effect.
  92663. * @param effect Define the effect to bind the buffer to
  92664. * @param name Name of the uniform block in the shader.
  92665. */
  92666. bindToEffect(effect: Effect, name: string): void;
  92667. /**
  92668. * Disposes the uniform buffer.
  92669. */
  92670. dispose(): void;
  92671. }
  92672. }
  92673. declare module BABYLON {
  92674. /**
  92675. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92676. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92677. */
  92678. export class Analyser {
  92679. /**
  92680. * Gets or sets the smoothing
  92681. * @ignorenaming
  92682. */
  92683. SMOOTHING: number;
  92684. /**
  92685. * Gets or sets the FFT table size
  92686. * @ignorenaming
  92687. */
  92688. FFT_SIZE: number;
  92689. /**
  92690. * Gets or sets the bar graph amplitude
  92691. * @ignorenaming
  92692. */
  92693. BARGRAPHAMPLITUDE: number;
  92694. /**
  92695. * Gets or sets the position of the debug canvas
  92696. * @ignorenaming
  92697. */
  92698. DEBUGCANVASPOS: {
  92699. x: number;
  92700. y: number;
  92701. };
  92702. /**
  92703. * Gets or sets the debug canvas size
  92704. * @ignorenaming
  92705. */
  92706. DEBUGCANVASSIZE: {
  92707. width: number;
  92708. height: number;
  92709. };
  92710. private _byteFreqs;
  92711. private _byteTime;
  92712. private _floatFreqs;
  92713. private _webAudioAnalyser;
  92714. private _debugCanvas;
  92715. private _debugCanvasContext;
  92716. private _scene;
  92717. private _registerFunc;
  92718. private _audioEngine;
  92719. /**
  92720. * Creates a new analyser
  92721. * @param scene defines hosting scene
  92722. */
  92723. constructor(scene: Scene);
  92724. /**
  92725. * Get the number of data values you will have to play with for the visualization
  92726. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92727. * @returns a number
  92728. */
  92729. getFrequencyBinCount(): number;
  92730. /**
  92731. * Gets the current frequency data as a byte array
  92732. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92733. * @returns a Uint8Array
  92734. */
  92735. getByteFrequencyData(): Uint8Array;
  92736. /**
  92737. * Gets the current waveform as a byte array
  92738. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92739. * @returns a Uint8Array
  92740. */
  92741. getByteTimeDomainData(): Uint8Array;
  92742. /**
  92743. * Gets the current frequency data as a float array
  92744. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92745. * @returns a Float32Array
  92746. */
  92747. getFloatFrequencyData(): Float32Array;
  92748. /**
  92749. * Renders the debug canvas
  92750. */
  92751. drawDebugCanvas(): void;
  92752. /**
  92753. * Stops rendering the debug canvas and removes it
  92754. */
  92755. stopDebugCanvas(): void;
  92756. /**
  92757. * Connects two audio nodes
  92758. * @param inputAudioNode defines first node to connect
  92759. * @param outputAudioNode defines second node to connect
  92760. */
  92761. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92762. /**
  92763. * Releases all associated resources
  92764. */
  92765. dispose(): void;
  92766. }
  92767. }
  92768. declare module BABYLON {
  92769. /**
  92770. * This represents an audio engine and it is responsible
  92771. * to play, synchronize and analyse sounds throughout the application.
  92772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92773. */
  92774. export interface IAudioEngine extends IDisposable {
  92775. /**
  92776. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92777. */
  92778. readonly canUseWebAudio: boolean;
  92779. /**
  92780. * Gets the current AudioContext if available.
  92781. */
  92782. readonly audioContext: Nullable<AudioContext>;
  92783. /**
  92784. * The master gain node defines the global audio volume of your audio engine.
  92785. */
  92786. readonly masterGain: GainNode;
  92787. /**
  92788. * Gets whether or not mp3 are supported by your browser.
  92789. */
  92790. readonly isMP3supported: boolean;
  92791. /**
  92792. * Gets whether or not ogg are supported by your browser.
  92793. */
  92794. readonly isOGGsupported: boolean;
  92795. /**
  92796. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92797. * @ignoreNaming
  92798. */
  92799. WarnedWebAudioUnsupported: boolean;
  92800. /**
  92801. * Defines if the audio engine relies on a custom unlocked button.
  92802. * In this case, the embedded button will not be displayed.
  92803. */
  92804. useCustomUnlockedButton: boolean;
  92805. /**
  92806. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92807. */
  92808. readonly unlocked: boolean;
  92809. /**
  92810. * Event raised when audio has been unlocked on the browser.
  92811. */
  92812. onAudioUnlockedObservable: Observable<AudioEngine>;
  92813. /**
  92814. * Event raised when audio has been locked on the browser.
  92815. */
  92816. onAudioLockedObservable: Observable<AudioEngine>;
  92817. /**
  92818. * Flags the audio engine in Locked state.
  92819. * This happens due to new browser policies preventing audio to autoplay.
  92820. */
  92821. lock(): void;
  92822. /**
  92823. * Unlocks the audio engine once a user action has been done on the dom.
  92824. * This is helpful to resume play once browser policies have been satisfied.
  92825. */
  92826. unlock(): void;
  92827. }
  92828. /**
  92829. * This represents the default audio engine used in babylon.
  92830. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92832. */
  92833. export class AudioEngine implements IAudioEngine {
  92834. private _audioContext;
  92835. private _audioContextInitialized;
  92836. private _muteButton;
  92837. private _hostElement;
  92838. /**
  92839. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92840. */
  92841. canUseWebAudio: boolean;
  92842. /**
  92843. * The master gain node defines the global audio volume of your audio engine.
  92844. */
  92845. masterGain: GainNode;
  92846. /**
  92847. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92848. * @ignoreNaming
  92849. */
  92850. WarnedWebAudioUnsupported: boolean;
  92851. /**
  92852. * Gets whether or not mp3 are supported by your browser.
  92853. */
  92854. isMP3supported: boolean;
  92855. /**
  92856. * Gets whether or not ogg are supported by your browser.
  92857. */
  92858. isOGGsupported: boolean;
  92859. /**
  92860. * Gets whether audio has been unlocked on the device.
  92861. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  92862. * a user interaction has happened.
  92863. */
  92864. unlocked: boolean;
  92865. /**
  92866. * Defines if the audio engine relies on a custom unlocked button.
  92867. * In this case, the embedded button will not be displayed.
  92868. */
  92869. useCustomUnlockedButton: boolean;
  92870. /**
  92871. * Event raised when audio has been unlocked on the browser.
  92872. */
  92873. onAudioUnlockedObservable: Observable<AudioEngine>;
  92874. /**
  92875. * Event raised when audio has been locked on the browser.
  92876. */
  92877. onAudioLockedObservable: Observable<AudioEngine>;
  92878. /**
  92879. * Gets the current AudioContext if available.
  92880. */
  92881. readonly audioContext: Nullable<AudioContext>;
  92882. private _connectedAnalyser;
  92883. /**
  92884. * Instantiates a new audio engine.
  92885. *
  92886. * There should be only one per page as some browsers restrict the number
  92887. * of audio contexts you can create.
  92888. * @param hostElement defines the host element where to display the mute icon if necessary
  92889. */
  92890. constructor(hostElement?: Nullable<HTMLElement>);
  92891. /**
  92892. * Flags the audio engine in Locked state.
  92893. * This happens due to new browser policies preventing audio to autoplay.
  92894. */
  92895. lock(): void;
  92896. /**
  92897. * Unlocks the audio engine once a user action has been done on the dom.
  92898. * This is helpful to resume play once browser policies have been satisfied.
  92899. */
  92900. unlock(): void;
  92901. private _resumeAudioContext;
  92902. private _initializeAudioContext;
  92903. private _tryToRun;
  92904. private _triggerRunningState;
  92905. private _triggerSuspendedState;
  92906. private _displayMuteButton;
  92907. private _moveButtonToTopLeft;
  92908. private _onResize;
  92909. private _hideMuteButton;
  92910. /**
  92911. * Destroy and release the resources associated with the audio ccontext.
  92912. */
  92913. dispose(): void;
  92914. /**
  92915. * Gets the global volume sets on the master gain.
  92916. * @returns the global volume if set or -1 otherwise
  92917. */
  92918. getGlobalVolume(): number;
  92919. /**
  92920. * Sets the global volume of your experience (sets on the master gain).
  92921. * @param newVolume Defines the new global volume of the application
  92922. */
  92923. setGlobalVolume(newVolume: number): void;
  92924. /**
  92925. * Connect the audio engine to an audio analyser allowing some amazing
  92926. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92928. * @param analyser The analyser to connect to the engine
  92929. */
  92930. connectToAnalyser(analyser: Analyser): void;
  92931. }
  92932. }
  92933. declare module BABYLON {
  92934. /**
  92935. * Interface used to present a loading screen while loading a scene
  92936. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92937. */
  92938. export interface ILoadingScreen {
  92939. /**
  92940. * Function called to display the loading screen
  92941. */
  92942. displayLoadingUI: () => void;
  92943. /**
  92944. * Function called to hide the loading screen
  92945. */
  92946. hideLoadingUI: () => void;
  92947. /**
  92948. * Gets or sets the color to use for the background
  92949. */
  92950. loadingUIBackgroundColor: string;
  92951. /**
  92952. * Gets or sets the text to display while loading
  92953. */
  92954. loadingUIText: string;
  92955. }
  92956. /**
  92957. * Class used for the default loading screen
  92958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92959. */
  92960. export class DefaultLoadingScreen implements ILoadingScreen {
  92961. private _renderingCanvas;
  92962. private _loadingText;
  92963. private _loadingDivBackgroundColor;
  92964. private _loadingDiv;
  92965. private _loadingTextDiv;
  92966. /** Gets or sets the logo url to use for the default loading screen */
  92967. static DefaultLogoUrl: string;
  92968. /** Gets or sets the spinner url to use for the default loading screen */
  92969. static DefaultSpinnerUrl: string;
  92970. /**
  92971. * Creates a new default loading screen
  92972. * @param _renderingCanvas defines the canvas used to render the scene
  92973. * @param _loadingText defines the default text to display
  92974. * @param _loadingDivBackgroundColor defines the default background color
  92975. */
  92976. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  92977. /**
  92978. * Function called to display the loading screen
  92979. */
  92980. displayLoadingUI(): void;
  92981. /**
  92982. * Function called to hide the loading screen
  92983. */
  92984. hideLoadingUI(): void;
  92985. /**
  92986. * Gets or sets the text to display while loading
  92987. */
  92988. loadingUIText: string;
  92989. /**
  92990. * Gets or sets the color to use for the background
  92991. */
  92992. loadingUIBackgroundColor: string;
  92993. private _resizeLoadingUI;
  92994. }
  92995. }
  92996. declare module BABYLON {
  92997. /** @hidden */
  92998. export class WebGLPipelineContext implements IPipelineContext {
  92999. engine: Engine;
  93000. program: Nullable<WebGLProgram>;
  93001. context?: WebGLRenderingContext;
  93002. vertexShader?: WebGLShader;
  93003. fragmentShader?: WebGLShader;
  93004. isParallelCompiled: boolean;
  93005. onCompiled?: () => void;
  93006. transformFeedback?: WebGLTransformFeedback | null;
  93007. readonly isAsync: boolean;
  93008. readonly isReady: boolean;
  93009. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  93010. }
  93011. }
  93012. declare module BABYLON {
  93013. /** @hidden */
  93014. export class WebGLDataBuffer extends DataBuffer {
  93015. private _buffer;
  93016. constructor(resource: WebGLBuffer);
  93017. readonly underlyingResource: any;
  93018. }
  93019. }
  93020. declare module BABYLON {
  93021. /** @hidden */
  93022. export class WebGL2ShaderProcessor implements IShaderProcessor {
  93023. attributeProcessor(attribute: string): string;
  93024. varyingProcessor(varying: string, isFragment: boolean): string;
  93025. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  93026. }
  93027. }
  93028. declare module BABYLON {
  93029. /**
  93030. * This class is used to track a performance counter which is number based.
  93031. * The user has access to many properties which give statistics of different nature.
  93032. *
  93033. * The implementer can track two kinds of Performance Counter: time and count.
  93034. * 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.
  93035. * 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.
  93036. */
  93037. export class PerfCounter {
  93038. /**
  93039. * Gets or sets a global boolean to turn on and off all the counters
  93040. */
  93041. static Enabled: boolean;
  93042. /**
  93043. * Returns the smallest value ever
  93044. */
  93045. readonly min: number;
  93046. /**
  93047. * Returns the biggest value ever
  93048. */
  93049. readonly max: number;
  93050. /**
  93051. * Returns the average value since the performance counter is running
  93052. */
  93053. readonly average: number;
  93054. /**
  93055. * Returns the average value of the last second the counter was monitored
  93056. */
  93057. readonly lastSecAverage: number;
  93058. /**
  93059. * Returns the current value
  93060. */
  93061. readonly current: number;
  93062. /**
  93063. * Gets the accumulated total
  93064. */
  93065. readonly total: number;
  93066. /**
  93067. * Gets the total value count
  93068. */
  93069. readonly count: number;
  93070. /**
  93071. * Creates a new counter
  93072. */
  93073. constructor();
  93074. /**
  93075. * Call this method to start monitoring a new frame.
  93076. * 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.
  93077. */
  93078. fetchNewFrame(): void;
  93079. /**
  93080. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93081. * @param newCount the count value to add to the monitored count
  93082. * @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.
  93083. */
  93084. addCount(newCount: number, fetchResult: boolean): void;
  93085. /**
  93086. * Start monitoring this performance counter
  93087. */
  93088. beginMonitoring(): void;
  93089. /**
  93090. * Compute the time lapsed since the previous beginMonitoring() call.
  93091. * @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
  93092. */
  93093. endMonitoring(newFrame?: boolean): void;
  93094. private _fetchResult;
  93095. private _startMonitoringTime;
  93096. private _min;
  93097. private _max;
  93098. private _average;
  93099. private _current;
  93100. private _totalValueCount;
  93101. private _totalAccumulated;
  93102. private _lastSecAverage;
  93103. private _lastSecAccumulated;
  93104. private _lastSecTime;
  93105. private _lastSecValueCount;
  93106. }
  93107. }
  93108. declare module BABYLON {
  93109. /**
  93110. * Interface for any object that can request an animation frame
  93111. */
  93112. export interface ICustomAnimationFrameRequester {
  93113. /**
  93114. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93115. */
  93116. renderFunction?: Function;
  93117. /**
  93118. * Called to request the next frame to render to
  93119. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93120. */
  93121. requestAnimationFrame: Function;
  93122. /**
  93123. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93124. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93125. */
  93126. requestID?: number;
  93127. }
  93128. }
  93129. declare module BABYLON {
  93130. /**
  93131. * Settings for finer control over video usage
  93132. */
  93133. export interface VideoTextureSettings {
  93134. /**
  93135. * Applies `autoplay` to video, if specified
  93136. */
  93137. autoPlay?: boolean;
  93138. /**
  93139. * Applies `loop` to video, if specified
  93140. */
  93141. loop?: boolean;
  93142. /**
  93143. * Automatically updates internal texture from video at every frame in the render loop
  93144. */
  93145. autoUpdateTexture: boolean;
  93146. /**
  93147. * Image src displayed during the video loading or until the user interacts with the video.
  93148. */
  93149. poster?: string;
  93150. }
  93151. /**
  93152. * If you want to display a video in your scene, this is the special texture for that.
  93153. * This special texture works similar to other textures, with the exception of a few parameters.
  93154. * @see https://doc.babylonjs.com/how_to/video_texture
  93155. */
  93156. export class VideoTexture extends Texture {
  93157. /**
  93158. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93159. */
  93160. readonly autoUpdateTexture: boolean;
  93161. /**
  93162. * The video instance used by the texture internally
  93163. */
  93164. readonly video: HTMLVideoElement;
  93165. private _onUserActionRequestedObservable;
  93166. /**
  93167. * Event triggerd when a dom action is required by the user to play the video.
  93168. * This happens due to recent changes in browser policies preventing video to auto start.
  93169. */
  93170. readonly onUserActionRequestedObservable: Observable<Texture>;
  93171. private _generateMipMaps;
  93172. private _engine;
  93173. private _stillImageCaptured;
  93174. private _displayingPosterTexture;
  93175. private _settings;
  93176. private _createInternalTextureOnEvent;
  93177. /**
  93178. * Creates a video texture.
  93179. * If you want to display a video in your scene, this is the special texture for that.
  93180. * This special texture works similar to other textures, with the exception of a few parameters.
  93181. * @see https://doc.babylonjs.com/how_to/video_texture
  93182. * @param name optional name, will detect from video source, if not defined
  93183. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93184. * @param scene is obviously the current scene.
  93185. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93186. * @param invertY is false by default but can be used to invert video on Y axis
  93187. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93188. * @param settings allows finer control over video usage
  93189. */
  93190. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93191. private _getName;
  93192. private _getVideo;
  93193. private _createInternalTexture;
  93194. private reset;
  93195. /**
  93196. * @hidden Internal method to initiate `update`.
  93197. */
  93198. _rebuild(): void;
  93199. /**
  93200. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93201. */
  93202. update(): void;
  93203. /**
  93204. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93205. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93206. */
  93207. updateTexture(isVisible: boolean): void;
  93208. protected _updateInternalTexture: () => void;
  93209. /**
  93210. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93211. * @param url New url.
  93212. */
  93213. updateURL(url: string): void;
  93214. /**
  93215. * Dispose the texture and release its associated resources.
  93216. */
  93217. dispose(): void;
  93218. /**
  93219. * Creates a video texture straight from a stream.
  93220. * @param scene Define the scene the texture should be created in
  93221. * @param stream Define the stream the texture should be created from
  93222. * @returns The created video texture as a promise
  93223. */
  93224. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93225. /**
  93226. * Creates a video texture straight from your WebCam video feed.
  93227. * @param scene Define the scene the texture should be created in
  93228. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93229. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93230. * @returns The created video texture as a promise
  93231. */
  93232. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93233. minWidth: number;
  93234. maxWidth: number;
  93235. minHeight: number;
  93236. maxHeight: number;
  93237. deviceId: string;
  93238. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93239. /**
  93240. * Creates a video texture straight from your WebCam video feed.
  93241. * @param scene Define the scene the texture should be created in
  93242. * @param onReady Define a callback to triggered once the texture will be ready
  93243. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93244. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93245. */
  93246. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93247. minWidth: number;
  93248. maxWidth: number;
  93249. minHeight: number;
  93250. maxHeight: number;
  93251. deviceId: string;
  93252. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93253. }
  93254. }
  93255. declare module BABYLON {
  93256. /**
  93257. * Defines the interface used by objects containing a viewport (like a camera)
  93258. */
  93259. interface IViewportOwnerLike {
  93260. /**
  93261. * Gets or sets the viewport
  93262. */
  93263. viewport: IViewportLike;
  93264. }
  93265. /**
  93266. * Interface for attribute information associated with buffer instanciation
  93267. */
  93268. export class InstancingAttributeInfo {
  93269. /**
  93270. * Index/offset of the attribute in the vertex shader
  93271. */
  93272. index: number;
  93273. /**
  93274. * size of the attribute, 1, 2, 3 or 4
  93275. */
  93276. attributeSize: number;
  93277. /**
  93278. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93279. * default is FLOAT
  93280. */
  93281. attribyteType: number;
  93282. /**
  93283. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93284. */
  93285. normalized: boolean;
  93286. /**
  93287. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93288. */
  93289. offset: number;
  93290. /**
  93291. * Name of the GLSL attribute, for debugging purpose only
  93292. */
  93293. attributeName: string;
  93294. }
  93295. /**
  93296. * Define options used to create a depth texture
  93297. */
  93298. export class DepthTextureCreationOptions {
  93299. /** Specifies whether or not a stencil should be allocated in the texture */
  93300. generateStencil?: boolean;
  93301. /** Specifies whether or not bilinear filtering is enable on the texture */
  93302. bilinearFiltering?: boolean;
  93303. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93304. comparisonFunction?: number;
  93305. /** Specifies if the created texture is a cube texture */
  93306. isCube?: boolean;
  93307. }
  93308. /**
  93309. * Class used to describe the capabilities of the engine relatively to the current browser
  93310. */
  93311. export class EngineCapabilities {
  93312. /** Maximum textures units per fragment shader */
  93313. maxTexturesImageUnits: number;
  93314. /** Maximum texture units per vertex shader */
  93315. maxVertexTextureImageUnits: number;
  93316. /** Maximum textures units in the entire pipeline */
  93317. maxCombinedTexturesImageUnits: number;
  93318. /** Maximum texture size */
  93319. maxTextureSize: number;
  93320. /** Maximum cube texture size */
  93321. maxCubemapTextureSize: number;
  93322. /** Maximum render texture size */
  93323. maxRenderTextureSize: number;
  93324. /** Maximum number of vertex attributes */
  93325. maxVertexAttribs: number;
  93326. /** Maximum number of varyings */
  93327. maxVaryingVectors: number;
  93328. /** Maximum number of uniforms per vertex shader */
  93329. maxVertexUniformVectors: number;
  93330. /** Maximum number of uniforms per fragment shader */
  93331. maxFragmentUniformVectors: number;
  93332. /** Defines if standard derivates (dx/dy) are supported */
  93333. standardDerivatives: boolean;
  93334. /** Defines if s3tc texture compression is supported */
  93335. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93336. /** Defines if pvrtc texture compression is supported */
  93337. pvrtc: any;
  93338. /** Defines if etc1 texture compression is supported */
  93339. etc1: any;
  93340. /** Defines if etc2 texture compression is supported */
  93341. etc2: any;
  93342. /** Defines if astc texture compression is supported */
  93343. astc: any;
  93344. /** Defines if float textures are supported */
  93345. textureFloat: boolean;
  93346. /** Defines if vertex array objects are supported */
  93347. vertexArrayObject: boolean;
  93348. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93349. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93350. /** Gets the maximum level of anisotropy supported */
  93351. maxAnisotropy: number;
  93352. /** Defines if instancing is supported */
  93353. instancedArrays: boolean;
  93354. /** Defines if 32 bits indices are supported */
  93355. uintIndices: boolean;
  93356. /** Defines if high precision shaders are supported */
  93357. highPrecisionShaderSupported: boolean;
  93358. /** Defines if depth reading in the fragment shader is supported */
  93359. fragmentDepthSupported: boolean;
  93360. /** Defines if float texture linear filtering is supported*/
  93361. textureFloatLinearFiltering: boolean;
  93362. /** Defines if rendering to float textures is supported */
  93363. textureFloatRender: boolean;
  93364. /** Defines if half float textures are supported*/
  93365. textureHalfFloat: boolean;
  93366. /** Defines if half float texture linear filtering is supported*/
  93367. textureHalfFloatLinearFiltering: boolean;
  93368. /** Defines if rendering to half float textures is supported */
  93369. textureHalfFloatRender: boolean;
  93370. /** Defines if textureLOD shader command is supported */
  93371. textureLOD: boolean;
  93372. /** Defines if draw buffers extension is supported */
  93373. drawBuffersExtension: boolean;
  93374. /** Defines if depth textures are supported */
  93375. depthTextureExtension: boolean;
  93376. /** Defines if float color buffer are supported */
  93377. colorBufferFloat: boolean;
  93378. /** Gets disjoint timer query extension (null if not supported) */
  93379. timerQuery: EXT_disjoint_timer_query;
  93380. /** Defines if timestamp can be used with timer query */
  93381. canUseTimestampForTimerQuery: boolean;
  93382. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93383. multiview: any;
  93384. /** Function used to let the system compiles shaders in background */
  93385. parallelShaderCompile: {
  93386. COMPLETION_STATUS_KHR: number;
  93387. };
  93388. }
  93389. /** Interface defining initialization parameters for Engine class */
  93390. export interface EngineOptions extends WebGLContextAttributes {
  93391. /**
  93392. * Defines if the engine should no exceed a specified device ratio
  93393. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93394. */
  93395. limitDeviceRatio?: number;
  93396. /**
  93397. * Defines if webvr should be enabled automatically
  93398. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93399. */
  93400. autoEnableWebVR?: boolean;
  93401. /**
  93402. * Defines if webgl2 should be turned off even if supported
  93403. * @see http://doc.babylonjs.com/features/webgl2
  93404. */
  93405. disableWebGL2Support?: boolean;
  93406. /**
  93407. * Defines if webaudio should be initialized as well
  93408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93409. */
  93410. audioEngine?: boolean;
  93411. /**
  93412. * Defines if animations should run using a deterministic lock step
  93413. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93414. */
  93415. deterministicLockstep?: boolean;
  93416. /** Defines the maximum steps to use with deterministic lock step mode */
  93417. lockstepMaxSteps?: number;
  93418. /**
  93419. * Defines that engine should ignore context lost events
  93420. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93421. */
  93422. doNotHandleContextLost?: boolean;
  93423. /**
  93424. * Defines that engine should ignore modifying touch action attribute and style
  93425. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93426. */
  93427. doNotHandleTouchAction?: boolean;
  93428. /**
  93429. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93430. */
  93431. useHighPrecisionFloats?: boolean;
  93432. }
  93433. /**
  93434. * Defines the interface used by display changed events
  93435. */
  93436. export interface IDisplayChangedEventArgs {
  93437. /** Gets the vrDisplay object (if any) */
  93438. vrDisplay: Nullable<any>;
  93439. /** Gets a boolean indicating if webVR is supported */
  93440. vrSupported: boolean;
  93441. }
  93442. /**
  93443. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93444. */
  93445. export class Engine {
  93446. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93447. static ExceptionList: ({
  93448. key: string;
  93449. capture: string;
  93450. captureConstraint: number;
  93451. targets: string[];
  93452. } | {
  93453. key: string;
  93454. capture: null;
  93455. captureConstraint: null;
  93456. targets: string[];
  93457. })[];
  93458. /** Gets the list of created engines */
  93459. static readonly Instances: Engine[];
  93460. /**
  93461. * Gets the latest created engine
  93462. */
  93463. static readonly LastCreatedEngine: Nullable<Engine>;
  93464. /**
  93465. * Gets the latest created scene
  93466. */
  93467. static readonly LastCreatedScene: Nullable<Scene>;
  93468. /**
  93469. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93470. * @param flag defines which part of the materials must be marked as dirty
  93471. * @param predicate defines a predicate used to filter which materials should be affected
  93472. */
  93473. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93474. /** @hidden */
  93475. static _TextureLoaders: IInternalTextureLoader[];
  93476. /** Defines that alpha blending is disabled */
  93477. static readonly ALPHA_DISABLE: number;
  93478. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93479. static readonly ALPHA_ADD: number;
  93480. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93481. static readonly ALPHA_COMBINE: number;
  93482. /** Defines that alpha blending to DEST - SRC * DEST */
  93483. static readonly ALPHA_SUBTRACT: number;
  93484. /** Defines that alpha blending to SRC * DEST */
  93485. static readonly ALPHA_MULTIPLY: number;
  93486. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93487. static readonly ALPHA_MAXIMIZED: number;
  93488. /** Defines that alpha blending to SRC + DEST */
  93489. static readonly ALPHA_ONEONE: number;
  93490. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93491. static readonly ALPHA_PREMULTIPLIED: number;
  93492. /**
  93493. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93494. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93495. */
  93496. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93497. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93498. static readonly ALPHA_INTERPOLATE: number;
  93499. /**
  93500. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93501. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93502. */
  93503. static readonly ALPHA_SCREENMODE: number;
  93504. /** Defines that the ressource is not delayed*/
  93505. static readonly DELAYLOADSTATE_NONE: number;
  93506. /** Defines that the ressource was successfully delay loaded */
  93507. static readonly DELAYLOADSTATE_LOADED: number;
  93508. /** Defines that the ressource is currently delay loading */
  93509. static readonly DELAYLOADSTATE_LOADING: number;
  93510. /** Defines that the ressource is delayed and has not started loading */
  93511. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93513. static readonly NEVER: number;
  93514. /** 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 */
  93515. static readonly ALWAYS: number;
  93516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93517. static readonly LESS: number;
  93518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93519. static readonly EQUAL: number;
  93520. /** 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 */
  93521. static readonly LEQUAL: number;
  93522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93523. static readonly GREATER: number;
  93524. /** 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 */
  93525. static readonly GEQUAL: number;
  93526. /** 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 */
  93527. static readonly NOTEQUAL: number;
  93528. /** Passed to stencilOperation to specify that stencil value must be kept */
  93529. static readonly KEEP: number;
  93530. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93531. static readonly REPLACE: number;
  93532. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93533. static readonly INCR: number;
  93534. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93535. static readonly DECR: number;
  93536. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93537. static readonly INVERT: number;
  93538. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93539. static readonly INCR_WRAP: number;
  93540. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93541. static readonly DECR_WRAP: number;
  93542. /** Texture is not repeating outside of 0..1 UVs */
  93543. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93544. /** Texture is repeating outside of 0..1 UVs */
  93545. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93546. /** Texture is repeating and mirrored */
  93547. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93548. /** ALPHA */
  93549. static readonly TEXTUREFORMAT_ALPHA: number;
  93550. /** LUMINANCE */
  93551. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93552. /** LUMINANCE_ALPHA */
  93553. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93554. /** RGB */
  93555. static readonly TEXTUREFORMAT_RGB: number;
  93556. /** RGBA */
  93557. static readonly TEXTUREFORMAT_RGBA: number;
  93558. /** RED */
  93559. static readonly TEXTUREFORMAT_RED: number;
  93560. /** RED (2nd reference) */
  93561. static readonly TEXTUREFORMAT_R: number;
  93562. /** RG */
  93563. static readonly TEXTUREFORMAT_RG: number;
  93564. /** RED_INTEGER */
  93565. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93566. /** RED_INTEGER (2nd reference) */
  93567. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93568. /** RG_INTEGER */
  93569. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93570. /** RGB_INTEGER */
  93571. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93572. /** RGBA_INTEGER */
  93573. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93574. /** UNSIGNED_BYTE */
  93575. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93576. /** UNSIGNED_BYTE (2nd reference) */
  93577. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93578. /** FLOAT */
  93579. static readonly TEXTURETYPE_FLOAT: number;
  93580. /** HALF_FLOAT */
  93581. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93582. /** BYTE */
  93583. static readonly TEXTURETYPE_BYTE: number;
  93584. /** SHORT */
  93585. static readonly TEXTURETYPE_SHORT: number;
  93586. /** UNSIGNED_SHORT */
  93587. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93588. /** INT */
  93589. static readonly TEXTURETYPE_INT: number;
  93590. /** UNSIGNED_INT */
  93591. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93592. /** UNSIGNED_SHORT_4_4_4_4 */
  93593. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93594. /** UNSIGNED_SHORT_5_5_5_1 */
  93595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93596. /** UNSIGNED_SHORT_5_6_5 */
  93597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93598. /** UNSIGNED_INT_2_10_10_10_REV */
  93599. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93600. /** UNSIGNED_INT_24_8 */
  93601. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93602. /** UNSIGNED_INT_10F_11F_11F_REV */
  93603. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93604. /** UNSIGNED_INT_5_9_9_9_REV */
  93605. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93606. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93607. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93608. /** nearest is mag = nearest and min = nearest and mip = linear */
  93609. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93610. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93611. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93612. /** Trilinear is mag = linear and min = linear and mip = linear */
  93613. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93614. /** nearest is mag = nearest and min = nearest and mip = linear */
  93615. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93616. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93617. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93618. /** Trilinear is mag = linear and min = linear and mip = linear */
  93619. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93620. /** mag = nearest and min = nearest and mip = nearest */
  93621. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93622. /** mag = nearest and min = linear and mip = nearest */
  93623. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93624. /** mag = nearest and min = linear and mip = linear */
  93625. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93626. /** mag = nearest and min = linear and mip = none */
  93627. static readonly TEXTURE_NEAREST_LINEAR: number;
  93628. /** mag = nearest and min = nearest and mip = none */
  93629. static readonly TEXTURE_NEAREST_NEAREST: number;
  93630. /** mag = linear and min = nearest and mip = nearest */
  93631. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93632. /** mag = linear and min = nearest and mip = linear */
  93633. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93634. /** mag = linear and min = linear and mip = none */
  93635. static readonly TEXTURE_LINEAR_LINEAR: number;
  93636. /** mag = linear and min = nearest and mip = none */
  93637. static readonly TEXTURE_LINEAR_NEAREST: number;
  93638. /** Explicit coordinates mode */
  93639. static readonly TEXTURE_EXPLICIT_MODE: number;
  93640. /** Spherical coordinates mode */
  93641. static readonly TEXTURE_SPHERICAL_MODE: number;
  93642. /** Planar coordinates mode */
  93643. static readonly TEXTURE_PLANAR_MODE: number;
  93644. /** Cubic coordinates mode */
  93645. static readonly TEXTURE_CUBIC_MODE: number;
  93646. /** Projection coordinates mode */
  93647. static readonly TEXTURE_PROJECTION_MODE: number;
  93648. /** Skybox coordinates mode */
  93649. static readonly TEXTURE_SKYBOX_MODE: number;
  93650. /** Inverse Cubic coordinates mode */
  93651. static readonly TEXTURE_INVCUBIC_MODE: number;
  93652. /** Equirectangular coordinates mode */
  93653. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93654. /** Equirectangular Fixed coordinates mode */
  93655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93656. /** Equirectangular Fixed Mirrored coordinates mode */
  93657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93658. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93659. static readonly SCALEMODE_FLOOR: number;
  93660. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93661. static readonly SCALEMODE_NEAREST: number;
  93662. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93663. static readonly SCALEMODE_CEILING: number;
  93664. /**
  93665. * Returns the current npm package of the sdk
  93666. */
  93667. static readonly NpmPackage: string;
  93668. /**
  93669. * Returns the current version of the framework
  93670. */
  93671. static readonly Version: string;
  93672. /**
  93673. * Returns a string describing the current engine
  93674. */
  93675. readonly description: string;
  93676. /**
  93677. * Gets or sets the epsilon value used by collision engine
  93678. */
  93679. static CollisionsEpsilon: number;
  93680. /**
  93681. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93682. */
  93683. static ShadersRepository: string;
  93684. /**
  93685. * Method called to create the default loading screen.
  93686. * This can be overriden in your own app.
  93687. * @param canvas The rendering canvas element
  93688. * @returns The loading screen
  93689. */
  93690. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93691. /**
  93692. * Method called to create the default rescale post process on each engine.
  93693. */
  93694. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93695. /** @hidden */
  93696. _shaderProcessor: IShaderProcessor;
  93697. /**
  93698. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93699. */
  93700. forcePOTTextures: boolean;
  93701. /**
  93702. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93703. */
  93704. isFullscreen: boolean;
  93705. /**
  93706. * Gets a boolean indicating if the pointer is currently locked
  93707. */
  93708. isPointerLock: boolean;
  93709. /**
  93710. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93711. */
  93712. cullBackFaces: boolean;
  93713. /**
  93714. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93715. */
  93716. renderEvenInBackground: boolean;
  93717. /**
  93718. * Gets or sets a boolean indicating that cache can be kept between frames
  93719. */
  93720. preventCacheWipeBetweenFrames: boolean;
  93721. /**
  93722. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93723. **/
  93724. enableOfflineSupport: boolean;
  93725. /**
  93726. * 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)
  93727. **/
  93728. disableManifestCheck: boolean;
  93729. /**
  93730. * Gets the list of created scenes
  93731. */
  93732. scenes: Scene[];
  93733. /**
  93734. * Event raised when a new scene is created
  93735. */
  93736. onNewSceneAddedObservable: Observable<Scene>;
  93737. /**
  93738. * Gets the list of created postprocesses
  93739. */
  93740. postProcesses: PostProcess[];
  93741. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93742. validateShaderPrograms: boolean;
  93743. /**
  93744. * Observable event triggered each time the rendering canvas is resized
  93745. */
  93746. onResizeObservable: Observable<Engine>;
  93747. /**
  93748. * Observable event triggered each time the canvas loses focus
  93749. */
  93750. onCanvasBlurObservable: Observable<Engine>;
  93751. /**
  93752. * Observable event triggered each time the canvas gains focus
  93753. */
  93754. onCanvasFocusObservable: Observable<Engine>;
  93755. /**
  93756. * Observable event triggered each time the canvas receives pointerout event
  93757. */
  93758. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93759. /**
  93760. * Observable event triggered before each texture is initialized
  93761. */
  93762. onBeforeTextureInitObservable: Observable<Texture>;
  93763. /**
  93764. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93765. */
  93766. disableUniformBuffers: boolean;
  93767. /** @hidden */
  93768. _uniformBuffers: UniformBuffer[];
  93769. /**
  93770. * Gets a boolean indicating that the engine supports uniform buffers
  93771. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93772. */
  93773. readonly supportsUniformBuffers: boolean;
  93774. /**
  93775. * Observable raised when the engine begins a new frame
  93776. */
  93777. onBeginFrameObservable: Observable<Engine>;
  93778. /**
  93779. * If set, will be used to request the next animation frame for the render loop
  93780. */
  93781. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93782. /**
  93783. * Observable raised when the engine ends the current frame
  93784. */
  93785. onEndFrameObservable: Observable<Engine>;
  93786. /**
  93787. * Observable raised when the engine is about to compile a shader
  93788. */
  93789. onBeforeShaderCompilationObservable: Observable<Engine>;
  93790. /**
  93791. * Observable raised when the engine has jsut compiled a shader
  93792. */
  93793. onAfterShaderCompilationObservable: Observable<Engine>;
  93794. /** @hidden */
  93795. _gl: WebGLRenderingContext;
  93796. private _renderingCanvas;
  93797. private _windowIsBackground;
  93798. private _webGLVersion;
  93799. protected _highPrecisionShadersAllowed: boolean;
  93800. /** @hidden */
  93801. readonly _shouldUseHighPrecisionShader: boolean;
  93802. /**
  93803. * Gets a boolean indicating that only power of 2 textures are supported
  93804. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93805. */
  93806. readonly needPOTTextures: boolean;
  93807. /** @hidden */
  93808. _badOS: boolean;
  93809. /** @hidden */
  93810. _badDesktopOS: boolean;
  93811. /**
  93812. * Gets the audio engine
  93813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93814. * @ignorenaming
  93815. */
  93816. static audioEngine: IAudioEngine;
  93817. /**
  93818. * Default AudioEngine factory responsible of creating the Audio Engine.
  93819. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93820. */
  93821. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93822. /**
  93823. * Default offline support factory responsible of creating a tool used to store data locally.
  93824. * By default, this will create a Database object if the workload has been embedded.
  93825. */
  93826. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93827. private _onFocus;
  93828. private _onBlur;
  93829. private _onCanvasPointerOut;
  93830. private _onCanvasBlur;
  93831. private _onCanvasFocus;
  93832. private _onFullscreenChange;
  93833. private _onPointerLockChange;
  93834. private _hardwareScalingLevel;
  93835. /** @hidden */
  93836. _caps: EngineCapabilities;
  93837. private _pointerLockRequested;
  93838. private _isStencilEnable;
  93839. private _colorWrite;
  93840. private _loadingScreen;
  93841. /** @hidden */
  93842. _drawCalls: PerfCounter;
  93843. private _glVersion;
  93844. private _glRenderer;
  93845. private _glVendor;
  93846. private _videoTextureSupported;
  93847. private _renderingQueueLaunched;
  93848. private _activeRenderLoops;
  93849. private _deterministicLockstep;
  93850. private _lockstepMaxSteps;
  93851. /**
  93852. * Observable signaled when a context lost event is raised
  93853. */
  93854. onContextLostObservable: Observable<Engine>;
  93855. /**
  93856. * Observable signaled when a context restored event is raised
  93857. */
  93858. onContextRestoredObservable: Observable<Engine>;
  93859. private _onContextLost;
  93860. private _onContextRestored;
  93861. private _contextWasLost;
  93862. /** @hidden */
  93863. _doNotHandleContextLost: boolean;
  93864. /**
  93865. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  93866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  93867. */
  93868. doNotHandleContextLost: boolean;
  93869. private _performanceMonitor;
  93870. private _fps;
  93871. private _deltaTime;
  93872. /**
  93873. * Turn this value on if you want to pause FPS computation when in background
  93874. */
  93875. disablePerformanceMonitorInBackground: boolean;
  93876. /**
  93877. * Gets the performance monitor attached to this engine
  93878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  93879. */
  93880. readonly performanceMonitor: PerformanceMonitor;
  93881. /**
  93882. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  93883. */
  93884. disableVertexArrayObjects: boolean;
  93885. /** @hidden */
  93886. protected _depthCullingState: _DepthCullingState;
  93887. /** @hidden */
  93888. protected _stencilState: _StencilState;
  93889. /** @hidden */
  93890. protected _alphaState: _AlphaState;
  93891. /** @hidden */
  93892. protected _alphaMode: number;
  93893. /** @hidden */
  93894. _internalTexturesCache: InternalTexture[];
  93895. /** @hidden */
  93896. protected _activeChannel: number;
  93897. private _currentTextureChannel;
  93898. /** @hidden */
  93899. protected _boundTexturesCache: {
  93900. [key: string]: Nullable<InternalTexture>;
  93901. };
  93902. /** @hidden */
  93903. protected _currentEffect: Nullable<Effect>;
  93904. /** @hidden */
  93905. protected _currentProgram: Nullable<WebGLProgram>;
  93906. private _compiledEffects;
  93907. private _vertexAttribArraysEnabled;
  93908. /** @hidden */
  93909. protected _cachedViewport: Nullable<IViewportLike>;
  93910. private _cachedVertexArrayObject;
  93911. /** @hidden */
  93912. protected _cachedVertexBuffers: any;
  93913. /** @hidden */
  93914. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  93915. /** @hidden */
  93916. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  93917. /** @hidden */
  93918. _currentRenderTarget: Nullable<InternalTexture>;
  93919. private _uintIndicesCurrentlySet;
  93920. private _currentBoundBuffer;
  93921. /** @hidden */
  93922. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  93923. private _currentBufferPointers;
  93924. private _currentInstanceLocations;
  93925. private _currentInstanceBuffers;
  93926. private _textureUnits;
  93927. /** @hidden */
  93928. _workingCanvas: Nullable<HTMLCanvasElement>;
  93929. /** @hidden */
  93930. _workingContext: Nullable<CanvasRenderingContext2D>;
  93931. private _rescalePostProcess;
  93932. private _dummyFramebuffer;
  93933. private _externalData;
  93934. /** @hidden */
  93935. _bindedRenderFunction: any;
  93936. private _vaoRecordInProgress;
  93937. private _mustWipeVertexAttributes;
  93938. private _emptyTexture;
  93939. private _emptyCubeTexture;
  93940. private _emptyTexture3D;
  93941. /** @hidden */
  93942. _frameHandler: number;
  93943. private _nextFreeTextureSlots;
  93944. private _maxSimultaneousTextures;
  93945. private _activeRequests;
  93946. private _texturesSupported;
  93947. /** @hidden */
  93948. _textureFormatInUse: Nullable<string>;
  93949. /**
  93950. * Gets the list of texture formats supported
  93951. */
  93952. readonly texturesSupported: Array<string>;
  93953. /**
  93954. * Gets the list of texture formats in use
  93955. */
  93956. readonly textureFormatInUse: Nullable<string>;
  93957. /**
  93958. * Gets the current viewport
  93959. */
  93960. readonly currentViewport: Nullable<IViewportLike>;
  93961. /**
  93962. * Gets the default empty texture
  93963. */
  93964. readonly emptyTexture: InternalTexture;
  93965. /**
  93966. * Gets the default empty 3D texture
  93967. */
  93968. readonly emptyTexture3D: InternalTexture;
  93969. /**
  93970. * Gets the default empty cube texture
  93971. */
  93972. readonly emptyCubeTexture: InternalTexture;
  93973. /**
  93974. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  93975. */
  93976. readonly premultipliedAlpha: boolean;
  93977. /**
  93978. * Creates a new engine
  93979. * @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
  93980. * @param antialias defines enable antialiasing (default: false)
  93981. * @param options defines further options to be sent to the getContext() function
  93982. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  93983. */
  93984. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  93985. /**
  93986. * Initializes a webVR display and starts listening to display change events
  93987. * The onVRDisplayChangedObservable will be notified upon these changes
  93988. * @returns The onVRDisplayChangedObservable
  93989. */
  93990. initWebVR(): Observable<IDisplayChangedEventArgs>;
  93991. /** @hidden */
  93992. _prepareVRComponent(): void;
  93993. /** @hidden */
  93994. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  93995. /** @hidden */
  93996. _submitVRFrame(): void;
  93997. /**
  93998. * Call this function to leave webVR mode
  93999. * Will do nothing if webVR is not supported or if there is no webVR device
  94000. * @see http://doc.babylonjs.com/how_to/webvr_camera
  94001. */
  94002. disableVR(): void;
  94003. /**
  94004. * Gets a boolean indicating that the system is in VR mode and is presenting
  94005. * @returns true if VR mode is engaged
  94006. */
  94007. isVRPresenting(): boolean;
  94008. /** @hidden */
  94009. _requestVRFrame(): void;
  94010. private _disableTouchAction;
  94011. private _rebuildInternalTextures;
  94012. private _rebuildEffects;
  94013. /**
  94014. * Gets a boolean indicating if all created effects are ready
  94015. * @returns true if all effects are ready
  94016. */
  94017. areAllEffectsReady(): boolean;
  94018. private _rebuildBuffers;
  94019. private _initGLContext;
  94020. /**
  94021. * Gets version of the current webGL context
  94022. */
  94023. readonly webGLVersion: number;
  94024. /**
  94025. * Gets a string idenfifying the name of the class
  94026. * @returns "Engine" string
  94027. */
  94028. getClassName(): string;
  94029. /**
  94030. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  94031. */
  94032. readonly isStencilEnable: boolean;
  94033. /** @hidden */
  94034. _prepareWorkingCanvas(): void;
  94035. /**
  94036. * Reset the texture cache to empty state
  94037. */
  94038. resetTextureCache(): void;
  94039. /**
  94040. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94041. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94042. * @returns true if engine is in deterministic lock step mode
  94043. */
  94044. isDeterministicLockStep(): boolean;
  94045. /**
  94046. * Gets the max steps when engine is running in deterministic lock step
  94047. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94048. * @returns the max steps
  94049. */
  94050. getLockstepMaxSteps(): number;
  94051. /**
  94052. * Gets an object containing information about the current webGL context
  94053. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94054. */
  94055. getGlInfo(): {
  94056. vendor: string;
  94057. renderer: string;
  94058. version: string;
  94059. };
  94060. /**
  94061. * Gets current aspect ratio
  94062. * @param viewportOwner defines the camera to use to get the aspect ratio
  94063. * @param useScreen defines if screen size must be used (or the current render target if any)
  94064. * @returns a number defining the aspect ratio
  94065. */
  94066. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94067. /**
  94068. * Gets current screen aspect ratio
  94069. * @returns a number defining the aspect ratio
  94070. */
  94071. getScreenAspectRatio(): number;
  94072. /**
  94073. * Gets the current render width
  94074. * @param useScreen defines if screen size must be used (or the current render target if any)
  94075. * @returns a number defining the current render width
  94076. */
  94077. getRenderWidth(useScreen?: boolean): number;
  94078. /**
  94079. * Gets the current render height
  94080. * @param useScreen defines if screen size must be used (or the current render target if any)
  94081. * @returns a number defining the current render height
  94082. */
  94083. getRenderHeight(useScreen?: boolean): number;
  94084. /**
  94085. * Gets the HTML canvas attached with the current webGL context
  94086. * @returns a HTML canvas
  94087. */
  94088. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94089. /**
  94090. * Gets the client rect of the HTML canvas attached with the current webGL context
  94091. * @returns a client rectanglee
  94092. */
  94093. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94094. /**
  94095. * Defines the hardware scaling level.
  94096. * By default the hardware scaling level is computed from the window device ratio.
  94097. * 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.
  94098. * @param level defines the level to use
  94099. */
  94100. setHardwareScalingLevel(level: number): void;
  94101. /**
  94102. * Gets the current hardware scaling level.
  94103. * By default the hardware scaling level is computed from the window device ratio.
  94104. * 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.
  94105. * @returns a number indicating the current hardware scaling level
  94106. */
  94107. getHardwareScalingLevel(): number;
  94108. /**
  94109. * Gets the list of loaded textures
  94110. * @returns an array containing all loaded textures
  94111. */
  94112. getLoadedTexturesCache(): InternalTexture[];
  94113. /**
  94114. * Gets the object containing all engine capabilities
  94115. * @returns the EngineCapabilities object
  94116. */
  94117. getCaps(): EngineCapabilities;
  94118. /**
  94119. * Gets the current depth function
  94120. * @returns a number defining the depth function
  94121. */
  94122. getDepthFunction(): Nullable<number>;
  94123. /**
  94124. * Sets the current depth function
  94125. * @param depthFunc defines the function to use
  94126. */
  94127. setDepthFunction(depthFunc: number): void;
  94128. /**
  94129. * Sets the current depth function to GREATER
  94130. */
  94131. setDepthFunctionToGreater(): void;
  94132. /**
  94133. * Sets the current depth function to GEQUAL
  94134. */
  94135. setDepthFunctionToGreaterOrEqual(): void;
  94136. /**
  94137. * Sets the current depth function to LESS
  94138. */
  94139. setDepthFunctionToLess(): void;
  94140. private _cachedStencilBuffer;
  94141. private _cachedStencilFunction;
  94142. private _cachedStencilMask;
  94143. private _cachedStencilOperationPass;
  94144. private _cachedStencilOperationFail;
  94145. private _cachedStencilOperationDepthFail;
  94146. private _cachedStencilReference;
  94147. /**
  94148. * Caches the the state of the stencil buffer
  94149. */
  94150. cacheStencilState(): void;
  94151. /**
  94152. * Restores the state of the stencil buffer
  94153. */
  94154. restoreStencilState(): void;
  94155. /**
  94156. * Sets the current depth function to LEQUAL
  94157. */
  94158. setDepthFunctionToLessOrEqual(): void;
  94159. /**
  94160. * Gets a boolean indicating if stencil buffer is enabled
  94161. * @returns the current stencil buffer state
  94162. */
  94163. getStencilBuffer(): boolean;
  94164. /**
  94165. * Enable or disable the stencil buffer
  94166. * @param enable defines if the stencil buffer must be enabled or disabled
  94167. */
  94168. setStencilBuffer(enable: boolean): void;
  94169. /**
  94170. * Gets the current stencil mask
  94171. * @returns a number defining the new stencil mask to use
  94172. */
  94173. getStencilMask(): number;
  94174. /**
  94175. * Sets the current stencil mask
  94176. * @param mask defines the new stencil mask to use
  94177. */
  94178. setStencilMask(mask: number): void;
  94179. /**
  94180. * Gets the current stencil function
  94181. * @returns a number defining the stencil function to use
  94182. */
  94183. getStencilFunction(): number;
  94184. /**
  94185. * Gets the current stencil reference value
  94186. * @returns a number defining the stencil reference value to use
  94187. */
  94188. getStencilFunctionReference(): number;
  94189. /**
  94190. * Gets the current stencil mask
  94191. * @returns a number defining the stencil mask to use
  94192. */
  94193. getStencilFunctionMask(): number;
  94194. /**
  94195. * Sets the current stencil function
  94196. * @param stencilFunc defines the new stencil function to use
  94197. */
  94198. setStencilFunction(stencilFunc: number): void;
  94199. /**
  94200. * Sets the current stencil reference
  94201. * @param reference defines the new stencil reference to use
  94202. */
  94203. setStencilFunctionReference(reference: number): void;
  94204. /**
  94205. * Sets the current stencil mask
  94206. * @param mask defines the new stencil mask to use
  94207. */
  94208. setStencilFunctionMask(mask: number): void;
  94209. /**
  94210. * Gets the current stencil operation when stencil fails
  94211. * @returns a number defining stencil operation to use when stencil fails
  94212. */
  94213. getStencilOperationFail(): number;
  94214. /**
  94215. * Gets the current stencil operation when depth fails
  94216. * @returns a number defining stencil operation to use when depth fails
  94217. */
  94218. getStencilOperationDepthFail(): number;
  94219. /**
  94220. * Gets the current stencil operation when stencil passes
  94221. * @returns a number defining stencil operation to use when stencil passes
  94222. */
  94223. getStencilOperationPass(): number;
  94224. /**
  94225. * Sets the stencil operation to use when stencil fails
  94226. * @param operation defines the stencil operation to use when stencil fails
  94227. */
  94228. setStencilOperationFail(operation: number): void;
  94229. /**
  94230. * Sets the stencil operation to use when depth fails
  94231. * @param operation defines the stencil operation to use when depth fails
  94232. */
  94233. setStencilOperationDepthFail(operation: number): void;
  94234. /**
  94235. * Sets the stencil operation to use when stencil passes
  94236. * @param operation defines the stencil operation to use when stencil passes
  94237. */
  94238. setStencilOperationPass(operation: number): void;
  94239. /**
  94240. * Sets a boolean indicating if the dithering state is enabled or disabled
  94241. * @param value defines the dithering state
  94242. */
  94243. setDitheringState(value: boolean): void;
  94244. /**
  94245. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94246. * @param value defines the rasterizer state
  94247. */
  94248. setRasterizerState(value: boolean): void;
  94249. /**
  94250. * stop executing a render loop function and remove it from the execution array
  94251. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94252. */
  94253. stopRenderLoop(renderFunction?: () => void): void;
  94254. /** @hidden */
  94255. _renderLoop(): void;
  94256. /**
  94257. * Register and execute a render loop. The engine can have more than one render function
  94258. * @param renderFunction defines the function to continuously execute
  94259. */
  94260. runRenderLoop(renderFunction: () => void): void;
  94261. /**
  94262. * Toggle full screen mode
  94263. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94264. */
  94265. switchFullscreen(requestPointerLock: boolean): void;
  94266. /**
  94267. * Enters full screen mode
  94268. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94269. */
  94270. enterFullscreen(requestPointerLock: boolean): void;
  94271. /**
  94272. * Exits full screen mode
  94273. */
  94274. exitFullscreen(): void;
  94275. /**
  94276. * Enters Pointerlock mode
  94277. */
  94278. enterPointerlock(): void;
  94279. /**
  94280. * Exits Pointerlock mode
  94281. */
  94282. exitPointerlock(): void;
  94283. /**
  94284. * Clear the current render buffer or the current render target (if any is set up)
  94285. * @param color defines the color to use
  94286. * @param backBuffer defines if the back buffer must be cleared
  94287. * @param depth defines if the depth buffer must be cleared
  94288. * @param stencil defines if the stencil buffer must be cleared
  94289. */
  94290. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94291. /**
  94292. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94293. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94294. * @param y defines the y-coordinate of the corner of the clear rectangle
  94295. * @param width defines the width of the clear rectangle
  94296. * @param height defines the height of the clear rectangle
  94297. * @param clearColor defines the clear color
  94298. */
  94299. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94300. /**
  94301. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94302. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94303. * @param y defines the y-coordinate of the corner of the clear rectangle
  94304. * @param width defines the width of the clear rectangle
  94305. * @param height defines the height of the clear rectangle
  94306. */
  94307. enableScissor(x: number, y: number, width: number, height: number): void;
  94308. /**
  94309. * Disable previously set scissor test rectangle
  94310. */
  94311. disableScissor(): void;
  94312. private _viewportCached;
  94313. /** @hidden */
  94314. _viewport(x: number, y: number, width: number, height: number): void;
  94315. /**
  94316. * Set the WebGL's viewport
  94317. * @param viewport defines the viewport element to be used
  94318. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94319. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94320. */
  94321. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94322. /**
  94323. * Directly set the WebGL Viewport
  94324. * @param x defines the x coordinate of the viewport (in screen space)
  94325. * @param y defines the y coordinate of the viewport (in screen space)
  94326. * @param width defines the width of the viewport (in screen space)
  94327. * @param height defines the height of the viewport (in screen space)
  94328. * @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
  94329. */
  94330. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94331. /**
  94332. * Begin a new frame
  94333. */
  94334. beginFrame(): void;
  94335. /**
  94336. * Enf the current frame
  94337. */
  94338. endFrame(): void;
  94339. /**
  94340. * Resize the view according to the canvas' size
  94341. */
  94342. resize(): void;
  94343. /**
  94344. * Force a specific size of the canvas
  94345. * @param width defines the new canvas' width
  94346. * @param height defines the new canvas' height
  94347. */
  94348. setSize(width: number, height: number): void;
  94349. /**
  94350. * Binds the frame buffer to the specified texture.
  94351. * @param texture The texture to render to or null for the default canvas
  94352. * @param faceIndex The face of the texture to render to in case of cube texture
  94353. * @param requiredWidth The width of the target to render to
  94354. * @param requiredHeight The height of the target to render to
  94355. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94356. * @param depthStencilTexture The depth stencil texture to use to render
  94357. * @param lodLevel defines le lod level to bind to the frame buffer
  94358. */
  94359. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94360. /** @hidden */
  94361. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94362. /**
  94363. * Unbind the current render target texture from the webGL context
  94364. * @param texture defines the render target texture to unbind
  94365. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94366. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94367. */
  94368. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94369. /**
  94370. * Force the mipmap generation for the given render target texture
  94371. * @param texture defines the render target texture to use
  94372. */
  94373. generateMipMapsForCubemap(texture: InternalTexture): void;
  94374. /**
  94375. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94376. */
  94377. flushFramebuffer(): void;
  94378. /**
  94379. * Unbind the current render target and bind the default framebuffer
  94380. */
  94381. restoreDefaultFramebuffer(): void;
  94382. /**
  94383. * Create an uniform buffer
  94384. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94385. * @param elements defines the content of the uniform buffer
  94386. * @returns the webGL uniform buffer
  94387. */
  94388. createUniformBuffer(elements: FloatArray): DataBuffer;
  94389. /**
  94390. * Create a dynamic uniform buffer
  94391. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94392. * @param elements defines the content of the uniform buffer
  94393. * @returns the webGL uniform buffer
  94394. */
  94395. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94396. /**
  94397. * Update an existing uniform buffer
  94398. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94399. * @param uniformBuffer defines the target uniform buffer
  94400. * @param elements defines the content to update
  94401. * @param offset defines the offset in the uniform buffer where update should start
  94402. * @param count defines the size of the data to update
  94403. */
  94404. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94405. private _resetVertexBufferBinding;
  94406. /**
  94407. * Creates a vertex buffer
  94408. * @param data the data for the vertex buffer
  94409. * @returns the new WebGL static buffer
  94410. */
  94411. createVertexBuffer(data: DataArray): DataBuffer;
  94412. /**
  94413. * Creates a dynamic vertex buffer
  94414. * @param data the data for the dynamic vertex buffer
  94415. * @returns the new WebGL dynamic buffer
  94416. */
  94417. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94418. /**
  94419. * Update a dynamic index buffer
  94420. * @param indexBuffer defines the target index buffer
  94421. * @param indices defines the data to update
  94422. * @param offset defines the offset in the target index buffer where update should start
  94423. */
  94424. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94425. /**
  94426. * Updates a dynamic vertex buffer.
  94427. * @param vertexBuffer the vertex buffer to update
  94428. * @param data the data used to update the vertex buffer
  94429. * @param byteOffset the byte offset of the data
  94430. * @param byteLength the byte length of the data
  94431. */
  94432. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94433. private _resetIndexBufferBinding;
  94434. /**
  94435. * Creates a new index buffer
  94436. * @param indices defines the content of the index buffer
  94437. * @param updatable defines if the index buffer must be updatable
  94438. * @returns a new webGL buffer
  94439. */
  94440. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94441. /**
  94442. * Bind a webGL buffer to the webGL context
  94443. * @param buffer defines the buffer to bind
  94444. */
  94445. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94446. /**
  94447. * Bind an uniform buffer to the current webGL context
  94448. * @param buffer defines the buffer to bind
  94449. */
  94450. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94451. /**
  94452. * Bind a buffer to the current webGL context at a given location
  94453. * @param buffer defines the buffer to bind
  94454. * @param location defines the index where to bind the buffer
  94455. */
  94456. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94457. /**
  94458. * Bind a specific block at a given index in a specific shader program
  94459. * @param pipelineContext defines the pipeline context to use
  94460. * @param blockName defines the block name
  94461. * @param index defines the index where to bind the block
  94462. */
  94463. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94464. private bindIndexBuffer;
  94465. private bindBuffer;
  94466. /**
  94467. * update the bound buffer with the given data
  94468. * @param data defines the data to update
  94469. */
  94470. updateArrayBuffer(data: Float32Array): void;
  94471. private _vertexAttribPointer;
  94472. private _bindIndexBufferWithCache;
  94473. private _bindVertexBuffersAttributes;
  94474. /**
  94475. * Records a vertex array object
  94476. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94477. * @param vertexBuffers defines the list of vertex buffers to store
  94478. * @param indexBuffer defines the index buffer to store
  94479. * @param effect defines the effect to store
  94480. * @returns the new vertex array object
  94481. */
  94482. recordVertexArrayObject(vertexBuffers: {
  94483. [key: string]: VertexBuffer;
  94484. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94485. /**
  94486. * Bind a specific vertex array object
  94487. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94488. * @param vertexArrayObject defines the vertex array object to bind
  94489. * @param indexBuffer defines the index buffer to bind
  94490. */
  94491. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94492. /**
  94493. * Bind webGl buffers directly to the webGL context
  94494. * @param vertexBuffer defines the vertex buffer to bind
  94495. * @param indexBuffer defines the index buffer to bind
  94496. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94497. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94498. * @param effect defines the effect associated with the vertex buffer
  94499. */
  94500. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94501. private _unbindVertexArrayObject;
  94502. /**
  94503. * Bind a list of vertex buffers to the webGL context
  94504. * @param vertexBuffers defines the list of vertex buffers to bind
  94505. * @param indexBuffer defines the index buffer to bind
  94506. * @param effect defines the effect associated with the vertex buffers
  94507. */
  94508. bindBuffers(vertexBuffers: {
  94509. [key: string]: Nullable<VertexBuffer>;
  94510. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94511. /**
  94512. * Unbind all instance attributes
  94513. */
  94514. unbindInstanceAttributes(): void;
  94515. /**
  94516. * Release and free the memory of a vertex array object
  94517. * @param vao defines the vertex array object to delete
  94518. */
  94519. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94520. /** @hidden */
  94521. _releaseBuffer(buffer: DataBuffer): boolean;
  94522. /**
  94523. * Creates a webGL buffer to use with instanciation
  94524. * @param capacity defines the size of the buffer
  94525. * @returns the webGL buffer
  94526. */
  94527. createInstancesBuffer(capacity: number): DataBuffer;
  94528. /**
  94529. * Delete a webGL buffer used with instanciation
  94530. * @param buffer defines the webGL buffer to delete
  94531. */
  94532. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94533. /**
  94534. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94535. * @param instancesBuffer defines the webGL buffer to update and bind
  94536. * @param data defines the data to store in the buffer
  94537. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94538. */
  94539. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94540. /**
  94541. * Apply all cached states (depth, culling, stencil and alpha)
  94542. */
  94543. applyStates(): void;
  94544. /**
  94545. * Send a draw order
  94546. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94547. * @param indexStart defines the starting index
  94548. * @param indexCount defines the number of index to draw
  94549. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94550. */
  94551. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94552. /**
  94553. * Draw a list of points
  94554. * @param verticesStart defines the index of first vertex to draw
  94555. * @param verticesCount defines the count of vertices to draw
  94556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94557. */
  94558. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94559. /**
  94560. * Draw a list of unindexed primitives
  94561. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94562. * @param verticesStart defines the index of first vertex to draw
  94563. * @param verticesCount defines the count of vertices to draw
  94564. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94565. */
  94566. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94567. /**
  94568. * Draw a list of indexed primitives
  94569. * @param fillMode defines the primitive to use
  94570. * @param indexStart defines the starting index
  94571. * @param indexCount defines the number of index to draw
  94572. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94573. */
  94574. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94575. /**
  94576. * Draw a list of unindexed primitives
  94577. * @param fillMode defines the primitive to use
  94578. * @param verticesStart defines the index of first vertex to draw
  94579. * @param verticesCount defines the count of vertices to draw
  94580. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94581. */
  94582. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94583. private _drawMode;
  94584. /** @hidden */
  94585. _releaseEffect(effect: Effect): void;
  94586. /** @hidden */
  94587. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94588. /**
  94589. * Create a new effect (used to store vertex/fragment shaders)
  94590. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94591. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94592. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94593. * @param samplers defines an array of string used to represent textures
  94594. * @param defines defines the string containing the defines to use to compile the shaders
  94595. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94596. * @param onCompiled defines a function to call when the effect creation is successful
  94597. * @param onError defines a function to call when the effect creation has failed
  94598. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94599. * @returns the new Effect
  94600. */
  94601. 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;
  94602. private _compileShader;
  94603. private _compileRawShader;
  94604. /**
  94605. * Directly creates a webGL program
  94606. * @param pipelineContext defines the pipeline context to attach to
  94607. * @param vertexCode defines the vertex shader code to use
  94608. * @param fragmentCode defines the fragment shader code to use
  94609. * @param context defines the webGL context to use (if not set, the current one will be used)
  94610. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94611. * @returns the new webGL program
  94612. */
  94613. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94614. /**
  94615. * Creates a webGL program
  94616. * @param pipelineContext defines the pipeline context to attach to
  94617. * @param vertexCode defines the vertex shader code to use
  94618. * @param fragmentCode defines the fragment shader code to use
  94619. * @param defines defines the string containing the defines to use to compile the shaders
  94620. * @param context defines the webGL context to use (if not set, the current one will be used)
  94621. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94622. * @returns the new webGL program
  94623. */
  94624. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94625. /**
  94626. * Creates a new pipeline context
  94627. * @returns the new pipeline
  94628. */
  94629. createPipelineContext(): WebGLPipelineContext;
  94630. private _createShaderProgram;
  94631. private _finalizePipelineContext;
  94632. /** @hidden */
  94633. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94634. /** @hidden */
  94635. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94636. /** @hidden */
  94637. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94638. /**
  94639. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94640. * @param pipelineContext defines the pipeline context to use
  94641. * @param uniformsNames defines the list of uniform names
  94642. * @returns an array of webGL uniform locations
  94643. */
  94644. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94645. /**
  94646. * Gets the lsit of active attributes for a given webGL program
  94647. * @param pipelineContext defines the pipeline context to use
  94648. * @param attributesNames defines the list of attribute names to get
  94649. * @returns an array of indices indicating the offset of each attribute
  94650. */
  94651. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94652. /**
  94653. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94654. * @param effect defines the effect to activate
  94655. */
  94656. enableEffect(effect: Nullable<Effect>): void;
  94657. /**
  94658. * Set the value of an uniform to an array of int32
  94659. * @param uniform defines the webGL uniform location where to store the value
  94660. * @param array defines the array of int32 to store
  94661. */
  94662. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94663. /**
  94664. * Set the value of an uniform to an array of int32 (stored as vec2)
  94665. * @param uniform defines the webGL uniform location where to store the value
  94666. * @param array defines the array of int32 to store
  94667. */
  94668. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94669. /**
  94670. * Set the value of an uniform to an array of int32 (stored as vec3)
  94671. * @param uniform defines the webGL uniform location where to store the value
  94672. * @param array defines the array of int32 to store
  94673. */
  94674. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94675. /**
  94676. * Set the value of an uniform to an array of int32 (stored as vec4)
  94677. * @param uniform defines the webGL uniform location where to store the value
  94678. * @param array defines the array of int32 to store
  94679. */
  94680. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94681. /**
  94682. * Set the value of an uniform to an array of float32
  94683. * @param uniform defines the webGL uniform location where to store the value
  94684. * @param array defines the array of float32 to store
  94685. */
  94686. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94687. /**
  94688. * Set the value of an uniform to an array of float32 (stored as vec2)
  94689. * @param uniform defines the webGL uniform location where to store the value
  94690. * @param array defines the array of float32 to store
  94691. */
  94692. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94693. /**
  94694. * Set the value of an uniform to an array of float32 (stored as vec3)
  94695. * @param uniform defines the webGL uniform location where to store the value
  94696. * @param array defines the array of float32 to store
  94697. */
  94698. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94699. /**
  94700. * Set the value of an uniform to an array of float32 (stored as vec4)
  94701. * @param uniform defines the webGL uniform location where to store the value
  94702. * @param array defines the array of float32 to store
  94703. */
  94704. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94705. /**
  94706. * Set the value of an uniform to an array of number
  94707. * @param uniform defines the webGL uniform location where to store the value
  94708. * @param array defines the array of number to store
  94709. */
  94710. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94711. /**
  94712. * Set the value of an uniform to an array of number (stored as vec2)
  94713. * @param uniform defines the webGL uniform location where to store the value
  94714. * @param array defines the array of number to store
  94715. */
  94716. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94717. /**
  94718. * Set the value of an uniform to an array of number (stored as vec3)
  94719. * @param uniform defines the webGL uniform location where to store the value
  94720. * @param array defines the array of number to store
  94721. */
  94722. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94723. /**
  94724. * Set the value of an uniform to an array of number (stored as vec4)
  94725. * @param uniform defines the webGL uniform location where to store the value
  94726. * @param array defines the array of number to store
  94727. */
  94728. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94729. /**
  94730. * Set the value of an uniform to an array of float32 (stored as matrices)
  94731. * @param uniform defines the webGL uniform location where to store the value
  94732. * @param matrices defines the array of float32 to store
  94733. */
  94734. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94735. /**
  94736. * Set the value of an uniform to a matrix (3x3)
  94737. * @param uniform defines the webGL uniform location where to store the value
  94738. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94739. */
  94740. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94741. /**
  94742. * Set the value of an uniform to a matrix (2x2)
  94743. * @param uniform defines the webGL uniform location where to store the value
  94744. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94745. */
  94746. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94747. /**
  94748. * Set the value of an uniform to a number (int)
  94749. * @param uniform defines the webGL uniform location where to store the value
  94750. * @param value defines the int number to store
  94751. */
  94752. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94753. /**
  94754. * Set the value of an uniform to a number (float)
  94755. * @param uniform defines the webGL uniform location where to store the value
  94756. * @param value defines the float number to store
  94757. */
  94758. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94759. /**
  94760. * Set the value of an uniform to a vec2
  94761. * @param uniform defines the webGL uniform location where to store the value
  94762. * @param x defines the 1st component of the value
  94763. * @param y defines the 2nd component of the value
  94764. */
  94765. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94766. /**
  94767. * Set the value of an uniform to a vec3
  94768. * @param uniform defines the webGL uniform location where to store the value
  94769. * @param x defines the 1st component of the value
  94770. * @param y defines the 2nd component of the value
  94771. * @param z defines the 3rd component of the value
  94772. */
  94773. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94774. /**
  94775. * Set the value of an uniform to a boolean
  94776. * @param uniform defines the webGL uniform location where to store the value
  94777. * @param bool defines the boolean to store
  94778. */
  94779. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94780. /**
  94781. * Set the value of an uniform to a vec4
  94782. * @param uniform defines the webGL uniform location where to store the value
  94783. * @param x defines the 1st component of the value
  94784. * @param y defines the 2nd component of the value
  94785. * @param z defines the 3rd component of the value
  94786. * @param w defines the 4th component of the value
  94787. */
  94788. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94789. /**
  94790. * Sets a Color4 on a uniform variable
  94791. * @param uniform defines the uniform location
  94792. * @param color4 defines the value to be set
  94793. */
  94794. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94795. /**
  94796. * Set various states to the webGL context
  94797. * @param culling defines backface culling state
  94798. * @param zOffset defines the value to apply to zOffset (0 by default)
  94799. * @param force defines if states must be applied even if cache is up to date
  94800. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94801. */
  94802. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94803. /**
  94804. * Set the z offset to apply to current rendering
  94805. * @param value defines the offset to apply
  94806. */
  94807. setZOffset(value: number): void;
  94808. /**
  94809. * Gets the current value of the zOffset
  94810. * @returns the current zOffset state
  94811. */
  94812. getZOffset(): number;
  94813. /**
  94814. * Enable or disable depth buffering
  94815. * @param enable defines the state to set
  94816. */
  94817. setDepthBuffer(enable: boolean): void;
  94818. /**
  94819. * Gets a boolean indicating if depth writing is enabled
  94820. * @returns the current depth writing state
  94821. */
  94822. getDepthWrite(): boolean;
  94823. /**
  94824. * Enable or disable depth writing
  94825. * @param enable defines the state to set
  94826. */
  94827. setDepthWrite(enable: boolean): void;
  94828. /**
  94829. * Enable or disable color writing
  94830. * @param enable defines the state to set
  94831. */
  94832. setColorWrite(enable: boolean): void;
  94833. /**
  94834. * Gets a boolean indicating if color writing is enabled
  94835. * @returns the current color writing state
  94836. */
  94837. getColorWrite(): boolean;
  94838. /**
  94839. * Sets alpha constants used by some alpha blending modes
  94840. * @param r defines the red component
  94841. * @param g defines the green component
  94842. * @param b defines the blue component
  94843. * @param a defines the alpha component
  94844. */
  94845. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  94846. /**
  94847. * Sets the current alpha mode
  94848. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  94849. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  94850. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94851. */
  94852. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  94853. /**
  94854. * Gets the current alpha mode
  94855. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94856. * @returns the current alpha mode
  94857. */
  94858. getAlphaMode(): number;
  94859. /**
  94860. * Clears the list of texture accessible through engine.
  94861. * This can help preventing texture load conflict due to name collision.
  94862. */
  94863. clearInternalTexturesCache(): void;
  94864. /**
  94865. * Force the entire cache to be cleared
  94866. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  94867. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  94868. */
  94869. wipeCaches(bruteForce?: boolean): void;
  94870. /**
  94871. * Set the compressed texture format to use, based on the formats you have, and the formats
  94872. * supported by the hardware / browser.
  94873. *
  94874. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  94875. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  94876. * to API arguments needed to compressed textures. This puts the burden on the container
  94877. * generator to house the arcane code for determining these for current & future formats.
  94878. *
  94879. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94880. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94881. *
  94882. * Note: The result of this call is not taken into account when a texture is base64.
  94883. *
  94884. * @param formatsAvailable defines the list of those format families you have created
  94885. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  94886. *
  94887. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  94888. * @returns The extension selected.
  94889. */
  94890. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  94891. /** @hidden */
  94892. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  94893. min: number;
  94894. mag: number;
  94895. };
  94896. /** @hidden */
  94897. _createTexture(): WebGLTexture;
  94898. /**
  94899. * Usually called from Texture.ts.
  94900. * Passed information to create a WebGLTexture
  94901. * @param urlArg defines a value which contains one of the following:
  94902. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  94903. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  94904. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  94905. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  94906. * @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)
  94907. * @param scene needed for loading to the correct scene
  94908. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  94909. * @param onLoad optional callback to be called upon successful completion
  94910. * @param onError optional callback to be called upon failure
  94911. * @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
  94912. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  94913. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  94914. * @param forcedExtension defines the extension to use to pick the right loader
  94915. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  94916. * @returns a InternalTexture for assignment back into BABYLON.Texture
  94917. */
  94918. 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;
  94919. /**
  94920. * @hidden
  94921. * Rescales a texture
  94922. * @param source input texutre
  94923. * @param destination destination texture
  94924. * @param scene scene to use to render the resize
  94925. * @param internalFormat format to use when resizing
  94926. * @param onComplete callback to be called when resize has completed
  94927. */
  94928. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  94929. private _unpackFlipYCached;
  94930. /**
  94931. * In case you are sharing the context with other applications, it might
  94932. * be interested to not cache the unpack flip y state to ensure a consistent
  94933. * value would be set.
  94934. */
  94935. enableUnpackFlipYCached: boolean;
  94936. /** @hidden */
  94937. _unpackFlipY(value: boolean): void;
  94938. /** @hidden */
  94939. _getUnpackAlignement(): number;
  94940. /**
  94941. * Creates a dynamic texture
  94942. * @param width defines the width of the texture
  94943. * @param height defines the height of the texture
  94944. * @param generateMipMaps defines if the engine should generate the mip levels
  94945. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  94946. * @returns the dynamic texture inside an InternalTexture
  94947. */
  94948. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  94949. /**
  94950. * Update the sampling mode of a given texture
  94951. * @param samplingMode defines the required sampling mode
  94952. * @param texture defines the texture to update
  94953. */
  94954. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  94955. /**
  94956. * Update the content of a dynamic texture
  94957. * @param texture defines the texture to update
  94958. * @param canvas defines the canvas containing the source
  94959. * @param invertY defines if data must be stored with Y axis inverted
  94960. * @param premulAlpha defines if alpha is stored as premultiplied
  94961. * @param format defines the format of the data
  94962. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  94963. */
  94964. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  94965. /**
  94966. * Update a video texture
  94967. * @param texture defines the texture to update
  94968. * @param video defines the video element to use
  94969. * @param invertY defines if data must be stored with Y axis inverted
  94970. */
  94971. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  94972. /**
  94973. * Updates a depth texture Comparison Mode and Function.
  94974. * If the comparison Function is equal to 0, the mode will be set to none.
  94975. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  94976. * @param texture The texture to set the comparison function for
  94977. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  94978. */
  94979. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  94980. /** @hidden */
  94981. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  94982. width: number;
  94983. height: number;
  94984. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  94985. /**
  94986. * Creates a depth stencil texture.
  94987. * This is only available in WebGL 2 or with the depth texture extension available.
  94988. * @param size The size of face edge in the texture.
  94989. * @param options The options defining the texture.
  94990. * @returns The texture
  94991. */
  94992. createDepthStencilTexture(size: number | {
  94993. width: number;
  94994. height: number;
  94995. }, options: DepthTextureCreationOptions): InternalTexture;
  94996. /**
  94997. * Creates a depth stencil texture.
  94998. * This is only available in WebGL 2 or with the depth texture extension available.
  94999. * @param size The size of face edge in the texture.
  95000. * @param options The options defining the texture.
  95001. * @returns The texture
  95002. */
  95003. private _createDepthStencilTexture;
  95004. /**
  95005. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  95006. * @param renderTarget The render target to set the frame buffer for
  95007. */
  95008. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  95009. /**
  95010. * Creates a new render target texture
  95011. * @param size defines the size of the texture
  95012. * @param options defines the options used to create the texture
  95013. * @returns a new render target texture stored in an InternalTexture
  95014. */
  95015. createRenderTargetTexture(size: number | {
  95016. width: number;
  95017. height: number;
  95018. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  95019. /** @hidden */
  95020. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  95021. /**
  95022. * Updates the sample count of a render target texture
  95023. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  95024. * @param texture defines the texture to update
  95025. * @param samples defines the sample count to set
  95026. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  95027. */
  95028. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  95029. /** @hidden */
  95030. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95031. /** @hidden */
  95032. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95033. /** @hidden */
  95034. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95035. /** @hidden */
  95036. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95037. /**
  95038. * @hidden
  95039. */
  95040. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95041. private _prepareWebGLTextureContinuation;
  95042. private _prepareWebGLTexture;
  95043. /** @hidden */
  95044. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95045. /** @hidden */
  95046. _releaseFramebufferObjects(texture: InternalTexture): void;
  95047. /** @hidden */
  95048. _releaseTexture(texture: InternalTexture): void;
  95049. private setProgram;
  95050. private _boundUniforms;
  95051. /**
  95052. * Binds an effect to the webGL context
  95053. * @param effect defines the effect to bind
  95054. */
  95055. bindSamplers(effect: Effect): void;
  95056. private _activateCurrentTexture;
  95057. /** @hidden */
  95058. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95059. /** @hidden */
  95060. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95061. /**
  95062. * Sets a texture to the webGL context from a postprocess
  95063. * @param channel defines the channel to use
  95064. * @param postProcess defines the source postprocess
  95065. */
  95066. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95067. /**
  95068. * Binds the output of the passed in post process to the texture channel specified
  95069. * @param channel The channel the texture should be bound to
  95070. * @param postProcess The post process which's output should be bound
  95071. */
  95072. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95073. /**
  95074. * Unbind all textures from the webGL context
  95075. */
  95076. unbindAllTextures(): void;
  95077. /**
  95078. * Sets a texture to the according uniform.
  95079. * @param channel The texture channel
  95080. * @param uniform The uniform to set
  95081. * @param texture The texture to apply
  95082. */
  95083. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95084. /**
  95085. * Sets a depth stencil texture from a render target to the according uniform.
  95086. * @param channel The texture channel
  95087. * @param uniform The uniform to set
  95088. * @param texture The render target texture containing the depth stencil texture to apply
  95089. */
  95090. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95091. private _bindSamplerUniformToChannel;
  95092. private _getTextureWrapMode;
  95093. private _setTexture;
  95094. /**
  95095. * Sets an array of texture to the webGL context
  95096. * @param channel defines the channel where the texture array must be set
  95097. * @param uniform defines the associated uniform location
  95098. * @param textures defines the array of textures to bind
  95099. */
  95100. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95101. /** @hidden */
  95102. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95103. private _setTextureParameterFloat;
  95104. private _setTextureParameterInteger;
  95105. /**
  95106. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95107. * @param x defines the x coordinate of the rectangle where pixels must be read
  95108. * @param y defines the y coordinate of the rectangle where pixels must be read
  95109. * @param width defines the width of the rectangle where pixels must be read
  95110. * @param height defines the height of the rectangle where pixels must be read
  95111. * @returns a Uint8Array containing RGBA colors
  95112. */
  95113. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95114. /**
  95115. * Add an externaly attached data from its key.
  95116. * This method call will fail and return false, if such key already exists.
  95117. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95118. * @param key the unique key that identifies the data
  95119. * @param data the data object to associate to the key for this Engine instance
  95120. * @return true if no such key were already present and the data was added successfully, false otherwise
  95121. */
  95122. addExternalData<T>(key: string, data: T): boolean;
  95123. /**
  95124. * Get an externaly attached data from its key
  95125. * @param key the unique key that identifies the data
  95126. * @return the associated data, if present (can be null), or undefined if not present
  95127. */
  95128. getExternalData<T>(key: string): T;
  95129. /**
  95130. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95131. * @param key the unique key that identifies the data
  95132. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95133. * @return the associated data, can be null if the factory returned null.
  95134. */
  95135. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95136. /**
  95137. * Remove an externaly attached data from the Engine instance
  95138. * @param key the unique key that identifies the data
  95139. * @return true if the data was successfully removed, false if it doesn't exist
  95140. */
  95141. removeExternalData(key: string): boolean;
  95142. /**
  95143. * Unbind all vertex attributes from the webGL context
  95144. */
  95145. unbindAllAttributes(): void;
  95146. /**
  95147. * 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
  95148. */
  95149. releaseEffects(): void;
  95150. /**
  95151. * Dispose and release all associated resources
  95152. */
  95153. dispose(): void;
  95154. /**
  95155. * Display the loading screen
  95156. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95157. */
  95158. displayLoadingUI(): void;
  95159. /**
  95160. * Hide the loading screen
  95161. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95162. */
  95163. hideLoadingUI(): void;
  95164. /**
  95165. * Gets the current loading screen object
  95166. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95167. */
  95168. /**
  95169. * Sets the current loading screen object
  95170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95171. */
  95172. loadingScreen: ILoadingScreen;
  95173. /**
  95174. * Sets the current loading screen text
  95175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95176. */
  95177. loadingUIText: string;
  95178. /**
  95179. * Sets the current loading screen background color
  95180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95181. */
  95182. loadingUIBackgroundColor: string;
  95183. /**
  95184. * Attach a new callback raised when context lost event is fired
  95185. * @param callback defines the callback to call
  95186. */
  95187. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95188. /**
  95189. * Attach a new callback raised when context restored event is fired
  95190. * @param callback defines the callback to call
  95191. */
  95192. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95193. /**
  95194. * Gets the source code of the vertex shader associated with a specific webGL program
  95195. * @param program defines the program to use
  95196. * @returns a string containing the source code of the vertex shader associated with the program
  95197. */
  95198. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95199. /**
  95200. * Gets the source code of the fragment shader associated with a specific webGL program
  95201. * @param program defines the program to use
  95202. * @returns a string containing the source code of the fragment shader associated with the program
  95203. */
  95204. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95205. /**
  95206. * Get the current error code of the webGL context
  95207. * @returns the error code
  95208. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95209. */
  95210. getError(): number;
  95211. /**
  95212. * Gets the current framerate
  95213. * @returns a number representing the framerate
  95214. */
  95215. getFps(): number;
  95216. /**
  95217. * Gets the time spent between current and previous frame
  95218. * @returns a number representing the delta time in ms
  95219. */
  95220. getDeltaTime(): number;
  95221. private _measureFps;
  95222. /** @hidden */
  95223. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95224. private _canRenderToFloatFramebuffer;
  95225. private _canRenderToHalfFloatFramebuffer;
  95226. private _canRenderToFramebuffer;
  95227. /** @hidden */
  95228. _getWebGLTextureType(type: number): number;
  95229. /** @hidden */
  95230. _getInternalFormat(format: number): number;
  95231. /** @hidden */
  95232. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95233. /** @hidden */
  95234. _getRGBAMultiSampleBufferFormat(type: number): number;
  95235. /** @hidden */
  95236. _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;
  95237. /** @hidden */
  95238. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95239. /**
  95240. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95241. * @returns true if the engine can be created
  95242. * @ignorenaming
  95243. */
  95244. static isSupported(): boolean;
  95245. /**
  95246. * Find the next highest power of two.
  95247. * @param x Number to start search from.
  95248. * @return Next highest power of two.
  95249. */
  95250. static CeilingPOT(x: number): number;
  95251. /**
  95252. * Find the next lowest power of two.
  95253. * @param x Number to start search from.
  95254. * @return Next lowest power of two.
  95255. */
  95256. static FloorPOT(x: number): number;
  95257. /**
  95258. * Find the nearest power of two.
  95259. * @param x Number to start search from.
  95260. * @return Next nearest power of two.
  95261. */
  95262. static NearestPOT(x: number): number;
  95263. /**
  95264. * Get the closest exponent of two
  95265. * @param value defines the value to approximate
  95266. * @param max defines the maximum value to return
  95267. * @param mode defines how to define the closest value
  95268. * @returns closest exponent of two of the given value
  95269. */
  95270. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95271. /**
  95272. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95273. * @param func - the function to be called
  95274. * @param requester - the object that will request the next frame. Falls back to window.
  95275. * @returns frame number
  95276. */
  95277. static QueueNewFrame(func: () => void, requester?: any): number;
  95278. /**
  95279. * Ask the browser to promote the current element to pointerlock mode
  95280. * @param element defines the DOM element to promote
  95281. */
  95282. static _RequestPointerlock(element: HTMLElement): void;
  95283. /**
  95284. * Asks the browser to exit pointerlock mode
  95285. */
  95286. static _ExitPointerlock(): void;
  95287. /**
  95288. * Ask the browser to promote the current element to fullscreen rendering mode
  95289. * @param element defines the DOM element to promote
  95290. */
  95291. static _RequestFullscreen(element: HTMLElement): void;
  95292. /**
  95293. * Asks the browser to exit fullscreen mode
  95294. */
  95295. static _ExitFullscreen(): void;
  95296. }
  95297. }
  95298. declare module BABYLON {
  95299. /**
  95300. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95301. * during the life time of the application.
  95302. */
  95303. export class EngineStore {
  95304. /** Gets the list of created engines */
  95305. static Instances: Engine[];
  95306. /** @hidden */
  95307. static _LastCreatedScene: Nullable<Scene>;
  95308. /**
  95309. * Gets the latest created engine
  95310. */
  95311. static readonly LastCreatedEngine: Nullable<Engine>;
  95312. /**
  95313. * Gets the latest created scene
  95314. */
  95315. static readonly LastCreatedScene: Nullable<Scene>;
  95316. /**
  95317. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95318. * @ignorenaming
  95319. */
  95320. static UseFallbackTexture: boolean;
  95321. /**
  95322. * Texture content used if a texture cannot loaded
  95323. * @ignorenaming
  95324. */
  95325. static FallbackTexture: string;
  95326. }
  95327. }
  95328. declare module BABYLON {
  95329. /**
  95330. * Helper class that provides a small promise polyfill
  95331. */
  95332. export class PromisePolyfill {
  95333. /**
  95334. * Static function used to check if the polyfill is required
  95335. * If this is the case then the function will inject the polyfill to window.Promise
  95336. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95337. */
  95338. static Apply(force?: boolean): void;
  95339. }
  95340. }
  95341. declare module BABYLON {
  95342. interface IColor4Like {
  95343. r: float;
  95344. g: float;
  95345. b: float;
  95346. a: float;
  95347. }
  95348. /**
  95349. * Class containing a set of static utilities functions
  95350. */
  95351. export class Tools {
  95352. /**
  95353. * Gets or sets the base URL to use to load assets
  95354. */
  95355. static BaseUrl: string;
  95356. /**
  95357. * Enable/Disable Custom HTTP Request Headers globally.
  95358. * default = false
  95359. * @see CustomRequestHeaders
  95360. */
  95361. static UseCustomRequestHeaders: boolean;
  95362. /**
  95363. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95364. * i.e. when loading files, where the server/service expects an Authorization header
  95365. */
  95366. static CustomRequestHeaders: {
  95367. [key: string]: string;
  95368. };
  95369. /**
  95370. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95371. */
  95372. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95373. /**
  95374. * Default behaviour for cors in the application.
  95375. * It can be a string if the expected behavior is identical in the entire app.
  95376. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95377. */
  95378. static CorsBehavior: string | ((url: string | string[]) => string);
  95379. /**
  95380. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95381. * @ignorenaming
  95382. */
  95383. static UseFallbackTexture: boolean;
  95384. /**
  95385. * Use this object to register external classes like custom textures or material
  95386. * to allow the laoders to instantiate them
  95387. */
  95388. static RegisteredExternalClasses: {
  95389. [key: string]: Object;
  95390. };
  95391. /**
  95392. * Texture content used if a texture cannot loaded
  95393. * @ignorenaming
  95394. */
  95395. static fallbackTexture: string;
  95396. /**
  95397. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95398. * @param u defines the coordinate on X axis
  95399. * @param v defines the coordinate on Y axis
  95400. * @param width defines the width of the source data
  95401. * @param height defines the height of the source data
  95402. * @param pixels defines the source byte array
  95403. * @param color defines the output color
  95404. */
  95405. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95406. /**
  95407. * Interpolates between a and b via alpha
  95408. * @param a The lower value (returned when alpha = 0)
  95409. * @param b The upper value (returned when alpha = 1)
  95410. * @param alpha The interpolation-factor
  95411. * @return The mixed value
  95412. */
  95413. static Mix(a: number, b: number, alpha: number): number;
  95414. /**
  95415. * Tries to instantiate a new object from a given class name
  95416. * @param className defines the class name to instantiate
  95417. * @returns the new object or null if the system was not able to do the instantiation
  95418. */
  95419. static Instantiate(className: string): any;
  95420. /**
  95421. * Provides a slice function that will work even on IE
  95422. * @param data defines the array to slice
  95423. * @param start defines the start of the data (optional)
  95424. * @param end defines the end of the data (optional)
  95425. * @returns the new sliced array
  95426. */
  95427. static Slice<T>(data: T, start?: number, end?: number): T;
  95428. /**
  95429. * Polyfill for setImmediate
  95430. * @param action defines the action to execute after the current execution block
  95431. */
  95432. static SetImmediate(action: () => void): void;
  95433. /**
  95434. * Function indicating if a number is an exponent of 2
  95435. * @param value defines the value to test
  95436. * @returns true if the value is an exponent of 2
  95437. */
  95438. static IsExponentOfTwo(value: number): boolean;
  95439. private static _tmpFloatArray;
  95440. /**
  95441. * Returns the nearest 32-bit single precision float representation of a Number
  95442. * @param value A Number. If the parameter is of a different type, it will get converted
  95443. * to a number or to NaN if it cannot be converted
  95444. * @returns number
  95445. */
  95446. static FloatRound(value: number): number;
  95447. /**
  95448. * Extracts the filename from a path
  95449. * @param path defines the path to use
  95450. * @returns the filename
  95451. */
  95452. static GetFilename(path: string): string;
  95453. /**
  95454. * Extracts the "folder" part of a path (everything before the filename).
  95455. * @param uri The URI to extract the info from
  95456. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95457. * @returns The "folder" part of the path
  95458. */
  95459. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95460. /**
  95461. * Extracts text content from a DOM element hierarchy
  95462. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95463. */
  95464. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95465. /**
  95466. * Convert an angle in radians to degrees
  95467. * @param angle defines the angle to convert
  95468. * @returns the angle in degrees
  95469. */
  95470. static ToDegrees(angle: number): number;
  95471. /**
  95472. * Convert an angle in degrees to radians
  95473. * @param angle defines the angle to convert
  95474. * @returns the angle in radians
  95475. */
  95476. static ToRadians(angle: number): number;
  95477. /**
  95478. * Encode a buffer to a base64 string
  95479. * @param buffer defines the buffer to encode
  95480. * @returns the encoded string
  95481. */
  95482. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95483. /**
  95484. * Returns an array if obj is not an array
  95485. * @param obj defines the object to evaluate as an array
  95486. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95487. * @returns either obj directly if obj is an array or a new array containing obj
  95488. */
  95489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95490. /**
  95491. * Gets the pointer prefix to use
  95492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95493. */
  95494. static GetPointerPrefix(): string;
  95495. /**
  95496. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95497. * @param url define the url we are trying
  95498. * @param element define the dom element where to configure the cors policy
  95499. */
  95500. static SetCorsBehavior(url: string | string[], element: {
  95501. crossOrigin: string | null;
  95502. }): void;
  95503. /**
  95504. * Removes unwanted characters from an url
  95505. * @param url defines the url to clean
  95506. * @returns the cleaned url
  95507. */
  95508. static CleanUrl(url: string): string;
  95509. /**
  95510. * Gets or sets a function used to pre-process url before using them to load assets
  95511. */
  95512. static PreprocessUrl: (url: string) => string;
  95513. /**
  95514. * Loads an image as an HTMLImageElement.
  95515. * @param input url string, ArrayBuffer, or Blob to load
  95516. * @param onLoad callback called when the image successfully loads
  95517. * @param onError callback called when the image fails to load
  95518. * @param offlineProvider offline provider for caching
  95519. * @returns the HTMLImageElement of the loaded image
  95520. */
  95521. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95522. /**
  95523. * Loads a file
  95524. * @param url url string, ArrayBuffer, or Blob to load
  95525. * @param onSuccess callback called when the file successfully loads
  95526. * @param onProgress callback called while file is loading (if the server supports this mode)
  95527. * @param offlineProvider defines the offline provider for caching
  95528. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95529. * @param onError callback called when the file fails to load
  95530. * @returns a file request object
  95531. */
  95532. 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;
  95533. /**
  95534. * Loads a file from a url
  95535. * @param url the file url to load
  95536. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95537. */
  95538. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95539. /**
  95540. * Load a script (identified by an url). When the url returns, the
  95541. * content of this file is added into a new script element, attached to the DOM (body element)
  95542. * @param scriptUrl defines the url of the script to laod
  95543. * @param onSuccess defines the callback called when the script is loaded
  95544. * @param onError defines the callback to call if an error occurs
  95545. * @param scriptId defines the id of the script element
  95546. */
  95547. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95548. /**
  95549. * Load an asynchronous script (identified by an url). When the url returns, the
  95550. * content of this file is added into a new script element, attached to the DOM (body element)
  95551. * @param scriptUrl defines the url of the script to laod
  95552. * @param scriptId defines the id of the script element
  95553. * @returns a promise request object
  95554. */
  95555. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95556. /**
  95557. * Loads a file from a blob
  95558. * @param fileToLoad defines the blob to use
  95559. * @param callback defines the callback to call when data is loaded
  95560. * @param progressCallback defines the callback to call during loading process
  95561. * @returns a file request object
  95562. */
  95563. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95564. /**
  95565. * Loads a file
  95566. * @param fileToLoad defines the file to load
  95567. * @param callback defines the callback to call when data is loaded
  95568. * @param progressCallBack defines the callback to call during loading process
  95569. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95570. * @returns a file request object
  95571. */
  95572. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95573. /**
  95574. * Creates a data url from a given string content
  95575. * @param content defines the content to convert
  95576. * @returns the new data url link
  95577. */
  95578. static FileAsURL(content: string): string;
  95579. /**
  95580. * Format the given number to a specific decimal format
  95581. * @param value defines the number to format
  95582. * @param decimals defines the number of decimals to use
  95583. * @returns the formatted string
  95584. */
  95585. static Format(value: number, decimals?: number): string;
  95586. /**
  95587. * Tries to copy an object by duplicating every property
  95588. * @param source defines the source object
  95589. * @param destination defines the target object
  95590. * @param doNotCopyList defines a list of properties to avoid
  95591. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95592. */
  95593. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95594. /**
  95595. * Gets a boolean indicating if the given object has no own property
  95596. * @param obj defines the object to test
  95597. * @returns true if object has no own property
  95598. */
  95599. static IsEmpty(obj: any): boolean;
  95600. /**
  95601. * Function used to register events at window level
  95602. * @param events defines the events to register
  95603. */
  95604. static RegisterTopRootEvents(events: {
  95605. name: string;
  95606. handler: Nullable<(e: FocusEvent) => any>;
  95607. }[]): void;
  95608. /**
  95609. * Function used to unregister events from window level
  95610. * @param events defines the events to unregister
  95611. */
  95612. static UnregisterTopRootEvents(events: {
  95613. name: string;
  95614. handler: Nullable<(e: FocusEvent) => any>;
  95615. }[]): void;
  95616. /**
  95617. * @ignore
  95618. */
  95619. static _ScreenshotCanvas: HTMLCanvasElement;
  95620. /**
  95621. * Dumps the current bound framebuffer
  95622. * @param width defines the rendering width
  95623. * @param height defines the rendering height
  95624. * @param engine defines the hosting engine
  95625. * @param successCallback defines the callback triggered once the data are available
  95626. * @param mimeType defines the mime type of the result
  95627. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95628. */
  95629. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95630. /**
  95631. * Converts the canvas data to blob.
  95632. * This acts as a polyfill for browsers not supporting the to blob function.
  95633. * @param canvas Defines the canvas to extract the data from
  95634. * @param successCallback Defines the callback triggered once the data are available
  95635. * @param mimeType Defines the mime type of the result
  95636. */
  95637. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95638. /**
  95639. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95640. * @param successCallback defines the callback triggered once the data are available
  95641. * @param mimeType defines the mime type of the result
  95642. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95643. */
  95644. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95645. /**
  95646. * Downloads a blob in the browser
  95647. * @param blob defines the blob to download
  95648. * @param fileName defines the name of the downloaded file
  95649. */
  95650. static Download(blob: Blob, fileName: string): void;
  95651. /**
  95652. * Captures a screenshot of the current rendering
  95653. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95654. * @param engine defines the rendering engine
  95655. * @param camera defines the source camera
  95656. * @param size This parameter can be set to a single number or to an object with the
  95657. * following (optional) properties: precision, width, height. If a single number is passed,
  95658. * it will be used for both width and height. If an object is passed, the screenshot size
  95659. * will be derived from the parameters. The precision property is a multiplier allowing
  95660. * rendering at a higher or lower resolution
  95661. * @param successCallback defines the callback receives a single parameter which contains the
  95662. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95663. * src parameter of an <img> to display it
  95664. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95665. * Check your browser for supported MIME types
  95666. */
  95667. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  95668. /**
  95669. * Captures a screenshot of the current rendering
  95670. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95671. * @param engine defines the rendering engine
  95672. * @param camera defines the source camera
  95673. * @param size This parameter can be set to a single number or to an object with the
  95674. * following (optional) properties: precision, width, height. If a single number is passed,
  95675. * it will be used for both width and height. If an object is passed, the screenshot size
  95676. * will be derived from the parameters. The precision property is a multiplier allowing
  95677. * rendering at a higher or lower resolution
  95678. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95679. * Check your browser for supported MIME types
  95680. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95681. * to the src parameter of an <img> to display it
  95682. */
  95683. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  95684. /**
  95685. * Generates an image screenshot from the specified camera.
  95686. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95687. * @param engine The engine to use for rendering
  95688. * @param camera The camera to use for rendering
  95689. * @param size This parameter can be set to a single number or to an object with the
  95690. * following (optional) properties: precision, width, height. If a single number is passed,
  95691. * it will be used for both width and height. If an object is passed, the screenshot size
  95692. * will be derived from the parameters. The precision property is a multiplier allowing
  95693. * rendering at a higher or lower resolution
  95694. * @param successCallback The callback receives a single parameter which contains the
  95695. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95696. * src parameter of an <img> to display it
  95697. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95698. * Check your browser for supported MIME types
  95699. * @param samples Texture samples (default: 1)
  95700. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95701. * @param fileName A name for for the downloaded file.
  95702. */
  95703. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95704. /**
  95705. * Generates an image screenshot from the specified camera.
  95706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95707. * @param engine The engine to use for rendering
  95708. * @param camera The camera to use for rendering
  95709. * @param size This parameter can be set to a single number or to an object with the
  95710. * following (optional) properties: precision, width, height. If a single number is passed,
  95711. * it will be used for both width and height. If an object is passed, the screenshot size
  95712. * will be derived from the parameters. The precision property is a multiplier allowing
  95713. * rendering at a higher or lower resolution
  95714. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95715. * Check your browser for supported MIME types
  95716. * @param samples Texture samples (default: 1)
  95717. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95718. * @param fileName A name for for the downloaded file.
  95719. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95720. * to the src parameter of an <img> to display it
  95721. */
  95722. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  95723. /**
  95724. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95725. * Be aware Math.random() could cause collisions, but:
  95726. * "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"
  95727. * @returns a pseudo random id
  95728. */
  95729. static RandomId(): string;
  95730. /**
  95731. * Test if the given uri is a base64 string
  95732. * @param uri The uri to test
  95733. * @return True if the uri is a base64 string or false otherwise
  95734. */
  95735. static IsBase64(uri: string): boolean;
  95736. /**
  95737. * Decode the given base64 uri.
  95738. * @param uri The uri to decode
  95739. * @return The decoded base64 data.
  95740. */
  95741. static DecodeBase64(uri: string): ArrayBuffer;
  95742. /**
  95743. * Gets the absolute url.
  95744. * @param url the input url
  95745. * @return the absolute url
  95746. */
  95747. static GetAbsoluteUrl(url: string): string;
  95748. /**
  95749. * No log
  95750. */
  95751. static readonly NoneLogLevel: number;
  95752. /**
  95753. * Only message logs
  95754. */
  95755. static readonly MessageLogLevel: number;
  95756. /**
  95757. * Only warning logs
  95758. */
  95759. static readonly WarningLogLevel: number;
  95760. /**
  95761. * Only error logs
  95762. */
  95763. static readonly ErrorLogLevel: number;
  95764. /**
  95765. * All logs
  95766. */
  95767. static readonly AllLogLevel: number;
  95768. /**
  95769. * Gets a value indicating the number of loading errors
  95770. * @ignorenaming
  95771. */
  95772. static readonly errorsCount: number;
  95773. /**
  95774. * Callback called when a new log is added
  95775. */
  95776. static OnNewCacheEntry: (entry: string) => void;
  95777. /**
  95778. * Log a message to the console
  95779. * @param message defines the message to log
  95780. */
  95781. static Log(message: string): void;
  95782. /**
  95783. * Write a warning message to the console
  95784. * @param message defines the message to log
  95785. */
  95786. static Warn(message: string): void;
  95787. /**
  95788. * Write an error message to the console
  95789. * @param message defines the message to log
  95790. */
  95791. static Error(message: string): void;
  95792. /**
  95793. * Gets current log cache (list of logs)
  95794. */
  95795. static readonly LogCache: string;
  95796. /**
  95797. * Clears the log cache
  95798. */
  95799. static ClearLogCache(): void;
  95800. /**
  95801. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95802. */
  95803. static LogLevels: number;
  95804. /**
  95805. * Checks if the window object exists
  95806. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95807. */
  95808. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95809. /**
  95810. * No performance log
  95811. */
  95812. static readonly PerformanceNoneLogLevel: number;
  95813. /**
  95814. * Use user marks to log performance
  95815. */
  95816. static readonly PerformanceUserMarkLogLevel: number;
  95817. /**
  95818. * Log performance to the console
  95819. */
  95820. static readonly PerformanceConsoleLogLevel: number;
  95821. private static _performance;
  95822. /**
  95823. * Sets the current performance log level
  95824. */
  95825. static PerformanceLogLevel: number;
  95826. private static _StartPerformanceCounterDisabled;
  95827. private static _EndPerformanceCounterDisabled;
  95828. private static _StartUserMark;
  95829. private static _EndUserMark;
  95830. private static _StartPerformanceConsole;
  95831. private static _EndPerformanceConsole;
  95832. /**
  95833. * Starts a performance counter
  95834. */
  95835. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95836. /**
  95837. * Ends a specific performance coutner
  95838. */
  95839. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95840. /**
  95841. * Gets either window.performance.now() if supported or Date.now() else
  95842. */
  95843. static readonly Now: number;
  95844. /**
  95845. * This method will return the name of the class used to create the instance of the given object.
  95846. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  95847. * @param object the object to get the class name from
  95848. * @param isType defines if the object is actually a type
  95849. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  95850. */
  95851. static GetClassName(object: any, isType?: boolean): string;
  95852. /**
  95853. * Gets the first element of an array satisfying a given predicate
  95854. * @param array defines the array to browse
  95855. * @param predicate defines the predicate to use
  95856. * @returns null if not found or the element
  95857. */
  95858. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  95859. /**
  95860. * This method will return the name of the full name of the class, including its owning module (if any).
  95861. * 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).
  95862. * @param object the object to get the class name from
  95863. * @param isType defines if the object is actually a type
  95864. * @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.
  95865. * @ignorenaming
  95866. */
  95867. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  95868. /**
  95869. * Returns a promise that resolves after the given amount of time.
  95870. * @param delay Number of milliseconds to delay
  95871. * @returns Promise that resolves after the given amount of time
  95872. */
  95873. static DelayAsync(delay: number): Promise<void>;
  95874. }
  95875. /**
  95876. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  95877. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  95878. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  95879. * @param name The name of the class, case should be preserved
  95880. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  95881. */
  95882. export function className(name: string, module?: string): (target: Object) => void;
  95883. /**
  95884. * An implementation of a loop for asynchronous functions.
  95885. */
  95886. export class AsyncLoop {
  95887. /**
  95888. * Defines the number of iterations for the loop
  95889. */
  95890. iterations: number;
  95891. /**
  95892. * Defines the current index of the loop.
  95893. */
  95894. index: number;
  95895. private _done;
  95896. private _fn;
  95897. private _successCallback;
  95898. /**
  95899. * Constructor.
  95900. * @param iterations the number of iterations.
  95901. * @param func the function to run each iteration
  95902. * @param successCallback the callback that will be called upon succesful execution
  95903. * @param offset starting offset.
  95904. */
  95905. constructor(
  95906. /**
  95907. * Defines the number of iterations for the loop
  95908. */
  95909. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  95910. /**
  95911. * Execute the next iteration. Must be called after the last iteration was finished.
  95912. */
  95913. executeNext(): void;
  95914. /**
  95915. * Break the loop and run the success callback.
  95916. */
  95917. breakLoop(): void;
  95918. /**
  95919. * Create and run an async loop.
  95920. * @param iterations the number of iterations.
  95921. * @param fn the function to run each iteration
  95922. * @param successCallback the callback that will be called upon succesful execution
  95923. * @param offset starting offset.
  95924. * @returns the created async loop object
  95925. */
  95926. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  95927. /**
  95928. * A for-loop that will run a given number of iterations synchronous and the rest async.
  95929. * @param iterations total number of iterations
  95930. * @param syncedIterations number of synchronous iterations in each async iteration.
  95931. * @param fn the function to call each iteration.
  95932. * @param callback a success call back that will be called when iterating stops.
  95933. * @param breakFunction a break condition (optional)
  95934. * @param timeout timeout settings for the setTimeout function. default - 0.
  95935. * @returns the created async loop object
  95936. */
  95937. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  95938. }
  95939. }
  95940. declare module BABYLON {
  95941. /** @hidden */
  95942. export interface ICollisionCoordinator {
  95943. createCollider(): Collider;
  95944. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95945. init(scene: Scene): void;
  95946. }
  95947. /** @hidden */
  95948. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  95949. private _scene;
  95950. private _scaledPosition;
  95951. private _scaledVelocity;
  95952. private _finalPosition;
  95953. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95954. createCollider(): Collider;
  95955. init(scene: Scene): void;
  95956. private _collideWithWorld;
  95957. }
  95958. }
  95959. declare module BABYLON {
  95960. /**
  95961. * Class used to manage all inputs for the scene.
  95962. */
  95963. export class InputManager {
  95964. /** The distance in pixel that you have to move to prevent some events */
  95965. static DragMovementThreshold: number;
  95966. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  95967. static LongPressDelay: number;
  95968. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  95969. static DoubleClickDelay: number;
  95970. /** If you need to check double click without raising a single click at first click, enable this flag */
  95971. static ExclusiveDoubleClickMode: boolean;
  95972. private _wheelEventName;
  95973. private _onPointerMove;
  95974. private _onPointerDown;
  95975. private _onPointerUp;
  95976. private _initClickEvent;
  95977. private _initActionManager;
  95978. private _delayedSimpleClick;
  95979. private _delayedSimpleClickTimeout;
  95980. private _previousDelayedSimpleClickTimeout;
  95981. private _meshPickProceed;
  95982. private _previousButtonPressed;
  95983. private _currentPickResult;
  95984. private _previousPickResult;
  95985. private _totalPointersPressed;
  95986. private _doubleClickOccured;
  95987. private _pointerOverMesh;
  95988. private _pickedDownMesh;
  95989. private _pickedUpMesh;
  95990. private _pointerX;
  95991. private _pointerY;
  95992. private _unTranslatedPointerX;
  95993. private _unTranslatedPointerY;
  95994. private _startingPointerPosition;
  95995. private _previousStartingPointerPosition;
  95996. private _startingPointerTime;
  95997. private _previousStartingPointerTime;
  95998. private _pointerCaptures;
  95999. private _onKeyDown;
  96000. private _onKeyUp;
  96001. private _onCanvasFocusObserver;
  96002. private _onCanvasBlurObserver;
  96003. private _scene;
  96004. /**
  96005. * Creates a new InputManager
  96006. * @param scene defines the hosting scene
  96007. */
  96008. constructor(scene: Scene);
  96009. /**
  96010. * Gets the mesh that is currently under the pointer
  96011. */
  96012. readonly meshUnderPointer: Nullable<AbstractMesh>;
  96013. /**
  96014. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  96015. */
  96016. readonly unTranslatedPointer: Vector2;
  96017. /**
  96018. * Gets or sets the current on-screen X position of the pointer
  96019. */
  96020. pointerX: number;
  96021. /**
  96022. * Gets or sets the current on-screen Y position of the pointer
  96023. */
  96024. pointerY: number;
  96025. private _updatePointerPosition;
  96026. private _processPointerMove;
  96027. private _setRayOnPointerInfo;
  96028. private _checkPrePointerObservable;
  96029. /**
  96030. * Use this method to simulate a pointer move on a mesh
  96031. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96032. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96033. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96034. */
  96035. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96036. /**
  96037. * Use this method to simulate a pointer down on a mesh
  96038. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96039. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96040. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96041. */
  96042. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96043. private _processPointerDown;
  96044. /** @hidden */
  96045. _isPointerSwiping(): boolean;
  96046. /**
  96047. * Use this method to simulate a pointer up on a mesh
  96048. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96049. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96050. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96051. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96052. */
  96053. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96054. private _processPointerUp;
  96055. /**
  96056. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96057. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96058. * @returns true if the pointer was captured
  96059. */
  96060. isPointerCaptured(pointerId?: number): boolean;
  96061. /**
  96062. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96063. * @param attachUp defines if you want to attach events to pointerup
  96064. * @param attachDown defines if you want to attach events to pointerdown
  96065. * @param attachMove defines if you want to attach events to pointermove
  96066. */
  96067. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96068. /**
  96069. * Detaches all event handlers
  96070. */
  96071. detachControl(): void;
  96072. /**
  96073. * Force the value of meshUnderPointer
  96074. * @param mesh defines the mesh to use
  96075. */
  96076. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96077. /**
  96078. * Gets the mesh under the pointer
  96079. * @returns a Mesh or null if no mesh is under the pointer
  96080. */
  96081. getPointerOverMesh(): Nullable<AbstractMesh>;
  96082. }
  96083. }
  96084. declare module BABYLON {
  96085. /**
  96086. * Helper class used to generate session unique ID
  96087. */
  96088. export class UniqueIdGenerator {
  96089. private static _UniqueIdCounter;
  96090. /**
  96091. * Gets an unique (relatively to the current scene) Id
  96092. */
  96093. static readonly UniqueId: number;
  96094. }
  96095. }
  96096. declare module BABYLON {
  96097. /**
  96098. * This class defines the direct association between an animation and a target
  96099. */
  96100. export class TargetedAnimation {
  96101. /**
  96102. * Animation to perform
  96103. */
  96104. animation: Animation;
  96105. /**
  96106. * Target to animate
  96107. */
  96108. target: any;
  96109. /**
  96110. * Serialize the object
  96111. * @returns the JSON object representing the current entity
  96112. */
  96113. serialize(): any;
  96114. }
  96115. /**
  96116. * Use this class to create coordinated animations on multiple targets
  96117. */
  96118. export class AnimationGroup implements IDisposable {
  96119. /** The name of the animation group */
  96120. name: string;
  96121. private _scene;
  96122. private _targetedAnimations;
  96123. private _animatables;
  96124. private _from;
  96125. private _to;
  96126. private _isStarted;
  96127. private _isPaused;
  96128. private _speedRatio;
  96129. private _loopAnimation;
  96130. /**
  96131. * Gets or sets the unique id of the node
  96132. */
  96133. uniqueId: number;
  96134. /**
  96135. * This observable will notify when one animation have ended
  96136. */
  96137. onAnimationEndObservable: Observable<TargetedAnimation>;
  96138. /**
  96139. * Observer raised when one animation loops
  96140. */
  96141. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96142. /**
  96143. * This observable will notify when all animations have ended.
  96144. */
  96145. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96146. /**
  96147. * This observable will notify when all animations have paused.
  96148. */
  96149. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96150. /**
  96151. * This observable will notify when all animations are playing.
  96152. */
  96153. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96154. /**
  96155. * Gets the first frame
  96156. */
  96157. readonly from: number;
  96158. /**
  96159. * Gets the last frame
  96160. */
  96161. readonly to: number;
  96162. /**
  96163. * Define if the animations are started
  96164. */
  96165. readonly isStarted: boolean;
  96166. /**
  96167. * Gets a value indicating that the current group is playing
  96168. */
  96169. readonly isPlaying: boolean;
  96170. /**
  96171. * Gets or sets the speed ratio to use for all animations
  96172. */
  96173. /**
  96174. * Gets or sets the speed ratio to use for all animations
  96175. */
  96176. speedRatio: number;
  96177. /**
  96178. * Gets or sets if all animations should loop or not
  96179. */
  96180. loopAnimation: boolean;
  96181. /**
  96182. * Gets the targeted animations for this animation group
  96183. */
  96184. readonly targetedAnimations: Array<TargetedAnimation>;
  96185. /**
  96186. * returning the list of animatables controlled by this animation group.
  96187. */
  96188. readonly animatables: Array<Animatable>;
  96189. /**
  96190. * Instantiates a new Animation Group.
  96191. * This helps managing several animations at once.
  96192. * @see http://doc.babylonjs.com/how_to/group
  96193. * @param name Defines the name of the group
  96194. * @param scene Defines the scene the group belongs to
  96195. */
  96196. constructor(
  96197. /** The name of the animation group */
  96198. name: string, scene?: Nullable<Scene>);
  96199. /**
  96200. * Add an animation (with its target) in the group
  96201. * @param animation defines the animation we want to add
  96202. * @param target defines the target of the animation
  96203. * @returns the TargetedAnimation object
  96204. */
  96205. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96206. /**
  96207. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96208. * It can add constant keys at begin or end
  96209. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96210. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96211. * @returns the animation group
  96212. */
  96213. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96214. /**
  96215. * Start all animations on given targets
  96216. * @param loop defines if animations must loop
  96217. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96218. * @param from defines the from key (optional)
  96219. * @param to defines the to key (optional)
  96220. * @returns the current animation group
  96221. */
  96222. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96223. /**
  96224. * Pause all animations
  96225. * @returns the animation group
  96226. */
  96227. pause(): AnimationGroup;
  96228. /**
  96229. * Play all animations to initial state
  96230. * This function will start() the animations if they were not started or will restart() them if they were paused
  96231. * @param loop defines if animations must loop
  96232. * @returns the animation group
  96233. */
  96234. play(loop?: boolean): AnimationGroup;
  96235. /**
  96236. * Reset all animations to initial state
  96237. * @returns the animation group
  96238. */
  96239. reset(): AnimationGroup;
  96240. /**
  96241. * Restart animations from key 0
  96242. * @returns the animation group
  96243. */
  96244. restart(): AnimationGroup;
  96245. /**
  96246. * Stop all animations
  96247. * @returns the animation group
  96248. */
  96249. stop(): AnimationGroup;
  96250. /**
  96251. * Set animation weight for all animatables
  96252. * @param weight defines the weight to use
  96253. * @return the animationGroup
  96254. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96255. */
  96256. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96257. /**
  96258. * Synchronize and normalize all animatables with a source animatable
  96259. * @param root defines the root animatable to synchronize with
  96260. * @return the animationGroup
  96261. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96262. */
  96263. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96264. /**
  96265. * Goes to a specific frame in this animation group
  96266. * @param frame the frame number to go to
  96267. * @return the animationGroup
  96268. */
  96269. goToFrame(frame: number): AnimationGroup;
  96270. /**
  96271. * Dispose all associated resources
  96272. */
  96273. dispose(): void;
  96274. private _checkAnimationGroupEnded;
  96275. /**
  96276. * Clone the current animation group and returns a copy
  96277. * @param newName defines the name of the new group
  96278. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96279. * @returns the new aniamtion group
  96280. */
  96281. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96282. /**
  96283. * Serializes the animationGroup to an object
  96284. * @returns Serialized object
  96285. */
  96286. serialize(): any;
  96287. /**
  96288. * Returns a new AnimationGroup object parsed from the source provided.
  96289. * @param parsedAnimationGroup defines the source
  96290. * @param scene defines the scene that will receive the animationGroup
  96291. * @returns a new AnimationGroup
  96292. */
  96293. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96294. /**
  96295. * Returns the string "AnimationGroup"
  96296. * @returns "AnimationGroup"
  96297. */
  96298. getClassName(): string;
  96299. /**
  96300. * Creates a detailled string about the object
  96301. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96302. * @returns a string representing the object
  96303. */
  96304. toString(fullDetails?: boolean): string;
  96305. }
  96306. }
  96307. declare module BABYLON {
  96308. /**
  96309. * Define an interface for all classes that will hold resources
  96310. */
  96311. export interface IDisposable {
  96312. /**
  96313. * Releases all held resources
  96314. */
  96315. dispose(): void;
  96316. }
  96317. /** Interface defining initialization parameters for Scene class */
  96318. export interface SceneOptions {
  96319. /**
  96320. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96321. * It will improve performance when the number of geometries becomes important.
  96322. */
  96323. useGeometryUniqueIdsMap?: boolean;
  96324. /**
  96325. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96326. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96327. */
  96328. useMaterialMeshMap?: boolean;
  96329. /**
  96330. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96331. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96332. */
  96333. useClonedMeshhMap?: boolean;
  96334. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96335. virtual?: boolean;
  96336. }
  96337. /**
  96338. * Represents a scene to be rendered by the engine.
  96339. * @see http://doc.babylonjs.com/features/scene
  96340. */
  96341. export class Scene extends AbstractScene implements IAnimatable {
  96342. /** The fog is deactivated */
  96343. static readonly FOGMODE_NONE: number;
  96344. /** The fog density is following an exponential function */
  96345. static readonly FOGMODE_EXP: number;
  96346. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96347. static readonly FOGMODE_EXP2: number;
  96348. /** The fog density is following a linear function. */
  96349. static readonly FOGMODE_LINEAR: number;
  96350. /**
  96351. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96352. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96353. */
  96354. static MinDeltaTime: number;
  96355. /**
  96356. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96357. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96358. */
  96359. static MaxDeltaTime: number;
  96360. /**
  96361. * Factory used to create the default material.
  96362. * @param name The name of the material to create
  96363. * @param scene The scene to create the material for
  96364. * @returns The default material
  96365. */
  96366. static DefaultMaterialFactory(scene: Scene): Material;
  96367. /**
  96368. * Factory used to create the a collision coordinator.
  96369. * @returns The collision coordinator
  96370. */
  96371. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96372. /** @hidden */
  96373. _inputManager: InputManager;
  96374. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96375. cameraToUseForPointers: Nullable<Camera>;
  96376. /** @hidden */
  96377. readonly _isScene: boolean;
  96378. /**
  96379. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96380. */
  96381. autoClear: boolean;
  96382. /**
  96383. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96384. */
  96385. autoClearDepthAndStencil: boolean;
  96386. /**
  96387. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96388. */
  96389. clearColor: Color4;
  96390. /**
  96391. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96392. */
  96393. ambientColor: Color3;
  96394. /**
  96395. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96396. * It should only be one of the following (if not the default embedded one):
  96397. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96398. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96399. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96400. * The material properties need to be setup according to the type of texture in use.
  96401. */
  96402. environmentBRDFTexture: BaseTexture;
  96403. /** @hidden */
  96404. protected _environmentTexture: Nullable<BaseTexture>;
  96405. /**
  96406. * Texture used in all pbr material as the reflection texture.
  96407. * As in the majority of the scene they are the same (exception for multi room and so on),
  96408. * this is easier to reference from here than from all the materials.
  96409. */
  96410. /**
  96411. * Texture used in all pbr material as the reflection texture.
  96412. * As in the majority of the scene they are the same (exception for multi room and so on),
  96413. * this is easier to set here than in all the materials.
  96414. */
  96415. environmentTexture: Nullable<BaseTexture>;
  96416. /** @hidden */
  96417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96418. /**
  96419. * Default image processing configuration used either in the rendering
  96420. * Forward main pass or through the imageProcessingPostProcess if present.
  96421. * As in the majority of the scene they are the same (exception for multi camera),
  96422. * this is easier to reference from here than from all the materials and post process.
  96423. *
  96424. * No setter as we it is a shared configuration, you can set the values instead.
  96425. */
  96426. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96427. private _forceWireframe;
  96428. /**
  96429. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96430. */
  96431. forceWireframe: boolean;
  96432. private _forcePointsCloud;
  96433. /**
  96434. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96435. */
  96436. forcePointsCloud: boolean;
  96437. /**
  96438. * Gets or sets the active clipplane 1
  96439. */
  96440. clipPlane: Nullable<Plane>;
  96441. /**
  96442. * Gets or sets the active clipplane 2
  96443. */
  96444. clipPlane2: Nullable<Plane>;
  96445. /**
  96446. * Gets or sets the active clipplane 3
  96447. */
  96448. clipPlane3: Nullable<Plane>;
  96449. /**
  96450. * Gets or sets the active clipplane 4
  96451. */
  96452. clipPlane4: Nullable<Plane>;
  96453. /**
  96454. * Gets or sets a boolean indicating if animations are enabled
  96455. */
  96456. animationsEnabled: boolean;
  96457. private _animationPropertiesOverride;
  96458. /**
  96459. * Gets or sets the animation properties override
  96460. */
  96461. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96462. /**
  96463. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96464. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96465. */
  96466. useConstantAnimationDeltaTime: boolean;
  96467. /**
  96468. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96469. * Please note that it requires to run a ray cast through the scene on every frame
  96470. */
  96471. constantlyUpdateMeshUnderPointer: boolean;
  96472. /**
  96473. * Defines the HTML cursor to use when hovering over interactive elements
  96474. */
  96475. hoverCursor: string;
  96476. /**
  96477. * Defines the HTML default cursor to use (empty by default)
  96478. */
  96479. defaultCursor: string;
  96480. /**
  96481. * This is used to call preventDefault() on pointer down
  96482. * in order to block unwanted artifacts like system double clicks
  96483. */
  96484. preventDefaultOnPointerDown: boolean;
  96485. /**
  96486. * This is used to call preventDefault() on pointer up
  96487. * in order to block unwanted artifacts like system double clicks
  96488. */
  96489. preventDefaultOnPointerUp: boolean;
  96490. /**
  96491. * Gets or sets user defined metadata
  96492. */
  96493. metadata: any;
  96494. /**
  96495. * For internal use only. Please do not use.
  96496. */
  96497. reservedDataStore: any;
  96498. /**
  96499. * Gets the name of the plugin used to load this scene (null by default)
  96500. */
  96501. loadingPluginName: string;
  96502. /**
  96503. * Use this array to add regular expressions used to disable offline support for specific urls
  96504. */
  96505. disableOfflineSupportExceptionRules: RegExp[];
  96506. /**
  96507. * An event triggered when the scene is disposed.
  96508. */
  96509. onDisposeObservable: Observable<Scene>;
  96510. private _onDisposeObserver;
  96511. /** Sets a function to be executed when this scene is disposed. */
  96512. onDispose: () => void;
  96513. /**
  96514. * An event triggered before rendering the scene (right after animations and physics)
  96515. */
  96516. onBeforeRenderObservable: Observable<Scene>;
  96517. private _onBeforeRenderObserver;
  96518. /** Sets a function to be executed before rendering this scene */
  96519. beforeRender: Nullable<() => void>;
  96520. /**
  96521. * An event triggered after rendering the scene
  96522. */
  96523. onAfterRenderObservable: Observable<Scene>;
  96524. /**
  96525. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96526. */
  96527. onAfterRenderCameraObservable: Observable<Camera>;
  96528. private _onAfterRenderObserver;
  96529. /** Sets a function to be executed after rendering this scene */
  96530. afterRender: Nullable<() => void>;
  96531. /**
  96532. * An event triggered before animating the scene
  96533. */
  96534. onBeforeAnimationsObservable: Observable<Scene>;
  96535. /**
  96536. * An event triggered after animations processing
  96537. */
  96538. onAfterAnimationsObservable: Observable<Scene>;
  96539. /**
  96540. * An event triggered before draw calls are ready to be sent
  96541. */
  96542. onBeforeDrawPhaseObservable: Observable<Scene>;
  96543. /**
  96544. * An event triggered after draw calls have been sent
  96545. */
  96546. onAfterDrawPhaseObservable: Observable<Scene>;
  96547. /**
  96548. * An event triggered when the scene is ready
  96549. */
  96550. onReadyObservable: Observable<Scene>;
  96551. /**
  96552. * An event triggered before rendering a camera
  96553. */
  96554. onBeforeCameraRenderObservable: Observable<Camera>;
  96555. private _onBeforeCameraRenderObserver;
  96556. /** Sets a function to be executed before rendering a camera*/
  96557. beforeCameraRender: () => void;
  96558. /**
  96559. * An event triggered after rendering a camera
  96560. */
  96561. onAfterCameraRenderObservable: Observable<Camera>;
  96562. private _onAfterCameraRenderObserver;
  96563. /** Sets a function to be executed after rendering a camera*/
  96564. afterCameraRender: () => void;
  96565. /**
  96566. * An event triggered when active meshes evaluation is about to start
  96567. */
  96568. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96569. /**
  96570. * An event triggered when active meshes evaluation is done
  96571. */
  96572. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96573. /**
  96574. * An event triggered when particles rendering is about to start
  96575. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96576. */
  96577. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96578. /**
  96579. * An event triggered when particles rendering is done
  96580. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96581. */
  96582. onAfterParticlesRenderingObservable: Observable<Scene>;
  96583. /**
  96584. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96585. */
  96586. onDataLoadedObservable: Observable<Scene>;
  96587. /**
  96588. * An event triggered when a camera is created
  96589. */
  96590. onNewCameraAddedObservable: Observable<Camera>;
  96591. /**
  96592. * An event triggered when a camera is removed
  96593. */
  96594. onCameraRemovedObservable: Observable<Camera>;
  96595. /**
  96596. * An event triggered when a light is created
  96597. */
  96598. onNewLightAddedObservable: Observable<Light>;
  96599. /**
  96600. * An event triggered when a light is removed
  96601. */
  96602. onLightRemovedObservable: Observable<Light>;
  96603. /**
  96604. * An event triggered when a geometry is created
  96605. */
  96606. onNewGeometryAddedObservable: Observable<Geometry>;
  96607. /**
  96608. * An event triggered when a geometry is removed
  96609. */
  96610. onGeometryRemovedObservable: Observable<Geometry>;
  96611. /**
  96612. * An event triggered when a transform node is created
  96613. */
  96614. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96615. /**
  96616. * An event triggered when a transform node is removed
  96617. */
  96618. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96619. /**
  96620. * An event triggered when a mesh is created
  96621. */
  96622. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96623. /**
  96624. * An event triggered when a mesh is removed
  96625. */
  96626. onMeshRemovedObservable: Observable<AbstractMesh>;
  96627. /**
  96628. * An event triggered when a skeleton is created
  96629. */
  96630. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96631. /**
  96632. * An event triggered when a skeleton is removed
  96633. */
  96634. onSkeletonRemovedObservable: Observable<Skeleton>;
  96635. /**
  96636. * An event triggered when a material is created
  96637. */
  96638. onNewMaterialAddedObservable: Observable<Material>;
  96639. /**
  96640. * An event triggered when a material is removed
  96641. */
  96642. onMaterialRemovedObservable: Observable<Material>;
  96643. /**
  96644. * An event triggered when a texture is created
  96645. */
  96646. onNewTextureAddedObservable: Observable<BaseTexture>;
  96647. /**
  96648. * An event triggered when a texture is removed
  96649. */
  96650. onTextureRemovedObservable: Observable<BaseTexture>;
  96651. /**
  96652. * An event triggered when render targets are about to be rendered
  96653. * Can happen multiple times per frame.
  96654. */
  96655. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96656. /**
  96657. * An event triggered when render targets were rendered.
  96658. * Can happen multiple times per frame.
  96659. */
  96660. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96661. /**
  96662. * An event triggered before calculating deterministic simulation step
  96663. */
  96664. onBeforeStepObservable: Observable<Scene>;
  96665. /**
  96666. * An event triggered after calculating deterministic simulation step
  96667. */
  96668. onAfterStepObservable: Observable<Scene>;
  96669. /**
  96670. * An event triggered when the activeCamera property is updated
  96671. */
  96672. onActiveCameraChanged: Observable<Scene>;
  96673. /**
  96674. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96675. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96676. * 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)
  96677. */
  96678. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96679. /**
  96680. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96681. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96682. * 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)
  96683. */
  96684. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96685. /**
  96686. * This Observable will when a mesh has been imported into the scene.
  96687. */
  96688. onMeshImportedObservable: Observable<AbstractMesh>;
  96689. /**
  96690. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96691. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96692. */
  96693. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96694. /** @hidden */
  96695. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96696. /**
  96697. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96698. */
  96699. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96700. /**
  96701. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96702. */
  96703. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96704. /**
  96705. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96706. */
  96707. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96708. /** Callback called when a pointer move is detected */
  96709. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96710. /** Callback called when a pointer down is detected */
  96711. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96712. /** Callback called when a pointer up is detected */
  96713. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96714. /** Callback called when a pointer pick is detected */
  96715. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96716. /**
  96717. * 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).
  96718. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96719. */
  96720. onPrePointerObservable: Observable<PointerInfoPre>;
  96721. /**
  96722. * Observable event triggered each time an input event is received from the rendering canvas
  96723. */
  96724. onPointerObservable: Observable<PointerInfo>;
  96725. /**
  96726. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96727. */
  96728. readonly unTranslatedPointer: Vector2;
  96729. /**
  96730. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96731. */
  96732. static DragMovementThreshold: number;
  96733. /**
  96734. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96735. */
  96736. static LongPressDelay: number;
  96737. /**
  96738. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96739. */
  96740. static DoubleClickDelay: number;
  96741. /** If you need to check double click without raising a single click at first click, enable this flag */
  96742. static ExclusiveDoubleClickMode: boolean;
  96743. /** @hidden */
  96744. _mirroredCameraPosition: Nullable<Vector3>;
  96745. /**
  96746. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96747. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96748. */
  96749. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96750. /**
  96751. * Observable event triggered each time an keyboard event is received from the hosting window
  96752. */
  96753. onKeyboardObservable: Observable<KeyboardInfo>;
  96754. private _useRightHandedSystem;
  96755. /**
  96756. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96757. */
  96758. useRightHandedSystem: boolean;
  96759. private _timeAccumulator;
  96760. private _currentStepId;
  96761. private _currentInternalStep;
  96762. /**
  96763. * Sets the step Id used by deterministic lock step
  96764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96765. * @param newStepId defines the step Id
  96766. */
  96767. setStepId(newStepId: number): void;
  96768. /**
  96769. * Gets the step Id used by deterministic lock step
  96770. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96771. * @returns the step Id
  96772. */
  96773. getStepId(): number;
  96774. /**
  96775. * Gets the internal step used by deterministic lock step
  96776. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96777. * @returns the internal step
  96778. */
  96779. getInternalStep(): number;
  96780. private _fogEnabled;
  96781. /**
  96782. * Gets or sets a boolean indicating if fog is enabled on this scene
  96783. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96784. * (Default is true)
  96785. */
  96786. fogEnabled: boolean;
  96787. private _fogMode;
  96788. /**
  96789. * Gets or sets the fog mode to use
  96790. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96791. * | mode | value |
  96792. * | --- | --- |
  96793. * | FOGMODE_NONE | 0 |
  96794. * | FOGMODE_EXP | 1 |
  96795. * | FOGMODE_EXP2 | 2 |
  96796. * | FOGMODE_LINEAR | 3 |
  96797. */
  96798. fogMode: number;
  96799. /**
  96800. * Gets or sets the fog color to use
  96801. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96802. * (Default is Color3(0.2, 0.2, 0.3))
  96803. */
  96804. fogColor: Color3;
  96805. /**
  96806. * Gets or sets the fog density to use
  96807. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96808. * (Default is 0.1)
  96809. */
  96810. fogDensity: number;
  96811. /**
  96812. * Gets or sets the fog start distance to use
  96813. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96814. * (Default is 0)
  96815. */
  96816. fogStart: number;
  96817. /**
  96818. * Gets or sets the fog end distance to use
  96819. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96820. * (Default is 1000)
  96821. */
  96822. fogEnd: number;
  96823. private _shadowsEnabled;
  96824. /**
  96825. * Gets or sets a boolean indicating if shadows are enabled on this scene
  96826. */
  96827. shadowsEnabled: boolean;
  96828. private _lightsEnabled;
  96829. /**
  96830. * Gets or sets a boolean indicating if lights are enabled on this scene
  96831. */
  96832. lightsEnabled: boolean;
  96833. /** All of the active cameras added to this scene. */
  96834. activeCameras: Camera[];
  96835. /** @hidden */
  96836. _activeCamera: Nullable<Camera>;
  96837. /** Gets or sets the current active camera */
  96838. activeCamera: Nullable<Camera>;
  96839. private _defaultMaterial;
  96840. /** The default material used on meshes when no material is affected */
  96841. /** The default material used on meshes when no material is affected */
  96842. defaultMaterial: Material;
  96843. private _texturesEnabled;
  96844. /**
  96845. * Gets or sets a boolean indicating if textures are enabled on this scene
  96846. */
  96847. texturesEnabled: boolean;
  96848. /**
  96849. * Gets or sets a boolean indicating if particles are enabled on this scene
  96850. */
  96851. particlesEnabled: boolean;
  96852. /**
  96853. * Gets or sets a boolean indicating if sprites are enabled on this scene
  96854. */
  96855. spritesEnabled: boolean;
  96856. private _skeletonsEnabled;
  96857. /**
  96858. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  96859. */
  96860. skeletonsEnabled: boolean;
  96861. /**
  96862. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  96863. */
  96864. lensFlaresEnabled: boolean;
  96865. /**
  96866. * Gets or sets a boolean indicating if collisions are enabled on this scene
  96867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96868. */
  96869. collisionsEnabled: boolean;
  96870. private _collisionCoordinator;
  96871. /** @hidden */
  96872. readonly collisionCoordinator: ICollisionCoordinator;
  96873. /**
  96874. * Defines the gravity applied to this scene (used only for collisions)
  96875. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96876. */
  96877. gravity: Vector3;
  96878. /**
  96879. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  96880. */
  96881. postProcessesEnabled: boolean;
  96882. /**
  96883. * The list of postprocesses added to the scene
  96884. */
  96885. postProcesses: PostProcess[];
  96886. /**
  96887. * Gets the current postprocess manager
  96888. */
  96889. postProcessManager: PostProcessManager;
  96890. /**
  96891. * Gets or sets a boolean indicating if render targets are enabled on this scene
  96892. */
  96893. renderTargetsEnabled: boolean;
  96894. /**
  96895. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  96896. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  96897. */
  96898. dumpNextRenderTargets: boolean;
  96899. /**
  96900. * The list of user defined render targets added to the scene
  96901. */
  96902. customRenderTargets: RenderTargetTexture[];
  96903. /**
  96904. * Defines if texture loading must be delayed
  96905. * If true, textures will only be loaded when they need to be rendered
  96906. */
  96907. useDelayedTextureLoading: boolean;
  96908. /**
  96909. * Gets the list of meshes imported to the scene through SceneLoader
  96910. */
  96911. importedMeshesFiles: String[];
  96912. /**
  96913. * Gets or sets a boolean indicating if probes are enabled on this scene
  96914. */
  96915. probesEnabled: boolean;
  96916. /**
  96917. * Gets or sets the current offline provider to use to store scene data
  96918. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  96919. */
  96920. offlineProvider: IOfflineProvider;
  96921. /**
  96922. * Gets or sets the action manager associated with the scene
  96923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96924. */
  96925. actionManager: AbstractActionManager;
  96926. private _meshesForIntersections;
  96927. /**
  96928. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  96929. */
  96930. proceduralTexturesEnabled: boolean;
  96931. private _engine;
  96932. private _totalVertices;
  96933. /** @hidden */
  96934. _activeIndices: PerfCounter;
  96935. /** @hidden */
  96936. _activeParticles: PerfCounter;
  96937. /** @hidden */
  96938. _activeBones: PerfCounter;
  96939. private _animationRatio;
  96940. /** @hidden */
  96941. _animationTimeLast: number;
  96942. /** @hidden */
  96943. _animationTime: number;
  96944. /**
  96945. * Gets or sets a general scale for animation speed
  96946. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  96947. */
  96948. animationTimeScale: number;
  96949. /** @hidden */
  96950. _cachedMaterial: Nullable<Material>;
  96951. /** @hidden */
  96952. _cachedEffect: Nullable<Effect>;
  96953. /** @hidden */
  96954. _cachedVisibility: Nullable<number>;
  96955. private _renderId;
  96956. private _frameId;
  96957. private _executeWhenReadyTimeoutId;
  96958. private _intermediateRendering;
  96959. private _viewUpdateFlag;
  96960. private _projectionUpdateFlag;
  96961. /** @hidden */
  96962. _toBeDisposed: Nullable<IDisposable>[];
  96963. private _activeRequests;
  96964. /** @hidden */
  96965. _pendingData: any[];
  96966. private _isDisposed;
  96967. /**
  96968. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  96969. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  96970. */
  96971. dispatchAllSubMeshesOfActiveMeshes: boolean;
  96972. private _activeMeshes;
  96973. private _processedMaterials;
  96974. private _renderTargets;
  96975. /** @hidden */
  96976. _activeParticleSystems: SmartArray<IParticleSystem>;
  96977. private _activeSkeletons;
  96978. private _softwareSkinnedMeshes;
  96979. private _renderingManager;
  96980. /** @hidden */
  96981. _activeAnimatables: Animatable[];
  96982. private _transformMatrix;
  96983. private _sceneUbo;
  96984. /** @hidden */
  96985. _viewMatrix: Matrix;
  96986. private _projectionMatrix;
  96987. /** @hidden */
  96988. _forcedViewPosition: Nullable<Vector3>;
  96989. /** @hidden */
  96990. _frustumPlanes: Plane[];
  96991. /**
  96992. * Gets the list of frustum planes (built from the active camera)
  96993. */
  96994. readonly frustumPlanes: Plane[];
  96995. /**
  96996. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  96997. * This is useful if there are more lights that the maximum simulteanous authorized
  96998. */
  96999. requireLightSorting: boolean;
  97000. /** @hidden */
  97001. readonly useMaterialMeshMap: boolean;
  97002. /** @hidden */
  97003. readonly useClonedMeshhMap: boolean;
  97004. private _externalData;
  97005. private _uid;
  97006. /**
  97007. * @hidden
  97008. * Backing store of defined scene components.
  97009. */
  97010. _components: ISceneComponent[];
  97011. /**
  97012. * @hidden
  97013. * Backing store of defined scene components.
  97014. */
  97015. _serializableComponents: ISceneSerializableComponent[];
  97016. /**
  97017. * List of components to register on the next registration step.
  97018. */
  97019. private _transientComponents;
  97020. /**
  97021. * Registers the transient components if needed.
  97022. */
  97023. private _registerTransientComponents;
  97024. /**
  97025. * @hidden
  97026. * Add a component to the scene.
  97027. * Note that the ccomponent could be registered on th next frame if this is called after
  97028. * the register component stage.
  97029. * @param component Defines the component to add to the scene
  97030. */
  97031. _addComponent(component: ISceneComponent): void;
  97032. /**
  97033. * @hidden
  97034. * Gets a component from the scene.
  97035. * @param name defines the name of the component to retrieve
  97036. * @returns the component or null if not present
  97037. */
  97038. _getComponent(name: string): Nullable<ISceneComponent>;
  97039. /**
  97040. * @hidden
  97041. * Defines the actions happening before camera updates.
  97042. */
  97043. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97044. /**
  97045. * @hidden
  97046. * Defines the actions happening before clear the canvas.
  97047. */
  97048. _beforeClearStage: Stage<SimpleStageAction>;
  97049. /**
  97050. * @hidden
  97051. * Defines the actions when collecting render targets for the frame.
  97052. */
  97053. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97054. /**
  97055. * @hidden
  97056. * Defines the actions happening for one camera in the frame.
  97057. */
  97058. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97059. /**
  97060. * @hidden
  97061. * Defines the actions happening during the per mesh ready checks.
  97062. */
  97063. _isReadyForMeshStage: Stage<MeshStageAction>;
  97064. /**
  97065. * @hidden
  97066. * Defines the actions happening before evaluate active mesh checks.
  97067. */
  97068. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97069. /**
  97070. * @hidden
  97071. * Defines the actions happening during the evaluate sub mesh checks.
  97072. */
  97073. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97074. /**
  97075. * @hidden
  97076. * Defines the actions happening during the active mesh stage.
  97077. */
  97078. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97079. /**
  97080. * @hidden
  97081. * Defines the actions happening during the per camera render target step.
  97082. */
  97083. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97084. /**
  97085. * @hidden
  97086. * Defines the actions happening just before the active camera is drawing.
  97087. */
  97088. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97089. /**
  97090. * @hidden
  97091. * Defines the actions happening just before a render target is drawing.
  97092. */
  97093. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97094. /**
  97095. * @hidden
  97096. * Defines the actions happening just before a rendering group is drawing.
  97097. */
  97098. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97099. /**
  97100. * @hidden
  97101. * Defines the actions happening just before a mesh is drawing.
  97102. */
  97103. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97104. /**
  97105. * @hidden
  97106. * Defines the actions happening just after a mesh has been drawn.
  97107. */
  97108. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97109. /**
  97110. * @hidden
  97111. * Defines the actions happening just after a rendering group has been drawn.
  97112. */
  97113. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97114. /**
  97115. * @hidden
  97116. * Defines the actions happening just after the active camera has been drawn.
  97117. */
  97118. _afterCameraDrawStage: Stage<CameraStageAction>;
  97119. /**
  97120. * @hidden
  97121. * Defines the actions happening just after a render target has been drawn.
  97122. */
  97123. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97124. /**
  97125. * @hidden
  97126. * Defines the actions happening just after rendering all cameras and computing intersections.
  97127. */
  97128. _afterRenderStage: Stage<SimpleStageAction>;
  97129. /**
  97130. * @hidden
  97131. * Defines the actions happening when a pointer move event happens.
  97132. */
  97133. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97134. /**
  97135. * @hidden
  97136. * Defines the actions happening when a pointer down event happens.
  97137. */
  97138. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97139. /**
  97140. * @hidden
  97141. * Defines the actions happening when a pointer up event happens.
  97142. */
  97143. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97144. /**
  97145. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97146. */
  97147. private geometriesByUniqueId;
  97148. /**
  97149. * Creates a new Scene
  97150. * @param engine defines the engine to use to render this scene
  97151. * @param options defines the scene options
  97152. */
  97153. constructor(engine: Engine, options?: SceneOptions);
  97154. /**
  97155. * Gets a string idenfifying the name of the class
  97156. * @returns "Scene" string
  97157. */
  97158. getClassName(): string;
  97159. private _defaultMeshCandidates;
  97160. /**
  97161. * @hidden
  97162. */
  97163. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97164. private _defaultSubMeshCandidates;
  97165. /**
  97166. * @hidden
  97167. */
  97168. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97169. /**
  97170. * Sets the default candidate providers for the scene.
  97171. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97172. * and getCollidingSubMeshCandidates to their default function
  97173. */
  97174. setDefaultCandidateProviders(): void;
  97175. /**
  97176. * Gets the mesh that is currently under the pointer
  97177. */
  97178. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97179. /**
  97180. * Gets or sets the current on-screen X position of the pointer
  97181. */
  97182. pointerX: number;
  97183. /**
  97184. * Gets or sets the current on-screen Y position of the pointer
  97185. */
  97186. pointerY: number;
  97187. /**
  97188. * Gets the cached material (ie. the latest rendered one)
  97189. * @returns the cached material
  97190. */
  97191. getCachedMaterial(): Nullable<Material>;
  97192. /**
  97193. * Gets the cached effect (ie. the latest rendered one)
  97194. * @returns the cached effect
  97195. */
  97196. getCachedEffect(): Nullable<Effect>;
  97197. /**
  97198. * Gets the cached visibility state (ie. the latest rendered one)
  97199. * @returns the cached visibility state
  97200. */
  97201. getCachedVisibility(): Nullable<number>;
  97202. /**
  97203. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97204. * @param material defines the current material
  97205. * @param effect defines the current effect
  97206. * @param visibility defines the current visibility state
  97207. * @returns true if one parameter is not cached
  97208. */
  97209. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97210. /**
  97211. * Gets the engine associated with the scene
  97212. * @returns an Engine
  97213. */
  97214. getEngine(): Engine;
  97215. /**
  97216. * Gets the total number of vertices rendered per frame
  97217. * @returns the total number of vertices rendered per frame
  97218. */
  97219. getTotalVertices(): number;
  97220. /**
  97221. * Gets the performance counter for total vertices
  97222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97223. */
  97224. readonly totalVerticesPerfCounter: PerfCounter;
  97225. /**
  97226. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97227. * @returns the total number of active indices rendered per frame
  97228. */
  97229. getActiveIndices(): number;
  97230. /**
  97231. * Gets the performance counter for active indices
  97232. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97233. */
  97234. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97235. /**
  97236. * Gets the total number of active particles rendered per frame
  97237. * @returns the total number of active particles rendered per frame
  97238. */
  97239. getActiveParticles(): number;
  97240. /**
  97241. * Gets the performance counter for active particles
  97242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97243. */
  97244. readonly activeParticlesPerfCounter: PerfCounter;
  97245. /**
  97246. * Gets the total number of active bones rendered per frame
  97247. * @returns the total number of active bones rendered per frame
  97248. */
  97249. getActiveBones(): number;
  97250. /**
  97251. * Gets the performance counter for active bones
  97252. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97253. */
  97254. readonly activeBonesPerfCounter: PerfCounter;
  97255. /**
  97256. * Gets the array of active meshes
  97257. * @returns an array of AbstractMesh
  97258. */
  97259. getActiveMeshes(): SmartArray<AbstractMesh>;
  97260. /**
  97261. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97262. * @returns a number
  97263. */
  97264. getAnimationRatio(): number;
  97265. /**
  97266. * Gets an unique Id for the current render phase
  97267. * @returns a number
  97268. */
  97269. getRenderId(): number;
  97270. /**
  97271. * Gets an unique Id for the current frame
  97272. * @returns a number
  97273. */
  97274. getFrameId(): number;
  97275. /** Call this function if you want to manually increment the render Id*/
  97276. incrementRenderId(): void;
  97277. private _createUbo;
  97278. /**
  97279. * Use this method to simulate a pointer move on a mesh
  97280. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97281. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97282. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97283. * @returns the current scene
  97284. */
  97285. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97286. /**
  97287. * Use this method to simulate a pointer down on a mesh
  97288. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97289. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97290. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97291. * @returns the current scene
  97292. */
  97293. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97294. /**
  97295. * Use this method to simulate a pointer up on a mesh
  97296. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97297. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97298. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97299. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97300. * @returns the current scene
  97301. */
  97302. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97303. /**
  97304. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97305. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97306. * @returns true if the pointer was captured
  97307. */
  97308. isPointerCaptured(pointerId?: number): boolean;
  97309. /**
  97310. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97311. * @param attachUp defines if you want to attach events to pointerup
  97312. * @param attachDown defines if you want to attach events to pointerdown
  97313. * @param attachMove defines if you want to attach events to pointermove
  97314. */
  97315. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97316. /** Detaches all event handlers*/
  97317. detachControl(): void;
  97318. /**
  97319. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97320. * Delay loaded resources are not taking in account
  97321. * @return true if all required resources are ready
  97322. */
  97323. isReady(): boolean;
  97324. /** Resets all cached information relative to material (including effect and visibility) */
  97325. resetCachedMaterial(): void;
  97326. /**
  97327. * Registers a function to be called before every frame render
  97328. * @param func defines the function to register
  97329. */
  97330. registerBeforeRender(func: () => void): void;
  97331. /**
  97332. * Unregisters a function called before every frame render
  97333. * @param func defines the function to unregister
  97334. */
  97335. unregisterBeforeRender(func: () => void): void;
  97336. /**
  97337. * Registers a function to be called after every frame render
  97338. * @param func defines the function to register
  97339. */
  97340. registerAfterRender(func: () => void): void;
  97341. /**
  97342. * Unregisters a function called after every frame render
  97343. * @param func defines the function to unregister
  97344. */
  97345. unregisterAfterRender(func: () => void): void;
  97346. private _executeOnceBeforeRender;
  97347. /**
  97348. * The provided function will run before render once and will be disposed afterwards.
  97349. * A timeout delay can be provided so that the function will be executed in N ms.
  97350. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97351. * @param func The function to be executed.
  97352. * @param timeout optional delay in ms
  97353. */
  97354. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97355. /** @hidden */
  97356. _addPendingData(data: any): void;
  97357. /** @hidden */
  97358. _removePendingData(data: any): void;
  97359. /**
  97360. * Returns the number of items waiting to be loaded
  97361. * @returns the number of items waiting to be loaded
  97362. */
  97363. getWaitingItemsCount(): number;
  97364. /**
  97365. * Returns a boolean indicating if the scene is still loading data
  97366. */
  97367. readonly isLoading: boolean;
  97368. /**
  97369. * Registers a function to be executed when the scene is ready
  97370. * @param {Function} func - the function to be executed
  97371. */
  97372. executeWhenReady(func: () => void): void;
  97373. /**
  97374. * Returns a promise that resolves when the scene is ready
  97375. * @returns A promise that resolves when the scene is ready
  97376. */
  97377. whenReadyAsync(): Promise<void>;
  97378. /** @hidden */
  97379. _checkIsReady(): void;
  97380. /**
  97381. * Gets all animatable attached to the scene
  97382. */
  97383. readonly animatables: Animatable[];
  97384. /**
  97385. * Resets the last animation time frame.
  97386. * Useful to override when animations start running when loading a scene for the first time.
  97387. */
  97388. resetLastAnimationTimeFrame(): void;
  97389. /**
  97390. * Gets the current view matrix
  97391. * @returns a Matrix
  97392. */
  97393. getViewMatrix(): Matrix;
  97394. /**
  97395. * Gets the current projection matrix
  97396. * @returns a Matrix
  97397. */
  97398. getProjectionMatrix(): Matrix;
  97399. /**
  97400. * Gets the current transform matrix
  97401. * @returns a Matrix made of View * Projection
  97402. */
  97403. getTransformMatrix(): Matrix;
  97404. /**
  97405. * Sets the current transform matrix
  97406. * @param viewL defines the View matrix to use
  97407. * @param projectionL defines the Projection matrix to use
  97408. * @param viewR defines the right View matrix to use (if provided)
  97409. * @param projectionR defines the right Projection matrix to use (if provided)
  97410. */
  97411. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97412. /**
  97413. * Gets the uniform buffer used to store scene data
  97414. * @returns a UniformBuffer
  97415. */
  97416. getSceneUniformBuffer(): UniformBuffer;
  97417. /**
  97418. * Gets an unique (relatively to the current scene) Id
  97419. * @returns an unique number for the scene
  97420. */
  97421. getUniqueId(): number;
  97422. /**
  97423. * Add a mesh to the list of scene's meshes
  97424. * @param newMesh defines the mesh to add
  97425. * @param recursive if all child meshes should also be added to the scene
  97426. */
  97427. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97428. /**
  97429. * Remove a mesh for the list of scene's meshes
  97430. * @param toRemove defines the mesh to remove
  97431. * @param recursive if all child meshes should also be removed from the scene
  97432. * @returns the index where the mesh was in the mesh list
  97433. */
  97434. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97435. /**
  97436. * Add a transform node to the list of scene's transform nodes
  97437. * @param newTransformNode defines the transform node to add
  97438. */
  97439. addTransformNode(newTransformNode: TransformNode): void;
  97440. /**
  97441. * Remove a transform node for the list of scene's transform nodes
  97442. * @param toRemove defines the transform node to remove
  97443. * @returns the index where the transform node was in the transform node list
  97444. */
  97445. removeTransformNode(toRemove: TransformNode): number;
  97446. /**
  97447. * Remove a skeleton for the list of scene's skeletons
  97448. * @param toRemove defines the skeleton to remove
  97449. * @returns the index where the skeleton was in the skeleton list
  97450. */
  97451. removeSkeleton(toRemove: Skeleton): number;
  97452. /**
  97453. * Remove a morph target for the list of scene's morph targets
  97454. * @param toRemove defines the morph target to remove
  97455. * @returns the index where the morph target was in the morph target list
  97456. */
  97457. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97458. /**
  97459. * Remove a light for the list of scene's lights
  97460. * @param toRemove defines the light to remove
  97461. * @returns the index where the light was in the light list
  97462. */
  97463. removeLight(toRemove: Light): number;
  97464. /**
  97465. * Remove a camera for the list of scene's cameras
  97466. * @param toRemove defines the camera to remove
  97467. * @returns the index where the camera was in the camera list
  97468. */
  97469. removeCamera(toRemove: Camera): number;
  97470. /**
  97471. * Remove a particle system for the list of scene's particle systems
  97472. * @param toRemove defines the particle system to remove
  97473. * @returns the index where the particle system was in the particle system list
  97474. */
  97475. removeParticleSystem(toRemove: IParticleSystem): number;
  97476. /**
  97477. * Remove a animation for the list of scene's animations
  97478. * @param toRemove defines the animation to remove
  97479. * @returns the index where the animation was in the animation list
  97480. */
  97481. removeAnimation(toRemove: Animation): number;
  97482. /**
  97483. * Will stop the animation of the given target
  97484. * @param target - the target
  97485. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97486. * @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)
  97487. */
  97488. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97489. /**
  97490. * Removes the given animation group from this scene.
  97491. * @param toRemove The animation group to remove
  97492. * @returns The index of the removed animation group
  97493. */
  97494. removeAnimationGroup(toRemove: AnimationGroup): number;
  97495. /**
  97496. * Removes the given multi-material from this scene.
  97497. * @param toRemove The multi-material to remove
  97498. * @returns The index of the removed multi-material
  97499. */
  97500. removeMultiMaterial(toRemove: MultiMaterial): number;
  97501. /**
  97502. * Removes the given material from this scene.
  97503. * @param toRemove The material to remove
  97504. * @returns The index of the removed material
  97505. */
  97506. removeMaterial(toRemove: Material): number;
  97507. /**
  97508. * Removes the given action manager from this scene.
  97509. * @param toRemove The action manager to remove
  97510. * @returns The index of the removed action manager
  97511. */
  97512. removeActionManager(toRemove: AbstractActionManager): number;
  97513. /**
  97514. * Removes the given texture from this scene.
  97515. * @param toRemove The texture to remove
  97516. * @returns The index of the removed texture
  97517. */
  97518. removeTexture(toRemove: BaseTexture): number;
  97519. /**
  97520. * Adds the given light to this scene
  97521. * @param newLight The light to add
  97522. */
  97523. addLight(newLight: Light): void;
  97524. /**
  97525. * Sorts the list list based on light priorities
  97526. */
  97527. sortLightsByPriority(): void;
  97528. /**
  97529. * Adds the given camera to this scene
  97530. * @param newCamera The camera to add
  97531. */
  97532. addCamera(newCamera: Camera): void;
  97533. /**
  97534. * Adds the given skeleton to this scene
  97535. * @param newSkeleton The skeleton to add
  97536. */
  97537. addSkeleton(newSkeleton: Skeleton): void;
  97538. /**
  97539. * Adds the given particle system to this scene
  97540. * @param newParticleSystem The particle system to add
  97541. */
  97542. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97543. /**
  97544. * Adds the given animation to this scene
  97545. * @param newAnimation The animation to add
  97546. */
  97547. addAnimation(newAnimation: Animation): void;
  97548. /**
  97549. * Adds the given animation group to this scene.
  97550. * @param newAnimationGroup The animation group to add
  97551. */
  97552. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97553. /**
  97554. * Adds the given multi-material to this scene
  97555. * @param newMultiMaterial The multi-material to add
  97556. */
  97557. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97558. /**
  97559. * Adds the given material to this scene
  97560. * @param newMaterial The material to add
  97561. */
  97562. addMaterial(newMaterial: Material): void;
  97563. /**
  97564. * Adds the given morph target to this scene
  97565. * @param newMorphTargetManager The morph target to add
  97566. */
  97567. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97568. /**
  97569. * Adds the given geometry to this scene
  97570. * @param newGeometry The geometry to add
  97571. */
  97572. addGeometry(newGeometry: Geometry): void;
  97573. /**
  97574. * Adds the given action manager to this scene
  97575. * @param newActionManager The action manager to add
  97576. */
  97577. addActionManager(newActionManager: AbstractActionManager): void;
  97578. /**
  97579. * Adds the given texture to this scene.
  97580. * @param newTexture The texture to add
  97581. */
  97582. addTexture(newTexture: BaseTexture): void;
  97583. /**
  97584. * Switch active camera
  97585. * @param newCamera defines the new active camera
  97586. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97587. */
  97588. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97589. /**
  97590. * sets the active camera of the scene using its ID
  97591. * @param id defines the camera's ID
  97592. * @return the new active camera or null if none found.
  97593. */
  97594. setActiveCameraByID(id: string): Nullable<Camera>;
  97595. /**
  97596. * sets the active camera of the scene using its name
  97597. * @param name defines the camera's name
  97598. * @returns the new active camera or null if none found.
  97599. */
  97600. setActiveCameraByName(name: string): Nullable<Camera>;
  97601. /**
  97602. * get an animation group using its name
  97603. * @param name defines the material's name
  97604. * @return the animation group or null if none found.
  97605. */
  97606. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97607. /**
  97608. * Get a material using its unique id
  97609. * @param uniqueId defines the material's unique id
  97610. * @return the material or null if none found.
  97611. */
  97612. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97613. /**
  97614. * get a material using its id
  97615. * @param id defines the material's ID
  97616. * @return the material or null if none found.
  97617. */
  97618. getMaterialByID(id: string): Nullable<Material>;
  97619. /**
  97620. * Gets a the last added material using a given id
  97621. * @param id defines the material's ID
  97622. * @return the last material with the given id or null if none found.
  97623. */
  97624. getLastMaterialByID(id: string): Nullable<Material>;
  97625. /**
  97626. * Gets a material using its name
  97627. * @param name defines the material's name
  97628. * @return the material or null if none found.
  97629. */
  97630. getMaterialByName(name: string): Nullable<Material>;
  97631. /**
  97632. * Gets a camera using its id
  97633. * @param id defines the id to look for
  97634. * @returns the camera or null if not found
  97635. */
  97636. getCameraByID(id: string): Nullable<Camera>;
  97637. /**
  97638. * Gets a camera using its unique id
  97639. * @param uniqueId defines the unique id to look for
  97640. * @returns the camera or null if not found
  97641. */
  97642. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97643. /**
  97644. * Gets a camera using its name
  97645. * @param name defines the camera's name
  97646. * @return the camera or null if none found.
  97647. */
  97648. getCameraByName(name: string): Nullable<Camera>;
  97649. /**
  97650. * Gets a bone using its id
  97651. * @param id defines the bone's id
  97652. * @return the bone or null if not found
  97653. */
  97654. getBoneByID(id: string): Nullable<Bone>;
  97655. /**
  97656. * Gets a bone using its id
  97657. * @param name defines the bone's name
  97658. * @return the bone or null if not found
  97659. */
  97660. getBoneByName(name: string): Nullable<Bone>;
  97661. /**
  97662. * Gets a light node using its name
  97663. * @param name defines the the light's name
  97664. * @return the light or null if none found.
  97665. */
  97666. getLightByName(name: string): Nullable<Light>;
  97667. /**
  97668. * Gets a light node using its id
  97669. * @param id defines the light's id
  97670. * @return the light or null if none found.
  97671. */
  97672. getLightByID(id: string): Nullable<Light>;
  97673. /**
  97674. * Gets a light node using its scene-generated unique ID
  97675. * @param uniqueId defines the light's unique id
  97676. * @return the light or null if none found.
  97677. */
  97678. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97679. /**
  97680. * Gets a particle system by id
  97681. * @param id defines the particle system id
  97682. * @return the corresponding system or null if none found
  97683. */
  97684. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97685. /**
  97686. * Gets a geometry using its ID
  97687. * @param id defines the geometry's id
  97688. * @return the geometry or null if none found.
  97689. */
  97690. getGeometryByID(id: string): Nullable<Geometry>;
  97691. private _getGeometryByUniqueID;
  97692. /**
  97693. * Add a new geometry to this scene
  97694. * @param geometry defines the geometry to be added to the scene.
  97695. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97696. * @return a boolean defining if the geometry was added or not
  97697. */
  97698. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97699. /**
  97700. * Removes an existing geometry
  97701. * @param geometry defines the geometry to be removed from the scene
  97702. * @return a boolean defining if the geometry was removed or not
  97703. */
  97704. removeGeometry(geometry: Geometry): boolean;
  97705. /**
  97706. * Gets the list of geometries attached to the scene
  97707. * @returns an array of Geometry
  97708. */
  97709. getGeometries(): Geometry[];
  97710. /**
  97711. * Gets the first added mesh found of a given ID
  97712. * @param id defines the id to search for
  97713. * @return the mesh found or null if not found at all
  97714. */
  97715. getMeshByID(id: string): Nullable<AbstractMesh>;
  97716. /**
  97717. * Gets a list of meshes using their id
  97718. * @param id defines the id to search for
  97719. * @returns a list of meshes
  97720. */
  97721. getMeshesByID(id: string): Array<AbstractMesh>;
  97722. /**
  97723. * Gets the first added transform node found of a given ID
  97724. * @param id defines the id to search for
  97725. * @return the found transform node or null if not found at all.
  97726. */
  97727. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97728. /**
  97729. * Gets a transform node with its auto-generated unique id
  97730. * @param uniqueId efines the unique id to search for
  97731. * @return the found transform node or null if not found at all.
  97732. */
  97733. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97734. /**
  97735. * Gets a list of transform nodes using their id
  97736. * @param id defines the id to search for
  97737. * @returns a list of transform nodes
  97738. */
  97739. getTransformNodesByID(id: string): Array<TransformNode>;
  97740. /**
  97741. * Gets a mesh with its auto-generated unique id
  97742. * @param uniqueId defines the unique id to search for
  97743. * @return the found mesh or null if not found at all.
  97744. */
  97745. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97746. /**
  97747. * Gets a the last added mesh using a given id
  97748. * @param id defines the id to search for
  97749. * @return the found mesh or null if not found at all.
  97750. */
  97751. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97752. /**
  97753. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97754. * @param id defines the id to search for
  97755. * @return the found node or null if not found at all
  97756. */
  97757. getLastEntryByID(id: string): Nullable<Node>;
  97758. /**
  97759. * Gets a node (Mesh, Camera, Light) using a given id
  97760. * @param id defines the id to search for
  97761. * @return the found node or null if not found at all
  97762. */
  97763. getNodeByID(id: string): Nullable<Node>;
  97764. /**
  97765. * Gets a node (Mesh, Camera, Light) using a given name
  97766. * @param name defines the name to search for
  97767. * @return the found node or null if not found at all.
  97768. */
  97769. getNodeByName(name: string): Nullable<Node>;
  97770. /**
  97771. * Gets a mesh using a given name
  97772. * @param name defines the name to search for
  97773. * @return the found mesh or null if not found at all.
  97774. */
  97775. getMeshByName(name: string): Nullable<AbstractMesh>;
  97776. /**
  97777. * Gets a transform node using a given name
  97778. * @param name defines the name to search for
  97779. * @return the found transform node or null if not found at all.
  97780. */
  97781. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97782. /**
  97783. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97784. * @param id defines the id to search for
  97785. * @return the found skeleton or null if not found at all.
  97786. */
  97787. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97788. /**
  97789. * Gets a skeleton using a given auto generated unique id
  97790. * @param uniqueId defines the unique id to search for
  97791. * @return the found skeleton or null if not found at all.
  97792. */
  97793. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97794. /**
  97795. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97796. * @param id defines the id to search for
  97797. * @return the found skeleton or null if not found at all.
  97798. */
  97799. getSkeletonById(id: string): Nullable<Skeleton>;
  97800. /**
  97801. * Gets a skeleton using a given name
  97802. * @param name defines the name to search for
  97803. * @return the found skeleton or null if not found at all.
  97804. */
  97805. getSkeletonByName(name: string): Nullable<Skeleton>;
  97806. /**
  97807. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97808. * @param id defines the id to search for
  97809. * @return the found morph target manager or null if not found at all.
  97810. */
  97811. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  97812. /**
  97813. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  97814. * @param id defines the id to search for
  97815. * @return the found morph target or null if not found at all.
  97816. */
  97817. getMorphTargetById(id: string): Nullable<MorphTarget>;
  97818. /**
  97819. * Gets a boolean indicating if the given mesh is active
  97820. * @param mesh defines the mesh to look for
  97821. * @returns true if the mesh is in the active list
  97822. */
  97823. isActiveMesh(mesh: AbstractMesh): boolean;
  97824. /**
  97825. * Return a unique id as a string which can serve as an identifier for the scene
  97826. */
  97827. readonly uid: string;
  97828. /**
  97829. * Add an externaly attached data from its key.
  97830. * This method call will fail and return false, if such key already exists.
  97831. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97832. * @param key the unique key that identifies the data
  97833. * @param data the data object to associate to the key for this Engine instance
  97834. * @return true if no such key were already present and the data was added successfully, false otherwise
  97835. */
  97836. addExternalData<T>(key: string, data: T): boolean;
  97837. /**
  97838. * Get an externaly attached data from its key
  97839. * @param key the unique key that identifies the data
  97840. * @return the associated data, if present (can be null), or undefined if not present
  97841. */
  97842. getExternalData<T>(key: string): Nullable<T>;
  97843. /**
  97844. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97845. * @param key the unique key that identifies the data
  97846. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97847. * @return the associated data, can be null if the factory returned null.
  97848. */
  97849. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97850. /**
  97851. * Remove an externaly attached data from the Engine instance
  97852. * @param key the unique key that identifies the data
  97853. * @return true if the data was successfully removed, false if it doesn't exist
  97854. */
  97855. removeExternalData(key: string): boolean;
  97856. private _evaluateSubMesh;
  97857. /**
  97858. * Clear the processed materials smart array preventing retention point in material dispose.
  97859. */
  97860. freeProcessedMaterials(): void;
  97861. private _preventFreeActiveMeshesAndRenderingGroups;
  97862. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  97863. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  97864. * when disposing several meshes in a row or a hierarchy of meshes.
  97865. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  97866. */
  97867. blockfreeActiveMeshesAndRenderingGroups: boolean;
  97868. /**
  97869. * Clear the active meshes smart array preventing retention point in mesh dispose.
  97870. */
  97871. freeActiveMeshes(): void;
  97872. /**
  97873. * Clear the info related to rendering groups preventing retention points during dispose.
  97874. */
  97875. freeRenderingGroups(): void;
  97876. /** @hidden */
  97877. _isInIntermediateRendering(): boolean;
  97878. /**
  97879. * Lambda returning the list of potentially active meshes.
  97880. */
  97881. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  97882. /**
  97883. * Lambda returning the list of potentially active sub meshes.
  97884. */
  97885. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  97886. /**
  97887. * Lambda returning the list of potentially intersecting sub meshes.
  97888. */
  97889. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  97890. /**
  97891. * Lambda returning the list of potentially colliding sub meshes.
  97892. */
  97893. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  97894. private _activeMeshesFrozen;
  97895. /**
  97896. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  97897. * @returns the current scene
  97898. */
  97899. freezeActiveMeshes(): Scene;
  97900. /**
  97901. * Use this function to restart evaluating active meshes on every frame
  97902. * @returns the current scene
  97903. */
  97904. unfreezeActiveMeshes(): Scene;
  97905. private _evaluateActiveMeshes;
  97906. private _activeMesh;
  97907. /**
  97908. * Update the transform matrix to update from the current active camera
  97909. * @param force defines a boolean used to force the update even if cache is up to date
  97910. */
  97911. updateTransformMatrix(force?: boolean): void;
  97912. private _bindFrameBuffer;
  97913. /** @hidden */
  97914. _allowPostProcessClearColor: boolean;
  97915. /** @hidden */
  97916. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  97917. private _processSubCameras;
  97918. private _checkIntersections;
  97919. /** @hidden */
  97920. _advancePhysicsEngineStep(step: number): void;
  97921. /**
  97922. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  97923. */
  97924. getDeterministicFrameTime: () => number;
  97925. /** @hidden */
  97926. _animate(): void;
  97927. /** Execute all animations (for a frame) */
  97928. animate(): void;
  97929. /**
  97930. * Render the scene
  97931. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  97932. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  97933. */
  97934. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  97935. /**
  97936. * Freeze all materials
  97937. * A frozen material will not be updatable but should be faster to render
  97938. */
  97939. freezeMaterials(): void;
  97940. /**
  97941. * Unfreeze all materials
  97942. * A frozen material will not be updatable but should be faster to render
  97943. */
  97944. unfreezeMaterials(): void;
  97945. /**
  97946. * Releases all held ressources
  97947. */
  97948. dispose(): void;
  97949. /**
  97950. * Gets if the scene is already disposed
  97951. */
  97952. readonly isDisposed: boolean;
  97953. /**
  97954. * Call this function to reduce memory footprint of the scene.
  97955. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  97956. */
  97957. clearCachedVertexData(): void;
  97958. /**
  97959. * This function will remove the local cached buffer data from texture.
  97960. * It will save memory but will prevent the texture from being rebuilt
  97961. */
  97962. cleanCachedTextureBuffer(): void;
  97963. /**
  97964. * Get the world extend vectors with an optional filter
  97965. *
  97966. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  97967. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  97968. */
  97969. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  97970. min: Vector3;
  97971. max: Vector3;
  97972. };
  97973. /**
  97974. * Creates a ray that can be used to pick in the scene
  97975. * @param x defines the x coordinate of the origin (on-screen)
  97976. * @param y defines the y coordinate of the origin (on-screen)
  97977. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97978. * @param camera defines the camera to use for the picking
  97979. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97980. * @returns a Ray
  97981. */
  97982. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  97983. /**
  97984. * Creates a ray that can be used to pick in the scene
  97985. * @param x defines the x coordinate of the origin (on-screen)
  97986. * @param y defines the y coordinate of the origin (on-screen)
  97987. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97988. * @param result defines the ray where to store the picking ray
  97989. * @param camera defines the camera to use for the picking
  97990. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97991. * @returns the current scene
  97992. */
  97993. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  97994. /**
  97995. * Creates a ray that can be used to pick in the scene
  97996. * @param x defines the x coordinate of the origin (on-screen)
  97997. * @param y defines the y coordinate of the origin (on-screen)
  97998. * @param camera defines the camera to use for the picking
  97999. * @returns a Ray
  98000. */
  98001. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  98002. /**
  98003. * Creates a ray that can be used to pick in the scene
  98004. * @param x defines the x coordinate of the origin (on-screen)
  98005. * @param y defines the y coordinate of the origin (on-screen)
  98006. * @param result defines the ray where to store the picking ray
  98007. * @param camera defines the camera to use for the picking
  98008. * @returns the current scene
  98009. */
  98010. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  98011. /** Launch a ray to try to pick a mesh in the scene
  98012. * @param x position on screen
  98013. * @param y position on screen
  98014. * @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
  98015. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  98016. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98017. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98018. * @returns a PickingInfo
  98019. */
  98020. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98021. /** Use the given ray to pick a mesh in the scene
  98022. * @param ray The ray to use to pick meshes
  98023. * @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
  98024. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  98025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98026. * @returns a PickingInfo
  98027. */
  98028. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  98029. /**
  98030. * Launch a ray to try to pick a mesh in the scene
  98031. * @param x X position on screen
  98032. * @param y Y position on screen
  98033. * @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
  98034. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98035. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98036. * @returns an array of PickingInfo
  98037. */
  98038. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98039. /**
  98040. * Launch a ray to try to pick a mesh in the scene
  98041. * @param ray Ray to use
  98042. * @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
  98043. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98044. * @returns an array of PickingInfo
  98045. */
  98046. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98047. /**
  98048. * Force the value of meshUnderPointer
  98049. * @param mesh defines the mesh to use
  98050. */
  98051. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98052. /**
  98053. * Gets the mesh under the pointer
  98054. * @returns a Mesh or null if no mesh is under the pointer
  98055. */
  98056. getPointerOverMesh(): Nullable<AbstractMesh>;
  98057. /** @hidden */
  98058. _rebuildGeometries(): void;
  98059. /** @hidden */
  98060. _rebuildTextures(): void;
  98061. private _getByTags;
  98062. /**
  98063. * Get a list of meshes by tags
  98064. * @param tagsQuery defines the tags query to use
  98065. * @param forEach defines a predicate used to filter results
  98066. * @returns an array of Mesh
  98067. */
  98068. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98069. /**
  98070. * Get a list of cameras by tags
  98071. * @param tagsQuery defines the tags query to use
  98072. * @param forEach defines a predicate used to filter results
  98073. * @returns an array of Camera
  98074. */
  98075. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98076. /**
  98077. * Get a list of lights by tags
  98078. * @param tagsQuery defines the tags query to use
  98079. * @param forEach defines a predicate used to filter results
  98080. * @returns an array of Light
  98081. */
  98082. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98083. /**
  98084. * Get a list of materials by tags
  98085. * @param tagsQuery defines the tags query to use
  98086. * @param forEach defines a predicate used to filter results
  98087. * @returns an array of Material
  98088. */
  98089. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98090. /**
  98091. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98092. * This allowed control for front to back rendering or reversly depending of the special needs.
  98093. *
  98094. * @param renderingGroupId The rendering group id corresponding to its index
  98095. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98096. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98097. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98098. */
  98099. 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;
  98100. /**
  98101. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98102. *
  98103. * @param renderingGroupId The rendering group id corresponding to its index
  98104. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98105. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98106. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98107. */
  98108. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98109. /**
  98110. * Gets the current auto clear configuration for one rendering group of the rendering
  98111. * manager.
  98112. * @param index the rendering group index to get the information for
  98113. * @returns The auto clear setup for the requested rendering group
  98114. */
  98115. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98116. private _blockMaterialDirtyMechanism;
  98117. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98118. blockMaterialDirtyMechanism: boolean;
  98119. /**
  98120. * Will flag all materials as dirty to trigger new shader compilation
  98121. * @param flag defines the flag used to specify which material part must be marked as dirty
  98122. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98123. */
  98124. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98125. /** @hidden */
  98126. _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;
  98127. /** @hidden */
  98128. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98129. }
  98130. }
  98131. declare module BABYLON {
  98132. /**
  98133. * Set of assets to keep when moving a scene into an asset container.
  98134. */
  98135. export class KeepAssets extends AbstractScene {
  98136. }
  98137. /**
  98138. * Container with a set of assets that can be added or removed from a scene.
  98139. */
  98140. export class AssetContainer extends AbstractScene {
  98141. /**
  98142. * The scene the AssetContainer belongs to.
  98143. */
  98144. scene: Scene;
  98145. /**
  98146. * Instantiates an AssetContainer.
  98147. * @param scene The scene the AssetContainer belongs to.
  98148. */
  98149. constructor(scene: Scene);
  98150. /**
  98151. * Adds all the assets from the container to the scene.
  98152. */
  98153. addAllToScene(): void;
  98154. /**
  98155. * Removes all the assets in the container from the scene
  98156. */
  98157. removeAllFromScene(): void;
  98158. /**
  98159. * Disposes all the assets in the container
  98160. */
  98161. dispose(): void;
  98162. private _moveAssets;
  98163. /**
  98164. * Removes all the assets contained in the scene and adds them to the container.
  98165. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98166. */
  98167. moveAllFromScene(keepAssets?: KeepAssets): void;
  98168. /**
  98169. * 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.
  98170. * @returns the root mesh
  98171. */
  98172. createRootMesh(): Mesh;
  98173. }
  98174. }
  98175. declare module BABYLON {
  98176. /**
  98177. * Defines how the parser contract is defined.
  98178. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98179. */
  98180. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98181. /**
  98182. * Defines how the individual parser contract is defined.
  98183. * These parser can parse an individual asset
  98184. */
  98185. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98186. /**
  98187. * Base class of the scene acting as a container for the different elements composing a scene.
  98188. * This class is dynamically extended by the different components of the scene increasing
  98189. * flexibility and reducing coupling
  98190. */
  98191. export abstract class AbstractScene {
  98192. /**
  98193. * Stores the list of available parsers in the application.
  98194. */
  98195. private static _BabylonFileParsers;
  98196. /**
  98197. * Stores the list of available individual parsers in the application.
  98198. */
  98199. private static _IndividualBabylonFileParsers;
  98200. /**
  98201. * Adds a parser in the list of available ones
  98202. * @param name Defines the name of the parser
  98203. * @param parser Defines the parser to add
  98204. */
  98205. static AddParser(name: string, parser: BabylonFileParser): void;
  98206. /**
  98207. * Gets a general parser from the list of avaialble ones
  98208. * @param name Defines the name of the parser
  98209. * @returns the requested parser or null
  98210. */
  98211. static GetParser(name: string): Nullable<BabylonFileParser>;
  98212. /**
  98213. * Adds n individual parser in the list of available ones
  98214. * @param name Defines the name of the parser
  98215. * @param parser Defines the parser to add
  98216. */
  98217. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98218. /**
  98219. * Gets an individual parser from the list of avaialble ones
  98220. * @param name Defines the name of the parser
  98221. * @returns the requested parser or null
  98222. */
  98223. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98224. /**
  98225. * Parser json data and populate both a scene and its associated container object
  98226. * @param jsonData Defines the data to parse
  98227. * @param scene Defines the scene to parse the data for
  98228. * @param container Defines the container attached to the parsing sequence
  98229. * @param rootUrl Defines the root url of the data
  98230. */
  98231. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98232. /**
  98233. * Gets the list of root nodes (ie. nodes with no parent)
  98234. */
  98235. rootNodes: Node[];
  98236. /** All of the cameras added to this scene
  98237. * @see http://doc.babylonjs.com/babylon101/cameras
  98238. */
  98239. cameras: Camera[];
  98240. /**
  98241. * All of the lights added to this scene
  98242. * @see http://doc.babylonjs.com/babylon101/lights
  98243. */
  98244. lights: Light[];
  98245. /**
  98246. * All of the (abstract) meshes added to this scene
  98247. */
  98248. meshes: AbstractMesh[];
  98249. /**
  98250. * The list of skeletons added to the scene
  98251. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98252. */
  98253. skeletons: Skeleton[];
  98254. /**
  98255. * All of the particle systems added to this scene
  98256. * @see http://doc.babylonjs.com/babylon101/particles
  98257. */
  98258. particleSystems: IParticleSystem[];
  98259. /**
  98260. * Gets a list of Animations associated with the scene
  98261. */
  98262. animations: Animation[];
  98263. /**
  98264. * All of the animation groups added to this scene
  98265. * @see http://doc.babylonjs.com/how_to/group
  98266. */
  98267. animationGroups: AnimationGroup[];
  98268. /**
  98269. * All of the multi-materials added to this scene
  98270. * @see http://doc.babylonjs.com/how_to/multi_materials
  98271. */
  98272. multiMaterials: MultiMaterial[];
  98273. /**
  98274. * All of the materials added to this scene
  98275. * In the context of a Scene, it is not supposed to be modified manually.
  98276. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98277. * Note also that the order of the Material wihin the array is not significant and might change.
  98278. * @see http://doc.babylonjs.com/babylon101/materials
  98279. */
  98280. materials: Material[];
  98281. /**
  98282. * The list of morph target managers added to the scene
  98283. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98284. */
  98285. morphTargetManagers: MorphTargetManager[];
  98286. /**
  98287. * The list of geometries used in the scene.
  98288. */
  98289. geometries: Geometry[];
  98290. /**
  98291. * All of the tranform nodes added to this scene
  98292. * In the context of a Scene, it is not supposed to be modified manually.
  98293. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98294. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98295. * @see http://doc.babylonjs.com/how_to/transformnode
  98296. */
  98297. transformNodes: TransformNode[];
  98298. /**
  98299. * ActionManagers available on the scene.
  98300. */
  98301. actionManagers: AbstractActionManager[];
  98302. /**
  98303. * Textures to keep.
  98304. */
  98305. textures: BaseTexture[];
  98306. /**
  98307. * Environment texture for the scene
  98308. */
  98309. environmentTexture: Nullable<BaseTexture>;
  98310. }
  98311. }
  98312. declare module BABYLON {
  98313. /**
  98314. * Interface used to define options for Sound class
  98315. */
  98316. export interface ISoundOptions {
  98317. /**
  98318. * Does the sound autoplay once loaded.
  98319. */
  98320. autoplay?: boolean;
  98321. /**
  98322. * Does the sound loop after it finishes playing once.
  98323. */
  98324. loop?: boolean;
  98325. /**
  98326. * Sound's volume
  98327. */
  98328. volume?: number;
  98329. /**
  98330. * Is it a spatial sound?
  98331. */
  98332. spatialSound?: boolean;
  98333. /**
  98334. * Maximum distance to hear that sound
  98335. */
  98336. maxDistance?: number;
  98337. /**
  98338. * Uses user defined attenuation function
  98339. */
  98340. useCustomAttenuation?: boolean;
  98341. /**
  98342. * Define the roll off factor of spatial sounds.
  98343. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98344. */
  98345. rolloffFactor?: number;
  98346. /**
  98347. * Define the reference distance the sound should be heard perfectly.
  98348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98349. */
  98350. refDistance?: number;
  98351. /**
  98352. * Define the distance attenuation model the sound will follow.
  98353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98354. */
  98355. distanceModel?: string;
  98356. /**
  98357. * Defines the playback speed (1 by default)
  98358. */
  98359. playbackRate?: number;
  98360. /**
  98361. * Defines if the sound is from a streaming source
  98362. */
  98363. streaming?: boolean;
  98364. /**
  98365. * Defines an optional length (in seconds) inside the sound file
  98366. */
  98367. length?: number;
  98368. /**
  98369. * Defines an optional offset (in seconds) inside the sound file
  98370. */
  98371. offset?: number;
  98372. /**
  98373. * If true, URLs will not be required to state the audio file codec to use.
  98374. */
  98375. skipCodecCheck?: boolean;
  98376. }
  98377. /**
  98378. * Defines a sound that can be played in the application.
  98379. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98381. */
  98382. export class Sound {
  98383. /**
  98384. * The name of the sound in the scene.
  98385. */
  98386. name: string;
  98387. /**
  98388. * Does the sound autoplay once loaded.
  98389. */
  98390. autoplay: boolean;
  98391. /**
  98392. * Does the sound loop after it finishes playing once.
  98393. */
  98394. loop: boolean;
  98395. /**
  98396. * Does the sound use a custom attenuation curve to simulate the falloff
  98397. * happening when the source gets further away from the camera.
  98398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98399. */
  98400. useCustomAttenuation: boolean;
  98401. /**
  98402. * The sound track id this sound belongs to.
  98403. */
  98404. soundTrackId: number;
  98405. /**
  98406. * Is this sound currently played.
  98407. */
  98408. isPlaying: boolean;
  98409. /**
  98410. * Is this sound currently paused.
  98411. */
  98412. isPaused: boolean;
  98413. /**
  98414. * Does this sound enables spatial sound.
  98415. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98416. */
  98417. spatialSound: boolean;
  98418. /**
  98419. * Define the reference distance the sound should be heard perfectly.
  98420. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98421. */
  98422. refDistance: number;
  98423. /**
  98424. * Define the roll off factor of spatial sounds.
  98425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98426. */
  98427. rolloffFactor: number;
  98428. /**
  98429. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98430. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98431. */
  98432. maxDistance: number;
  98433. /**
  98434. * Define the distance attenuation model the sound will follow.
  98435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98436. */
  98437. distanceModel: string;
  98438. /**
  98439. * @hidden
  98440. * Back Compat
  98441. **/
  98442. onended: () => any;
  98443. /**
  98444. * Observable event when the current playing sound finishes.
  98445. */
  98446. onEndedObservable: Observable<Sound>;
  98447. private _panningModel;
  98448. private _playbackRate;
  98449. private _streaming;
  98450. private _startTime;
  98451. private _startOffset;
  98452. private _position;
  98453. /** @hidden */
  98454. _positionInEmitterSpace: boolean;
  98455. private _localDirection;
  98456. private _volume;
  98457. private _isReadyToPlay;
  98458. private _isDirectional;
  98459. private _readyToPlayCallback;
  98460. private _audioBuffer;
  98461. private _soundSource;
  98462. private _streamingSource;
  98463. private _soundPanner;
  98464. private _soundGain;
  98465. private _inputAudioNode;
  98466. private _outputAudioNode;
  98467. private _coneInnerAngle;
  98468. private _coneOuterAngle;
  98469. private _coneOuterGain;
  98470. private _scene;
  98471. private _connectedTransformNode;
  98472. private _customAttenuationFunction;
  98473. private _registerFunc;
  98474. private _isOutputConnected;
  98475. private _htmlAudioElement;
  98476. private _urlType;
  98477. private _length?;
  98478. private _offset?;
  98479. /** @hidden */
  98480. static _SceneComponentInitialization: (scene: Scene) => void;
  98481. /**
  98482. * Create a sound and attach it to a scene
  98483. * @param name Name of your sound
  98484. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98485. * @param scene defines the scene the sound belongs to
  98486. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98487. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98488. */
  98489. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98490. /**
  98491. * Release the sound and its associated resources
  98492. */
  98493. dispose(): void;
  98494. /**
  98495. * Gets if the sounds is ready to be played or not.
  98496. * @returns true if ready, otherwise false
  98497. */
  98498. isReady(): boolean;
  98499. private _soundLoaded;
  98500. /**
  98501. * Sets the data of the sound from an audiobuffer
  98502. * @param audioBuffer The audioBuffer containing the data
  98503. */
  98504. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98505. /**
  98506. * Updates the current sounds options such as maxdistance, loop...
  98507. * @param options A JSON object containing values named as the object properties
  98508. */
  98509. updateOptions(options: ISoundOptions): void;
  98510. private _createSpatialParameters;
  98511. private _updateSpatialParameters;
  98512. /**
  98513. * Switch the panning model to HRTF:
  98514. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98516. */
  98517. switchPanningModelToHRTF(): void;
  98518. /**
  98519. * Switch the panning model to Equal Power:
  98520. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98522. */
  98523. switchPanningModelToEqualPower(): void;
  98524. private _switchPanningModel;
  98525. /**
  98526. * Connect this sound to a sound track audio node like gain...
  98527. * @param soundTrackAudioNode the sound track audio node to connect to
  98528. */
  98529. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98530. /**
  98531. * Transform this sound into a directional source
  98532. * @param coneInnerAngle Size of the inner cone in degree
  98533. * @param coneOuterAngle Size of the outer cone in degree
  98534. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98535. */
  98536. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98537. /**
  98538. * Gets or sets the inner angle for the directional cone.
  98539. */
  98540. /**
  98541. * Gets or sets the inner angle for the directional cone.
  98542. */
  98543. directionalConeInnerAngle: number;
  98544. /**
  98545. * Gets or sets the outer angle for the directional cone.
  98546. */
  98547. /**
  98548. * Gets or sets the outer angle for the directional cone.
  98549. */
  98550. directionalConeOuterAngle: number;
  98551. /**
  98552. * Sets the position of the emitter if spatial sound is enabled
  98553. * @param newPosition Defines the new posisiton
  98554. */
  98555. setPosition(newPosition: Vector3): void;
  98556. /**
  98557. * Sets the local direction of the emitter if spatial sound is enabled
  98558. * @param newLocalDirection Defines the new local direction
  98559. */
  98560. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98561. private _updateDirection;
  98562. /** @hidden */
  98563. updateDistanceFromListener(): void;
  98564. /**
  98565. * Sets a new custom attenuation function for the sound.
  98566. * @param callback Defines the function used for the attenuation
  98567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98568. */
  98569. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98570. /**
  98571. * Play the sound
  98572. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98573. * @param offset (optional) Start the sound at a specific time in seconds
  98574. * @param length (optional) Sound duration (in seconds)
  98575. */
  98576. play(time?: number, offset?: number, length?: number): void;
  98577. private _onended;
  98578. /**
  98579. * Stop the sound
  98580. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98581. */
  98582. stop(time?: number): void;
  98583. /**
  98584. * Put the sound in pause
  98585. */
  98586. pause(): void;
  98587. /**
  98588. * Sets a dedicated volume for this sounds
  98589. * @param newVolume Define the new volume of the sound
  98590. * @param time Define time for gradual change to new volume
  98591. */
  98592. setVolume(newVolume: number, time?: number): void;
  98593. /**
  98594. * Set the sound play back rate
  98595. * @param newPlaybackRate Define the playback rate the sound should be played at
  98596. */
  98597. setPlaybackRate(newPlaybackRate: number): void;
  98598. /**
  98599. * Gets the volume of the sound.
  98600. * @returns the volume of the sound
  98601. */
  98602. getVolume(): number;
  98603. /**
  98604. * Attach the sound to a dedicated mesh
  98605. * @param transformNode The transform node to connect the sound with
  98606. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98607. */
  98608. attachToMesh(transformNode: TransformNode): void;
  98609. /**
  98610. * Detach the sound from the previously attached mesh
  98611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98612. */
  98613. detachFromMesh(): void;
  98614. private _onRegisterAfterWorldMatrixUpdate;
  98615. /**
  98616. * Clone the current sound in the scene.
  98617. * @returns the new sound clone
  98618. */
  98619. clone(): Nullable<Sound>;
  98620. /**
  98621. * Gets the current underlying audio buffer containing the data
  98622. * @returns the audio buffer
  98623. */
  98624. getAudioBuffer(): Nullable<AudioBuffer>;
  98625. /**
  98626. * Serializes the Sound in a JSON representation
  98627. * @returns the JSON representation of the sound
  98628. */
  98629. serialize(): any;
  98630. /**
  98631. * Parse a JSON representation of a sound to innstantiate in a given scene
  98632. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98633. * @param scene Define the scene the new parsed sound should be created in
  98634. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98635. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98636. * @returns the newly parsed sound
  98637. */
  98638. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98639. }
  98640. }
  98641. declare module BABYLON {
  98642. /**
  98643. * This defines an action helpful to play a defined sound on a triggered action.
  98644. */
  98645. export class PlaySoundAction extends Action {
  98646. private _sound;
  98647. /**
  98648. * Instantiate the action
  98649. * @param triggerOptions defines the trigger options
  98650. * @param sound defines the sound to play
  98651. * @param condition defines the trigger related conditions
  98652. */
  98653. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98654. /** @hidden */
  98655. _prepare(): void;
  98656. /**
  98657. * Execute the action and play the sound.
  98658. */
  98659. execute(): void;
  98660. /**
  98661. * Serializes the actions and its related information.
  98662. * @param parent defines the object to serialize in
  98663. * @returns the serialized object
  98664. */
  98665. serialize(parent: any): any;
  98666. }
  98667. /**
  98668. * This defines an action helpful to stop a defined sound on a triggered action.
  98669. */
  98670. export class StopSoundAction extends Action {
  98671. private _sound;
  98672. /**
  98673. * Instantiate the action
  98674. * @param triggerOptions defines the trigger options
  98675. * @param sound defines the sound to stop
  98676. * @param condition defines the trigger related conditions
  98677. */
  98678. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98679. /** @hidden */
  98680. _prepare(): void;
  98681. /**
  98682. * Execute the action and stop the sound.
  98683. */
  98684. execute(): void;
  98685. /**
  98686. * Serializes the actions and its related information.
  98687. * @param parent defines the object to serialize in
  98688. * @returns the serialized object
  98689. */
  98690. serialize(parent: any): any;
  98691. }
  98692. }
  98693. declare module BABYLON {
  98694. /**
  98695. * This defines an action responsible to change the value of a property
  98696. * by interpolating between its current value and the newly set one once triggered.
  98697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98698. */
  98699. export class InterpolateValueAction extends Action {
  98700. /**
  98701. * Defines the path of the property where the value should be interpolated
  98702. */
  98703. propertyPath: string;
  98704. /**
  98705. * Defines the target value at the end of the interpolation.
  98706. */
  98707. value: any;
  98708. /**
  98709. * Defines the time it will take for the property to interpolate to the value.
  98710. */
  98711. duration: number;
  98712. /**
  98713. * Defines if the other scene animations should be stopped when the action has been triggered
  98714. */
  98715. stopOtherAnimations?: boolean;
  98716. /**
  98717. * Defines a callback raised once the interpolation animation has been done.
  98718. */
  98719. onInterpolationDone?: () => void;
  98720. /**
  98721. * Observable triggered once the interpolation animation has been done.
  98722. */
  98723. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98724. private _target;
  98725. private _effectiveTarget;
  98726. private _property;
  98727. /**
  98728. * Instantiate the action
  98729. * @param triggerOptions defines the trigger options
  98730. * @param target defines the object containing the value to interpolate
  98731. * @param propertyPath defines the path to the property in the target object
  98732. * @param value defines the target value at the end of the interpolation
  98733. * @param duration deines the time it will take for the property to interpolate to the value.
  98734. * @param condition defines the trigger related conditions
  98735. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98736. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98737. */
  98738. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98739. /** @hidden */
  98740. _prepare(): void;
  98741. /**
  98742. * Execute the action starts the value interpolation.
  98743. */
  98744. execute(): void;
  98745. /**
  98746. * Serializes the actions and its related information.
  98747. * @param parent defines the object to serialize in
  98748. * @returns the serialized object
  98749. */
  98750. serialize(parent: any): any;
  98751. }
  98752. }
  98753. declare module BABYLON {
  98754. /**
  98755. * Options allowed during the creation of a sound track.
  98756. */
  98757. export interface ISoundTrackOptions {
  98758. /**
  98759. * The volume the sound track should take during creation
  98760. */
  98761. volume?: number;
  98762. /**
  98763. * Define if the sound track is the main sound track of the scene
  98764. */
  98765. mainTrack?: boolean;
  98766. }
  98767. /**
  98768. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98769. * It will be also used in a future release to apply effects on a specific track.
  98770. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98771. */
  98772. export class SoundTrack {
  98773. /**
  98774. * The unique identifier of the sound track in the scene.
  98775. */
  98776. id: number;
  98777. /**
  98778. * The list of sounds included in the sound track.
  98779. */
  98780. soundCollection: Array<Sound>;
  98781. private _outputAudioNode;
  98782. private _scene;
  98783. private _isMainTrack;
  98784. private _connectedAnalyser;
  98785. private _options;
  98786. private _isInitialized;
  98787. /**
  98788. * Creates a new sound track.
  98789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98790. * @param scene Define the scene the sound track belongs to
  98791. * @param options
  98792. */
  98793. constructor(scene: Scene, options?: ISoundTrackOptions);
  98794. private _initializeSoundTrackAudioGraph;
  98795. /**
  98796. * Release the sound track and its associated resources
  98797. */
  98798. dispose(): void;
  98799. /**
  98800. * Adds a sound to this sound track
  98801. * @param sound define the cound to add
  98802. * @ignoreNaming
  98803. */
  98804. AddSound(sound: Sound): void;
  98805. /**
  98806. * Removes a sound to this sound track
  98807. * @param sound define the cound to remove
  98808. * @ignoreNaming
  98809. */
  98810. RemoveSound(sound: Sound): void;
  98811. /**
  98812. * Set a global volume for the full sound track.
  98813. * @param newVolume Define the new volume of the sound track
  98814. */
  98815. setVolume(newVolume: number): void;
  98816. /**
  98817. * Switch the panning model to HRTF:
  98818. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98820. */
  98821. switchPanningModelToHRTF(): void;
  98822. /**
  98823. * Switch the panning model to Equal Power:
  98824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98826. */
  98827. switchPanningModelToEqualPower(): void;
  98828. /**
  98829. * Connect the sound track to an audio analyser allowing some amazing
  98830. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98832. * @param analyser The analyser to connect to the engine
  98833. */
  98834. connectToAnalyser(analyser: Analyser): void;
  98835. }
  98836. }
  98837. declare module BABYLON {
  98838. interface AbstractScene {
  98839. /**
  98840. * The list of sounds used in the scene.
  98841. */
  98842. sounds: Nullable<Array<Sound>>;
  98843. }
  98844. interface Scene {
  98845. /**
  98846. * @hidden
  98847. * Backing field
  98848. */
  98849. _mainSoundTrack: SoundTrack;
  98850. /**
  98851. * The main sound track played by the scene.
  98852. * It cotains your primary collection of sounds.
  98853. */
  98854. mainSoundTrack: SoundTrack;
  98855. /**
  98856. * The list of sound tracks added to the scene
  98857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98858. */
  98859. soundTracks: Nullable<Array<SoundTrack>>;
  98860. /**
  98861. * Gets a sound using a given name
  98862. * @param name defines the name to search for
  98863. * @return the found sound or null if not found at all.
  98864. */
  98865. getSoundByName(name: string): Nullable<Sound>;
  98866. /**
  98867. * Gets or sets if audio support is enabled
  98868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98869. */
  98870. audioEnabled: boolean;
  98871. /**
  98872. * Gets or sets if audio will be output to headphones
  98873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98874. */
  98875. headphone: boolean;
  98876. }
  98877. /**
  98878. * Defines the sound scene component responsible to manage any sounds
  98879. * in a given scene.
  98880. */
  98881. export class AudioSceneComponent implements ISceneSerializableComponent {
  98882. /**
  98883. * The component name helpfull to identify the component in the list of scene components.
  98884. */
  98885. readonly name: string;
  98886. /**
  98887. * The scene the component belongs to.
  98888. */
  98889. scene: Scene;
  98890. private _audioEnabled;
  98891. /**
  98892. * Gets whether audio is enabled or not.
  98893. * Please use related enable/disable method to switch state.
  98894. */
  98895. readonly audioEnabled: boolean;
  98896. private _headphone;
  98897. /**
  98898. * Gets whether audio is outputing to headphone or not.
  98899. * Please use the according Switch methods to change output.
  98900. */
  98901. readonly headphone: boolean;
  98902. /**
  98903. * Creates a new instance of the component for the given scene
  98904. * @param scene Defines the scene to register the component in
  98905. */
  98906. constructor(scene: Scene);
  98907. /**
  98908. * Registers the component in a given scene
  98909. */
  98910. register(): void;
  98911. /**
  98912. * Rebuilds the elements related to this component in case of
  98913. * context lost for instance.
  98914. */
  98915. rebuild(): void;
  98916. /**
  98917. * Serializes the component data to the specified json object
  98918. * @param serializationObject The object to serialize to
  98919. */
  98920. serialize(serializationObject: any): void;
  98921. /**
  98922. * Adds all the elements from the container to the scene
  98923. * @param container the container holding the elements
  98924. */
  98925. addFromContainer(container: AbstractScene): void;
  98926. /**
  98927. * Removes all the elements in the container from the scene
  98928. * @param container contains the elements to remove
  98929. * @param dispose if the removed element should be disposed (default: false)
  98930. */
  98931. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  98932. /**
  98933. * Disposes the component and the associated ressources.
  98934. */
  98935. dispose(): void;
  98936. /**
  98937. * Disables audio in the associated scene.
  98938. */
  98939. disableAudio(): void;
  98940. /**
  98941. * Enables audio in the associated scene.
  98942. */
  98943. enableAudio(): void;
  98944. /**
  98945. * Switch audio to headphone output.
  98946. */
  98947. switchAudioModeForHeadphones(): void;
  98948. /**
  98949. * Switch audio to normal speakers.
  98950. */
  98951. switchAudioModeForNormalSpeakers(): void;
  98952. private _afterRender;
  98953. }
  98954. }
  98955. declare module BABYLON {
  98956. /**
  98957. * Wraps one or more Sound objects and selects one with random weight for playback.
  98958. */
  98959. export class WeightedSound {
  98960. /** When true a Sound will be selected and played when the current playing Sound completes. */
  98961. loop: boolean;
  98962. private _coneInnerAngle;
  98963. private _coneOuterAngle;
  98964. private _volume;
  98965. /** A Sound is currently playing. */
  98966. isPlaying: boolean;
  98967. /** A Sound is currently paused. */
  98968. isPaused: boolean;
  98969. private _sounds;
  98970. private _weights;
  98971. private _currentIndex?;
  98972. /**
  98973. * Creates a new WeightedSound from the list of sounds given.
  98974. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  98975. * @param sounds Array of Sounds that will be selected from.
  98976. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  98977. */
  98978. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  98979. /**
  98980. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  98981. */
  98982. /**
  98983. * The size of cone in degress for a directional sound in which there will be no attenuation.
  98984. */
  98985. directionalConeInnerAngle: number;
  98986. /**
  98987. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98988. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98989. */
  98990. /**
  98991. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98992. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98993. */
  98994. directionalConeOuterAngle: number;
  98995. /**
  98996. * Playback volume.
  98997. */
  98998. /**
  98999. * Playback volume.
  99000. */
  99001. volume: number;
  99002. private _onended;
  99003. /**
  99004. * Suspend playback
  99005. */
  99006. pause(): void;
  99007. /**
  99008. * Stop playback
  99009. */
  99010. stop(): void;
  99011. /**
  99012. * Start playback.
  99013. * @param startOffset Position the clip head at a specific time in seconds.
  99014. */
  99015. play(startOffset?: number): void;
  99016. }
  99017. }
  99018. declare module BABYLON {
  99019. /**
  99020. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  99021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99022. */
  99023. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  99024. /**
  99025. * Gets the name of the behavior.
  99026. */
  99027. readonly name: string;
  99028. /**
  99029. * The easing function used by animations
  99030. */
  99031. static EasingFunction: BackEase;
  99032. /**
  99033. * The easing mode used by animations
  99034. */
  99035. static EasingMode: number;
  99036. /**
  99037. * The duration of the animation, in milliseconds
  99038. */
  99039. transitionDuration: number;
  99040. /**
  99041. * Length of the distance animated by the transition when lower radius is reached
  99042. */
  99043. lowerRadiusTransitionRange: number;
  99044. /**
  99045. * Length of the distance animated by the transition when upper radius is reached
  99046. */
  99047. upperRadiusTransitionRange: number;
  99048. private _autoTransitionRange;
  99049. /**
  99050. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99051. */
  99052. /**
  99053. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99054. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99055. */
  99056. autoTransitionRange: boolean;
  99057. private _attachedCamera;
  99058. private _onAfterCheckInputsObserver;
  99059. private _onMeshTargetChangedObserver;
  99060. /**
  99061. * Initializes the behavior.
  99062. */
  99063. init(): void;
  99064. /**
  99065. * Attaches the behavior to its arc rotate camera.
  99066. * @param camera Defines the camera to attach the behavior to
  99067. */
  99068. attach(camera: ArcRotateCamera): void;
  99069. /**
  99070. * Detaches the behavior from its current arc rotate camera.
  99071. */
  99072. detach(): void;
  99073. private _radiusIsAnimating;
  99074. private _radiusBounceTransition;
  99075. private _animatables;
  99076. private _cachedWheelPrecision;
  99077. /**
  99078. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99079. * @param radiusLimit The limit to check against.
  99080. * @return Bool to indicate if at limit.
  99081. */
  99082. private _isRadiusAtLimit;
  99083. /**
  99084. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99085. * @param radiusDelta The delta by which to animate to. Can be negative.
  99086. */
  99087. private _applyBoundRadiusAnimation;
  99088. /**
  99089. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99090. */
  99091. protected _clearAnimationLocks(): void;
  99092. /**
  99093. * Stops and removes all animations that have been applied to the camera
  99094. */
  99095. stopAllAnimations(): void;
  99096. }
  99097. }
  99098. declare module BABYLON {
  99099. /**
  99100. * 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.
  99101. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99102. */
  99103. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99104. /**
  99105. * Gets the name of the behavior.
  99106. */
  99107. readonly name: string;
  99108. private _mode;
  99109. private _radiusScale;
  99110. private _positionScale;
  99111. private _defaultElevation;
  99112. private _elevationReturnTime;
  99113. private _elevationReturnWaitTime;
  99114. private _zoomStopsAnimation;
  99115. private _framingTime;
  99116. /**
  99117. * The easing function used by animations
  99118. */
  99119. static EasingFunction: ExponentialEase;
  99120. /**
  99121. * The easing mode used by animations
  99122. */
  99123. static EasingMode: number;
  99124. /**
  99125. * Sets the current mode used by the behavior
  99126. */
  99127. /**
  99128. * Gets current mode used by the behavior.
  99129. */
  99130. mode: number;
  99131. /**
  99132. * Sets the scale applied to the radius (1 by default)
  99133. */
  99134. /**
  99135. * Gets the scale applied to the radius
  99136. */
  99137. radiusScale: number;
  99138. /**
  99139. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99140. */
  99141. /**
  99142. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99143. */
  99144. positionScale: number;
  99145. /**
  99146. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99147. * behaviour is triggered, in radians.
  99148. */
  99149. /**
  99150. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99151. * behaviour is triggered, in radians.
  99152. */
  99153. defaultElevation: number;
  99154. /**
  99155. * Sets the time (in milliseconds) taken to return to the default beta position.
  99156. * Negative value indicates camera should not return to default.
  99157. */
  99158. /**
  99159. * Gets the time (in milliseconds) taken to return to the default beta position.
  99160. * Negative value indicates camera should not return to default.
  99161. */
  99162. elevationReturnTime: number;
  99163. /**
  99164. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99165. */
  99166. /**
  99167. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99168. */
  99169. elevationReturnWaitTime: number;
  99170. /**
  99171. * Sets the flag that indicates if user zooming should stop animation.
  99172. */
  99173. /**
  99174. * Gets the flag that indicates if user zooming should stop animation.
  99175. */
  99176. zoomStopsAnimation: boolean;
  99177. /**
  99178. * Sets the transition time when framing the mesh, in milliseconds
  99179. */
  99180. /**
  99181. * Gets the transition time when framing the mesh, in milliseconds
  99182. */
  99183. framingTime: number;
  99184. /**
  99185. * Define if the behavior should automatically change the configured
  99186. * camera limits and sensibilities.
  99187. */
  99188. autoCorrectCameraLimitsAndSensibility: boolean;
  99189. private _onPrePointerObservableObserver;
  99190. private _onAfterCheckInputsObserver;
  99191. private _onMeshTargetChangedObserver;
  99192. private _attachedCamera;
  99193. private _isPointerDown;
  99194. private _lastInteractionTime;
  99195. /**
  99196. * Initializes the behavior.
  99197. */
  99198. init(): void;
  99199. /**
  99200. * Attaches the behavior to its arc rotate camera.
  99201. * @param camera Defines the camera to attach the behavior to
  99202. */
  99203. attach(camera: ArcRotateCamera): void;
  99204. /**
  99205. * Detaches the behavior from its current arc rotate camera.
  99206. */
  99207. detach(): void;
  99208. private _animatables;
  99209. private _betaIsAnimating;
  99210. private _betaTransition;
  99211. private _radiusTransition;
  99212. private _vectorTransition;
  99213. /**
  99214. * Targets the given mesh and updates zoom level accordingly.
  99215. * @param mesh The mesh to target.
  99216. * @param radius Optional. If a cached radius position already exists, overrides default.
  99217. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99218. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99219. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99220. */
  99221. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99222. /**
  99223. * Targets the given mesh with its children and updates zoom level accordingly.
  99224. * @param mesh The mesh to target.
  99225. * @param radius Optional. If a cached radius position already exists, overrides default.
  99226. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99227. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99228. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99229. */
  99230. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99231. /**
  99232. * Targets the given meshes with their children and updates zoom level accordingly.
  99233. * @param meshes The mesh to target.
  99234. * @param radius Optional. If a cached radius position already exists, overrides default.
  99235. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99236. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99237. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99238. */
  99239. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99240. /**
  99241. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99242. * @param minimumWorld Determines the smaller position of the bounding box extend
  99243. * @param maximumWorld Determines the bigger position of the bounding box extend
  99244. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99245. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99246. */
  99247. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99248. /**
  99249. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99250. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99251. * frustum width.
  99252. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99253. * to fully enclose the mesh in the viewing frustum.
  99254. */
  99255. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99256. /**
  99257. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99258. * is automatically returned to its default position (expected to be above ground plane).
  99259. */
  99260. private _maintainCameraAboveGround;
  99261. /**
  99262. * Returns the frustum slope based on the canvas ratio and camera FOV
  99263. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99264. */
  99265. private _getFrustumSlope;
  99266. /**
  99267. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99268. */
  99269. private _clearAnimationLocks;
  99270. /**
  99271. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99272. */
  99273. private _applyUserInteraction;
  99274. /**
  99275. * Stops and removes all animations that have been applied to the camera
  99276. */
  99277. stopAllAnimations(): void;
  99278. /**
  99279. * Gets a value indicating if the user is moving the camera
  99280. */
  99281. readonly isUserIsMoving: boolean;
  99282. /**
  99283. * The camera can move all the way towards the mesh.
  99284. */
  99285. static IgnoreBoundsSizeMode: number;
  99286. /**
  99287. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99288. */
  99289. static FitFrustumSidesMode: number;
  99290. }
  99291. }
  99292. declare module BABYLON {
  99293. /**
  99294. * Base class for Camera Pointer Inputs.
  99295. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99296. * for example usage.
  99297. */
  99298. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99299. /**
  99300. * Defines the camera the input is attached to.
  99301. */
  99302. abstract camera: Camera;
  99303. /**
  99304. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99305. */
  99306. protected _altKey: boolean;
  99307. protected _ctrlKey: boolean;
  99308. protected _metaKey: boolean;
  99309. protected _shiftKey: boolean;
  99310. /**
  99311. * Which mouse buttons were pressed at time of last mouse event.
  99312. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99313. */
  99314. protected _buttonsPressed: number;
  99315. /**
  99316. * Defines the buttons associated with the input to handle camera move.
  99317. */
  99318. buttons: number[];
  99319. /**
  99320. * Attach the input controls to a specific dom element to get the input from.
  99321. * @param element Defines the element the controls should be listened from
  99322. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99323. */
  99324. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99325. /**
  99326. * Detach the current controls from the specified dom element.
  99327. * @param element Defines the element to stop listening the inputs from
  99328. */
  99329. detachControl(element: Nullable<HTMLElement>): void;
  99330. /**
  99331. * Gets the class name of the current input.
  99332. * @returns the class name
  99333. */
  99334. getClassName(): string;
  99335. /**
  99336. * Get the friendly name associated with the input class.
  99337. * @returns the input friendly name
  99338. */
  99339. getSimpleName(): string;
  99340. /**
  99341. * Called on pointer POINTERDOUBLETAP event.
  99342. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99343. */
  99344. protected onDoubleTap(type: string): void;
  99345. /**
  99346. * Called on pointer POINTERMOVE event if only a single touch is active.
  99347. * Override this method to provide functionality.
  99348. */
  99349. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99350. /**
  99351. * Called on pointer POINTERMOVE event if multiple touches are active.
  99352. * Override this method to provide functionality.
  99353. */
  99354. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99355. /**
  99356. * Called on JS contextmenu event.
  99357. * Override this method to provide functionality.
  99358. */
  99359. protected onContextMenu(evt: PointerEvent): void;
  99360. /**
  99361. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99362. * press.
  99363. * Override this method to provide functionality.
  99364. */
  99365. protected onButtonDown(evt: PointerEvent): void;
  99366. /**
  99367. * Called each time a new POINTERUP event occurs. Ie, for each button
  99368. * release.
  99369. * Override this method to provide functionality.
  99370. */
  99371. protected onButtonUp(evt: PointerEvent): void;
  99372. /**
  99373. * Called when window becomes inactive.
  99374. * Override this method to provide functionality.
  99375. */
  99376. protected onLostFocus(): void;
  99377. private _pointerInput;
  99378. private _observer;
  99379. private _onLostFocus;
  99380. private pointA;
  99381. private pointB;
  99382. }
  99383. }
  99384. declare module BABYLON {
  99385. /**
  99386. * Manage the pointers inputs to control an arc rotate camera.
  99387. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99388. */
  99389. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99390. /**
  99391. * Defines the camera the input is attached to.
  99392. */
  99393. camera: ArcRotateCamera;
  99394. /**
  99395. * Gets the class name of the current input.
  99396. * @returns the class name
  99397. */
  99398. getClassName(): string;
  99399. /**
  99400. * Defines the buttons associated with the input to handle camera move.
  99401. */
  99402. buttons: number[];
  99403. /**
  99404. * Defines the pointer angular sensibility along the X axis or how fast is
  99405. * the camera rotating.
  99406. */
  99407. angularSensibilityX: number;
  99408. /**
  99409. * Defines the pointer angular sensibility along the Y axis or how fast is
  99410. * the camera rotating.
  99411. */
  99412. angularSensibilityY: number;
  99413. /**
  99414. * Defines the pointer pinch precision or how fast is the camera zooming.
  99415. */
  99416. pinchPrecision: number;
  99417. /**
  99418. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99419. * from 0.
  99420. * It defines the percentage of current camera.radius to use as delta when
  99421. * pinch zoom is used.
  99422. */
  99423. pinchDeltaPercentage: number;
  99424. /**
  99425. * Defines the pointer panning sensibility or how fast is the camera moving.
  99426. */
  99427. panningSensibility: number;
  99428. /**
  99429. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99430. */
  99431. multiTouchPanning: boolean;
  99432. /**
  99433. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99434. * zoom (pinch) through multitouch.
  99435. */
  99436. multiTouchPanAndZoom: boolean;
  99437. /**
  99438. * Revers pinch action direction.
  99439. */
  99440. pinchInwards: boolean;
  99441. private _isPanClick;
  99442. private _twoFingerActivityCount;
  99443. private _isPinching;
  99444. /**
  99445. * Called on pointer POINTERMOVE event if only a single touch is active.
  99446. */
  99447. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99448. /**
  99449. * Called on pointer POINTERDOUBLETAP event.
  99450. */
  99451. protected onDoubleTap(type: string): void;
  99452. /**
  99453. * Called on pointer POINTERMOVE event if multiple touches are active.
  99454. */
  99455. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99456. /**
  99457. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99458. * press.
  99459. */
  99460. protected onButtonDown(evt: PointerEvent): void;
  99461. /**
  99462. * Called each time a new POINTERUP event occurs. Ie, for each button
  99463. * release.
  99464. */
  99465. protected onButtonUp(evt: PointerEvent): void;
  99466. /**
  99467. * Called when window becomes inactive.
  99468. */
  99469. protected onLostFocus(): void;
  99470. }
  99471. }
  99472. declare module BABYLON {
  99473. /**
  99474. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99476. */
  99477. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99478. /**
  99479. * Defines the camera the input is attached to.
  99480. */
  99481. camera: ArcRotateCamera;
  99482. /**
  99483. * Defines the list of key codes associated with the up action (increase alpha)
  99484. */
  99485. keysUp: number[];
  99486. /**
  99487. * Defines the list of key codes associated with the down action (decrease alpha)
  99488. */
  99489. keysDown: number[];
  99490. /**
  99491. * Defines the list of key codes associated with the left action (increase beta)
  99492. */
  99493. keysLeft: number[];
  99494. /**
  99495. * Defines the list of key codes associated with the right action (decrease beta)
  99496. */
  99497. keysRight: number[];
  99498. /**
  99499. * Defines the list of key codes associated with the reset action.
  99500. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99501. */
  99502. keysReset: number[];
  99503. /**
  99504. * Defines the panning sensibility of the inputs.
  99505. * (How fast is the camera paning)
  99506. */
  99507. panningSensibility: number;
  99508. /**
  99509. * Defines the zooming sensibility of the inputs.
  99510. * (How fast is the camera zooming)
  99511. */
  99512. zoomingSensibility: number;
  99513. /**
  99514. * Defines wether maintaining the alt key down switch the movement mode from
  99515. * orientation to zoom.
  99516. */
  99517. useAltToZoom: boolean;
  99518. /**
  99519. * Rotation speed of the camera
  99520. */
  99521. angularSpeed: number;
  99522. private _keys;
  99523. private _ctrlPressed;
  99524. private _altPressed;
  99525. private _onCanvasBlurObserver;
  99526. private _onKeyboardObserver;
  99527. private _engine;
  99528. private _scene;
  99529. /**
  99530. * Attach the input controls to a specific dom element to get the input from.
  99531. * @param element Defines the element the controls should be listened from
  99532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99533. */
  99534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99535. /**
  99536. * Detach the current controls from the specified dom element.
  99537. * @param element Defines the element to stop listening the inputs from
  99538. */
  99539. detachControl(element: Nullable<HTMLElement>): void;
  99540. /**
  99541. * Update the current camera state depending on the inputs that have been used this frame.
  99542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99543. */
  99544. checkInputs(): void;
  99545. /**
  99546. * Gets the class name of the current intput.
  99547. * @returns the class name
  99548. */
  99549. getClassName(): string;
  99550. /**
  99551. * Get the friendly name associated with the input class.
  99552. * @returns the input friendly name
  99553. */
  99554. getSimpleName(): string;
  99555. }
  99556. }
  99557. declare module BABYLON {
  99558. /**
  99559. * Manage the mouse wheel inputs to control an arc rotate camera.
  99560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99561. */
  99562. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99563. /**
  99564. * Defines the camera the input is attached to.
  99565. */
  99566. camera: ArcRotateCamera;
  99567. /**
  99568. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99569. */
  99570. wheelPrecision: number;
  99571. /**
  99572. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99573. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99574. */
  99575. wheelDeltaPercentage: number;
  99576. private _wheel;
  99577. private _observer;
  99578. private computeDeltaFromMouseWheelLegacyEvent;
  99579. /**
  99580. * Attach the input controls to a specific dom element to get the input from.
  99581. * @param element Defines the element the controls should be listened from
  99582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99583. */
  99584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99585. /**
  99586. * Detach the current controls from the specified dom element.
  99587. * @param element Defines the element to stop listening the inputs from
  99588. */
  99589. detachControl(element: Nullable<HTMLElement>): void;
  99590. /**
  99591. * Gets the class name of the current intput.
  99592. * @returns the class name
  99593. */
  99594. getClassName(): string;
  99595. /**
  99596. * Get the friendly name associated with the input class.
  99597. * @returns the input friendly name
  99598. */
  99599. getSimpleName(): string;
  99600. }
  99601. }
  99602. declare module BABYLON {
  99603. /**
  99604. * Default Inputs manager for the ArcRotateCamera.
  99605. * It groups all the default supported inputs for ease of use.
  99606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99607. */
  99608. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99609. /**
  99610. * Instantiates a new ArcRotateCameraInputsManager.
  99611. * @param camera Defines the camera the inputs belong to
  99612. */
  99613. constructor(camera: ArcRotateCamera);
  99614. /**
  99615. * Add mouse wheel input support to the input manager.
  99616. * @returns the current input manager
  99617. */
  99618. addMouseWheel(): ArcRotateCameraInputsManager;
  99619. /**
  99620. * Add pointers input support to the input manager.
  99621. * @returns the current input manager
  99622. */
  99623. addPointers(): ArcRotateCameraInputsManager;
  99624. /**
  99625. * Add keyboard input support to the input manager.
  99626. * @returns the current input manager
  99627. */
  99628. addKeyboard(): ArcRotateCameraInputsManager;
  99629. }
  99630. }
  99631. declare module BABYLON {
  99632. /**
  99633. * This represents an orbital type of camera.
  99634. *
  99635. * 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.
  99636. * 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.
  99637. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99638. */
  99639. export class ArcRotateCamera extends TargetCamera {
  99640. /**
  99641. * Defines the rotation angle of the camera along the longitudinal axis.
  99642. */
  99643. alpha: number;
  99644. /**
  99645. * Defines the rotation angle of the camera along the latitudinal axis.
  99646. */
  99647. beta: number;
  99648. /**
  99649. * Defines the radius of the camera from it s target point.
  99650. */
  99651. radius: number;
  99652. protected _target: Vector3;
  99653. protected _targetHost: Nullable<AbstractMesh>;
  99654. /**
  99655. * Defines the target point of the camera.
  99656. * The camera looks towards it form the radius distance.
  99657. */
  99658. target: Vector3;
  99659. /**
  99660. * Define the current local position of the camera in the scene
  99661. */
  99662. position: Vector3;
  99663. protected _upVector: Vector3;
  99664. protected _upToYMatrix: Matrix;
  99665. protected _YToUpMatrix: Matrix;
  99666. /**
  99667. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99668. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99669. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99670. */
  99671. upVector: Vector3;
  99672. /**
  99673. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99674. */
  99675. setMatUp(): void;
  99676. /**
  99677. * Current inertia value on the longitudinal axis.
  99678. * The bigger this number the longer it will take for the camera to stop.
  99679. */
  99680. inertialAlphaOffset: number;
  99681. /**
  99682. * Current inertia value on the latitudinal axis.
  99683. * The bigger this number the longer it will take for the camera to stop.
  99684. */
  99685. inertialBetaOffset: number;
  99686. /**
  99687. * Current inertia value on the radius axis.
  99688. * The bigger this number the longer it will take for the camera to stop.
  99689. */
  99690. inertialRadiusOffset: number;
  99691. /**
  99692. * Minimum allowed angle on the longitudinal axis.
  99693. * This can help limiting how the Camera is able to move in the scene.
  99694. */
  99695. lowerAlphaLimit: Nullable<number>;
  99696. /**
  99697. * Maximum allowed angle on the longitudinal axis.
  99698. * This can help limiting how the Camera is able to move in the scene.
  99699. */
  99700. upperAlphaLimit: Nullable<number>;
  99701. /**
  99702. * Minimum allowed angle on the latitudinal axis.
  99703. * This can help limiting how the Camera is able to move in the scene.
  99704. */
  99705. lowerBetaLimit: number;
  99706. /**
  99707. * Maximum allowed angle on the latitudinal axis.
  99708. * This can help limiting how the Camera is able to move in the scene.
  99709. */
  99710. upperBetaLimit: number;
  99711. /**
  99712. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99713. * This can help limiting how the Camera is able to move in the scene.
  99714. */
  99715. lowerRadiusLimit: Nullable<number>;
  99716. /**
  99717. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99718. * This can help limiting how the Camera is able to move in the scene.
  99719. */
  99720. upperRadiusLimit: Nullable<number>;
  99721. /**
  99722. * Defines the current inertia value used during panning of the camera along the X axis.
  99723. */
  99724. inertialPanningX: number;
  99725. /**
  99726. * Defines the current inertia value used during panning of the camera along the Y axis.
  99727. */
  99728. inertialPanningY: number;
  99729. /**
  99730. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99731. * Basically if your fingers moves away from more than this distance you will be considered
  99732. * in pinch mode.
  99733. */
  99734. pinchToPanMaxDistance: number;
  99735. /**
  99736. * Defines the maximum distance the camera can pan.
  99737. * This could help keeping the cammera always in your scene.
  99738. */
  99739. panningDistanceLimit: Nullable<number>;
  99740. /**
  99741. * Defines the target of the camera before paning.
  99742. */
  99743. panningOriginTarget: Vector3;
  99744. /**
  99745. * Defines the value of the inertia used during panning.
  99746. * 0 would mean stop inertia and one would mean no decelleration at all.
  99747. */
  99748. panningInertia: number;
  99749. /**
  99750. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99751. */
  99752. angularSensibilityX: number;
  99753. /**
  99754. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99755. */
  99756. angularSensibilityY: number;
  99757. /**
  99758. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99759. */
  99760. pinchPrecision: number;
  99761. /**
  99762. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99763. * It will be used instead of pinchDeltaPrecision if different from 0.
  99764. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99765. */
  99766. pinchDeltaPercentage: number;
  99767. /**
  99768. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99769. */
  99770. panningSensibility: number;
  99771. /**
  99772. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99773. */
  99774. keysUp: number[];
  99775. /**
  99776. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99777. */
  99778. keysDown: number[];
  99779. /**
  99780. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99781. */
  99782. keysLeft: number[];
  99783. /**
  99784. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99785. */
  99786. keysRight: number[];
  99787. /**
  99788. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99789. */
  99790. wheelPrecision: number;
  99791. /**
  99792. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99793. * It will be used instead of pinchDeltaPrecision if different from 0.
  99794. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99795. */
  99796. wheelDeltaPercentage: number;
  99797. /**
  99798. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99799. */
  99800. zoomOnFactor: number;
  99801. /**
  99802. * Defines a screen offset for the camera position.
  99803. */
  99804. targetScreenOffset: Vector2;
  99805. /**
  99806. * Allows the camera to be completely reversed.
  99807. * If false the camera can not arrive upside down.
  99808. */
  99809. allowUpsideDown: boolean;
  99810. /**
  99811. * Define if double tap/click is used to restore the previously saved state of the camera.
  99812. */
  99813. useInputToRestoreState: boolean;
  99814. /** @hidden */
  99815. _viewMatrix: Matrix;
  99816. /** @hidden */
  99817. _useCtrlForPanning: boolean;
  99818. /** @hidden */
  99819. _panningMouseButton: number;
  99820. /**
  99821. * Defines the input associated to the camera.
  99822. */
  99823. inputs: ArcRotateCameraInputsManager;
  99824. /** @hidden */
  99825. _reset: () => void;
  99826. /**
  99827. * Defines the allowed panning axis.
  99828. */
  99829. panningAxis: Vector3;
  99830. protected _localDirection: Vector3;
  99831. protected _transformedDirection: Vector3;
  99832. private _bouncingBehavior;
  99833. /**
  99834. * Gets the bouncing behavior of the camera if it has been enabled.
  99835. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99836. */
  99837. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  99838. /**
  99839. * Defines if the bouncing behavior of the camera is enabled on the camera.
  99840. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99841. */
  99842. useBouncingBehavior: boolean;
  99843. private _framingBehavior;
  99844. /**
  99845. * Gets the framing behavior of the camera if it has been enabled.
  99846. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99847. */
  99848. readonly framingBehavior: Nullable<FramingBehavior>;
  99849. /**
  99850. * Defines if the framing behavior of the camera is enabled on the camera.
  99851. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99852. */
  99853. useFramingBehavior: boolean;
  99854. private _autoRotationBehavior;
  99855. /**
  99856. * Gets the auto rotation behavior of the camera if it has been enabled.
  99857. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99858. */
  99859. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  99860. /**
  99861. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  99862. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99863. */
  99864. useAutoRotationBehavior: boolean;
  99865. /**
  99866. * Observable triggered when the mesh target has been changed on the camera.
  99867. */
  99868. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  99869. /**
  99870. * Event raised when the camera is colliding with a mesh.
  99871. */
  99872. onCollide: (collidedMesh: AbstractMesh) => void;
  99873. /**
  99874. * Defines whether the camera should check collision with the objects oh the scene.
  99875. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  99876. */
  99877. checkCollisions: boolean;
  99878. /**
  99879. * Defines the collision radius of the camera.
  99880. * This simulates a sphere around the camera.
  99881. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99882. */
  99883. collisionRadius: Vector3;
  99884. protected _collider: Collider;
  99885. protected _previousPosition: Vector3;
  99886. protected _collisionVelocity: Vector3;
  99887. protected _newPosition: Vector3;
  99888. protected _previousAlpha: number;
  99889. protected _previousBeta: number;
  99890. protected _previousRadius: number;
  99891. protected _collisionTriggered: boolean;
  99892. protected _targetBoundingCenter: Nullable<Vector3>;
  99893. private _computationVector;
  99894. /**
  99895. * Instantiates a new ArcRotateCamera in a given scene
  99896. * @param name Defines the name of the camera
  99897. * @param alpha Defines the camera rotation along the logitudinal axis
  99898. * @param beta Defines the camera rotation along the latitudinal axis
  99899. * @param radius Defines the camera distance from its target
  99900. * @param target Defines the camera target
  99901. * @param scene Defines the scene the camera belongs to
  99902. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99903. */
  99904. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99905. /** @hidden */
  99906. _initCache(): void;
  99907. /** @hidden */
  99908. _updateCache(ignoreParentClass?: boolean): void;
  99909. protected _getTargetPosition(): Vector3;
  99910. private _storedAlpha;
  99911. private _storedBeta;
  99912. private _storedRadius;
  99913. private _storedTarget;
  99914. /**
  99915. * Stores the current state of the camera (alpha, beta, radius and target)
  99916. * @returns the camera itself
  99917. */
  99918. storeState(): Camera;
  99919. /**
  99920. * @hidden
  99921. * Restored camera state. You must call storeState() first
  99922. */
  99923. _restoreStateValues(): boolean;
  99924. /** @hidden */
  99925. _isSynchronizedViewMatrix(): boolean;
  99926. /**
  99927. * Attached controls to the current camera.
  99928. * @param element Defines the element the controls should be listened from
  99929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99930. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  99931. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  99932. */
  99933. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  99934. /**
  99935. * Detach the current controls from the camera.
  99936. * The camera will stop reacting to inputs.
  99937. * @param element Defines the element to stop listening the inputs from
  99938. */
  99939. detachControl(element: HTMLElement): void;
  99940. /** @hidden */
  99941. _checkInputs(): void;
  99942. protected _checkLimits(): void;
  99943. /**
  99944. * Rebuilds angles (alpha, beta) and radius from the give position and target
  99945. */
  99946. rebuildAnglesAndRadius(): void;
  99947. /**
  99948. * Use a position to define the current camera related information like aplha, beta and radius
  99949. * @param position Defines the position to set the camera at
  99950. */
  99951. setPosition(position: Vector3): void;
  99952. /**
  99953. * Defines the target the camera should look at.
  99954. * This will automatically adapt alpha beta and radius to fit within the new target.
  99955. * @param target Defines the new target as a Vector or a mesh
  99956. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  99957. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  99958. */
  99959. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  99960. /** @hidden */
  99961. _getViewMatrix(): Matrix;
  99962. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  99963. /**
  99964. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  99965. * @param meshes Defines the mesh to zoom on
  99966. * @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)
  99967. */
  99968. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  99969. /**
  99970. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  99971. * The target will be changed but the radius
  99972. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  99973. * @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)
  99974. */
  99975. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  99976. min: Vector3;
  99977. max: Vector3;
  99978. distance: number;
  99979. }, doNotUpdateMaxZ?: boolean): void;
  99980. /**
  99981. * @override
  99982. * Override Camera.createRigCamera
  99983. */
  99984. createRigCamera(name: string, cameraIndex: number): Camera;
  99985. /**
  99986. * @hidden
  99987. * @override
  99988. * Override Camera._updateRigCameras
  99989. */
  99990. _updateRigCameras(): void;
  99991. /**
  99992. * Destroy the camera and release the current resources hold by it.
  99993. */
  99994. dispose(): void;
  99995. /**
  99996. * Gets the current object class name.
  99997. * @return the class name
  99998. */
  99999. getClassName(): string;
  100000. }
  100001. }
  100002. declare module BABYLON {
  100003. /**
  100004. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  100005. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  100006. */
  100007. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  100008. /**
  100009. * Gets the name of the behavior.
  100010. */
  100011. readonly name: string;
  100012. private _zoomStopsAnimation;
  100013. private _idleRotationSpeed;
  100014. private _idleRotationWaitTime;
  100015. private _idleRotationSpinupTime;
  100016. /**
  100017. * Sets the flag that indicates if user zooming should stop animation.
  100018. */
  100019. /**
  100020. * Gets the flag that indicates if user zooming should stop animation.
  100021. */
  100022. zoomStopsAnimation: boolean;
  100023. /**
  100024. * Sets the default speed at which the camera rotates around the model.
  100025. */
  100026. /**
  100027. * Gets the default speed at which the camera rotates around the model.
  100028. */
  100029. idleRotationSpeed: number;
  100030. /**
  100031. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100032. */
  100033. /**
  100034. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100035. */
  100036. idleRotationWaitTime: number;
  100037. /**
  100038. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100039. */
  100040. /**
  100041. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100042. */
  100043. idleRotationSpinupTime: number;
  100044. /**
  100045. * Gets a value indicating if the camera is currently rotating because of this behavior
  100046. */
  100047. readonly rotationInProgress: boolean;
  100048. private _onPrePointerObservableObserver;
  100049. private _onAfterCheckInputsObserver;
  100050. private _attachedCamera;
  100051. private _isPointerDown;
  100052. private _lastFrameTime;
  100053. private _lastInteractionTime;
  100054. private _cameraRotationSpeed;
  100055. /**
  100056. * Initializes the behavior.
  100057. */
  100058. init(): void;
  100059. /**
  100060. * Attaches the behavior to its arc rotate camera.
  100061. * @param camera Defines the camera to attach the behavior to
  100062. */
  100063. attach(camera: ArcRotateCamera): void;
  100064. /**
  100065. * Detaches the behavior from its current arc rotate camera.
  100066. */
  100067. detach(): void;
  100068. /**
  100069. * Returns true if user is scrolling.
  100070. * @return true if user is scrolling.
  100071. */
  100072. private _userIsZooming;
  100073. private _lastFrameRadius;
  100074. private _shouldAnimationStopForInteraction;
  100075. /**
  100076. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100077. */
  100078. private _applyUserInteraction;
  100079. private _userIsMoving;
  100080. }
  100081. }
  100082. declare module BABYLON {
  100083. /**
  100084. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100085. */
  100086. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100087. private ui;
  100088. /**
  100089. * The name of the behavior
  100090. */
  100091. name: string;
  100092. /**
  100093. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100094. */
  100095. distanceAwayFromFace: number;
  100096. /**
  100097. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100098. */
  100099. distanceAwayFromBottomOfFace: number;
  100100. private _faceVectors;
  100101. private _target;
  100102. private _scene;
  100103. private _onRenderObserver;
  100104. private _tmpMatrix;
  100105. private _tmpVector;
  100106. /**
  100107. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100108. * @param ui The transform node that should be attched to the mesh
  100109. */
  100110. constructor(ui: TransformNode);
  100111. /**
  100112. * Initializes the behavior
  100113. */
  100114. init(): void;
  100115. private _closestFace;
  100116. private _zeroVector;
  100117. private _lookAtTmpMatrix;
  100118. private _lookAtToRef;
  100119. /**
  100120. * Attaches the AttachToBoxBehavior to the passed in mesh
  100121. * @param target The mesh that the specified node will be attached to
  100122. */
  100123. attach(target: Mesh): void;
  100124. /**
  100125. * Detaches the behavior from the mesh
  100126. */
  100127. detach(): void;
  100128. }
  100129. }
  100130. declare module BABYLON {
  100131. /**
  100132. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100133. */
  100134. export class FadeInOutBehavior implements Behavior<Mesh> {
  100135. /**
  100136. * Time in milliseconds to delay before fading in (Default: 0)
  100137. */
  100138. delay: number;
  100139. /**
  100140. * Time in milliseconds for the mesh to fade in (Default: 300)
  100141. */
  100142. fadeInTime: number;
  100143. private _millisecondsPerFrame;
  100144. private _hovered;
  100145. private _hoverValue;
  100146. private _ownerNode;
  100147. /**
  100148. * Instatiates the FadeInOutBehavior
  100149. */
  100150. constructor();
  100151. /**
  100152. * The name of the behavior
  100153. */
  100154. readonly name: string;
  100155. /**
  100156. * Initializes the behavior
  100157. */
  100158. init(): void;
  100159. /**
  100160. * Attaches the fade behavior on the passed in mesh
  100161. * @param ownerNode The mesh that will be faded in/out once attached
  100162. */
  100163. attach(ownerNode: Mesh): void;
  100164. /**
  100165. * Detaches the behavior from the mesh
  100166. */
  100167. detach(): void;
  100168. /**
  100169. * Triggers the mesh to begin fading in or out
  100170. * @param value if the object should fade in or out (true to fade in)
  100171. */
  100172. fadeIn(value: boolean): void;
  100173. private _update;
  100174. private _setAllVisibility;
  100175. }
  100176. }
  100177. declare module BABYLON {
  100178. /**
  100179. * Class containing a set of static utilities functions for managing Pivots
  100180. * @hidden
  100181. */
  100182. export class PivotTools {
  100183. private static _PivotCached;
  100184. private static _OldPivotPoint;
  100185. private static _PivotTranslation;
  100186. private static _PivotTmpVector;
  100187. /** @hidden */
  100188. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100189. /** @hidden */
  100190. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100191. }
  100192. }
  100193. declare module BABYLON {
  100194. /**
  100195. * Class containing static functions to help procedurally build meshes
  100196. */
  100197. export class PlaneBuilder {
  100198. /**
  100199. * Creates a plane mesh
  100200. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100201. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100202. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100206. * @param name defines the name of the mesh
  100207. * @param options defines the options used to create the mesh
  100208. * @param scene defines the hosting scene
  100209. * @returns the plane mesh
  100210. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100211. */
  100212. static CreatePlane(name: string, options: {
  100213. size?: number;
  100214. width?: number;
  100215. height?: number;
  100216. sideOrientation?: number;
  100217. frontUVs?: Vector4;
  100218. backUVs?: Vector4;
  100219. updatable?: boolean;
  100220. sourcePlane?: Plane;
  100221. }, scene?: Nullable<Scene>): Mesh;
  100222. }
  100223. }
  100224. declare module BABYLON {
  100225. /**
  100226. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100227. */
  100228. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100229. private static _AnyMouseID;
  100230. /**
  100231. * Abstract mesh the behavior is set on
  100232. */
  100233. attachedNode: AbstractMesh;
  100234. private _dragPlane;
  100235. private _scene;
  100236. private _pointerObserver;
  100237. private _beforeRenderObserver;
  100238. private static _planeScene;
  100239. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100240. /**
  100241. * 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)
  100242. */
  100243. maxDragAngle: number;
  100244. /**
  100245. * @hidden
  100246. */
  100247. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100248. /**
  100249. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100250. */
  100251. currentDraggingPointerID: number;
  100252. /**
  100253. * The last position where the pointer hit the drag plane in world space
  100254. */
  100255. lastDragPosition: Vector3;
  100256. /**
  100257. * If the behavior is currently in a dragging state
  100258. */
  100259. dragging: boolean;
  100260. /**
  100261. * 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)
  100262. */
  100263. dragDeltaRatio: number;
  100264. /**
  100265. * If the drag plane orientation should be updated during the dragging (Default: true)
  100266. */
  100267. updateDragPlane: boolean;
  100268. private _debugMode;
  100269. private _moving;
  100270. /**
  100271. * Fires each time the attached mesh is dragged with the pointer
  100272. * * delta between last drag position and current drag position in world space
  100273. * * dragDistance along the drag axis
  100274. * * dragPlaneNormal normal of the current drag plane used during the drag
  100275. * * dragPlanePoint in world space where the drag intersects the drag plane
  100276. */
  100277. onDragObservable: Observable<{
  100278. delta: Vector3;
  100279. dragPlanePoint: Vector3;
  100280. dragPlaneNormal: Vector3;
  100281. dragDistance: number;
  100282. pointerId: number;
  100283. }>;
  100284. /**
  100285. * Fires each time a drag begins (eg. mouse down on mesh)
  100286. */
  100287. onDragStartObservable: Observable<{
  100288. dragPlanePoint: Vector3;
  100289. pointerId: number;
  100290. }>;
  100291. /**
  100292. * Fires each time a drag ends (eg. mouse release after drag)
  100293. */
  100294. onDragEndObservable: Observable<{
  100295. dragPlanePoint: Vector3;
  100296. pointerId: number;
  100297. }>;
  100298. /**
  100299. * If the attached mesh should be moved when dragged
  100300. */
  100301. moveAttached: boolean;
  100302. /**
  100303. * If the drag behavior will react to drag events (Default: true)
  100304. */
  100305. enabled: boolean;
  100306. /**
  100307. * If pointer events should start and release the drag (Default: true)
  100308. */
  100309. startAndReleaseDragOnPointerEvents: boolean;
  100310. /**
  100311. * If camera controls should be detached during the drag
  100312. */
  100313. detachCameraControls: boolean;
  100314. /**
  100315. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100316. */
  100317. useObjectOrienationForDragging: boolean;
  100318. private _options;
  100319. /**
  100320. * Creates a pointer drag behavior that can be attached to a mesh
  100321. * @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)
  100322. */
  100323. constructor(options?: {
  100324. dragAxis?: Vector3;
  100325. dragPlaneNormal?: Vector3;
  100326. });
  100327. /**
  100328. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100329. */
  100330. validateDrag: (targetPosition: Vector3) => boolean;
  100331. /**
  100332. * The name of the behavior
  100333. */
  100334. readonly name: string;
  100335. /**
  100336. * Initializes the behavior
  100337. */
  100338. init(): void;
  100339. private _tmpVector;
  100340. private _alternatePickedPoint;
  100341. private _worldDragAxis;
  100342. private _targetPosition;
  100343. private _attachedElement;
  100344. /**
  100345. * Attaches the drag behavior the passed in mesh
  100346. * @param ownerNode The mesh that will be dragged around once attached
  100347. */
  100348. attach(ownerNode: AbstractMesh): void;
  100349. /**
  100350. * Force relase the drag action by code.
  100351. */
  100352. releaseDrag(): void;
  100353. private _startDragRay;
  100354. private _lastPointerRay;
  100355. /**
  100356. * Simulates the start of a pointer drag event on the behavior
  100357. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100358. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100359. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100360. */
  100361. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100362. private _startDrag;
  100363. private _dragDelta;
  100364. private _moveDrag;
  100365. private _pickWithRayOnDragPlane;
  100366. private _pointA;
  100367. private _pointB;
  100368. private _pointC;
  100369. private _lineA;
  100370. private _lineB;
  100371. private _localAxis;
  100372. private _lookAt;
  100373. private _updateDragPlanePosition;
  100374. /**
  100375. * Detaches the behavior from the mesh
  100376. */
  100377. detach(): void;
  100378. }
  100379. }
  100380. declare module BABYLON {
  100381. /**
  100382. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100383. */
  100384. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100385. private _dragBehaviorA;
  100386. private _dragBehaviorB;
  100387. private _startDistance;
  100388. private _initialScale;
  100389. private _targetScale;
  100390. private _ownerNode;
  100391. private _sceneRenderObserver;
  100392. /**
  100393. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100394. */
  100395. constructor();
  100396. /**
  100397. * The name of the behavior
  100398. */
  100399. readonly name: string;
  100400. /**
  100401. * Initializes the behavior
  100402. */
  100403. init(): void;
  100404. private _getCurrentDistance;
  100405. /**
  100406. * Attaches the scale behavior the passed in mesh
  100407. * @param ownerNode The mesh that will be scaled around once attached
  100408. */
  100409. attach(ownerNode: Mesh): void;
  100410. /**
  100411. * Detaches the behavior from the mesh
  100412. */
  100413. detach(): void;
  100414. }
  100415. }
  100416. declare module BABYLON {
  100417. /**
  100418. * 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
  100419. */
  100420. export class SixDofDragBehavior implements Behavior<Mesh> {
  100421. private static _virtualScene;
  100422. private _ownerNode;
  100423. private _sceneRenderObserver;
  100424. private _scene;
  100425. private _targetPosition;
  100426. private _virtualOriginMesh;
  100427. private _virtualDragMesh;
  100428. private _pointerObserver;
  100429. private _moving;
  100430. private _startingOrientation;
  100431. /**
  100432. * 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)
  100433. */
  100434. private zDragFactor;
  100435. /**
  100436. * If the object should rotate to face the drag origin
  100437. */
  100438. rotateDraggedObject: boolean;
  100439. /**
  100440. * If the behavior is currently in a dragging state
  100441. */
  100442. dragging: boolean;
  100443. /**
  100444. * 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)
  100445. */
  100446. dragDeltaRatio: number;
  100447. /**
  100448. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100449. */
  100450. currentDraggingPointerID: number;
  100451. /**
  100452. * If camera controls should be detached during the drag
  100453. */
  100454. detachCameraControls: boolean;
  100455. /**
  100456. * Fires each time a drag starts
  100457. */
  100458. onDragStartObservable: Observable<{}>;
  100459. /**
  100460. * Fires each time a drag ends (eg. mouse release after drag)
  100461. */
  100462. onDragEndObservable: Observable<{}>;
  100463. /**
  100464. * 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
  100465. */
  100466. constructor();
  100467. /**
  100468. * The name of the behavior
  100469. */
  100470. readonly name: string;
  100471. /**
  100472. * Initializes the behavior
  100473. */
  100474. init(): void;
  100475. /**
  100476. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100477. */
  100478. private readonly _pointerCamera;
  100479. /**
  100480. * Attaches the scale behavior the passed in mesh
  100481. * @param ownerNode The mesh that will be scaled around once attached
  100482. */
  100483. attach(ownerNode: Mesh): void;
  100484. /**
  100485. * Detaches the behavior from the mesh
  100486. */
  100487. detach(): void;
  100488. }
  100489. }
  100490. declare module BABYLON {
  100491. /**
  100492. * Class used to apply inverse kinematics to bones
  100493. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100494. */
  100495. export class BoneIKController {
  100496. private static _tmpVecs;
  100497. private static _tmpQuat;
  100498. private static _tmpMats;
  100499. /**
  100500. * Gets or sets the target mesh
  100501. */
  100502. targetMesh: AbstractMesh;
  100503. /** Gets or sets the mesh used as pole */
  100504. poleTargetMesh: AbstractMesh;
  100505. /**
  100506. * Gets or sets the bone used as pole
  100507. */
  100508. poleTargetBone: Nullable<Bone>;
  100509. /**
  100510. * Gets or sets the target position
  100511. */
  100512. targetPosition: Vector3;
  100513. /**
  100514. * Gets or sets the pole target position
  100515. */
  100516. poleTargetPosition: Vector3;
  100517. /**
  100518. * Gets or sets the pole target local offset
  100519. */
  100520. poleTargetLocalOffset: Vector3;
  100521. /**
  100522. * Gets or sets the pole angle
  100523. */
  100524. poleAngle: number;
  100525. /**
  100526. * Gets or sets the mesh associated with the controller
  100527. */
  100528. mesh: AbstractMesh;
  100529. /**
  100530. * 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)
  100531. */
  100532. slerpAmount: number;
  100533. private _bone1Quat;
  100534. private _bone1Mat;
  100535. private _bone2Ang;
  100536. private _bone1;
  100537. private _bone2;
  100538. private _bone1Length;
  100539. private _bone2Length;
  100540. private _maxAngle;
  100541. private _maxReach;
  100542. private _rightHandedSystem;
  100543. private _bendAxis;
  100544. private _slerping;
  100545. private _adjustRoll;
  100546. /**
  100547. * Gets or sets maximum allowed angle
  100548. */
  100549. maxAngle: number;
  100550. /**
  100551. * Creates a new BoneIKController
  100552. * @param mesh defines the mesh to control
  100553. * @param bone defines the bone to control
  100554. * @param options defines options to set up the controller
  100555. */
  100556. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100557. targetMesh?: AbstractMesh;
  100558. poleTargetMesh?: AbstractMesh;
  100559. poleTargetBone?: Bone;
  100560. poleTargetLocalOffset?: Vector3;
  100561. poleAngle?: number;
  100562. bendAxis?: Vector3;
  100563. maxAngle?: number;
  100564. slerpAmount?: number;
  100565. });
  100566. private _setMaxAngle;
  100567. /**
  100568. * Force the controller to update the bones
  100569. */
  100570. update(): void;
  100571. }
  100572. }
  100573. declare module BABYLON {
  100574. /**
  100575. * Class used to make a bone look toward a point in space
  100576. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100577. */
  100578. export class BoneLookController {
  100579. private static _tmpVecs;
  100580. private static _tmpQuat;
  100581. private static _tmpMats;
  100582. /**
  100583. * The target Vector3 that the bone will look at
  100584. */
  100585. target: Vector3;
  100586. /**
  100587. * The mesh that the bone is attached to
  100588. */
  100589. mesh: AbstractMesh;
  100590. /**
  100591. * The bone that will be looking to the target
  100592. */
  100593. bone: Bone;
  100594. /**
  100595. * The up axis of the coordinate system that is used when the bone is rotated
  100596. */
  100597. upAxis: Vector3;
  100598. /**
  100599. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100600. */
  100601. upAxisSpace: Space;
  100602. /**
  100603. * Used to make an adjustment to the yaw of the bone
  100604. */
  100605. adjustYaw: number;
  100606. /**
  100607. * Used to make an adjustment to the pitch of the bone
  100608. */
  100609. adjustPitch: number;
  100610. /**
  100611. * Used to make an adjustment to the roll of the bone
  100612. */
  100613. adjustRoll: number;
  100614. /**
  100615. * 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)
  100616. */
  100617. slerpAmount: number;
  100618. private _minYaw;
  100619. private _maxYaw;
  100620. private _minPitch;
  100621. private _maxPitch;
  100622. private _minYawSin;
  100623. private _minYawCos;
  100624. private _maxYawSin;
  100625. private _maxYawCos;
  100626. private _midYawConstraint;
  100627. private _minPitchTan;
  100628. private _maxPitchTan;
  100629. private _boneQuat;
  100630. private _slerping;
  100631. private _transformYawPitch;
  100632. private _transformYawPitchInv;
  100633. private _firstFrameSkipped;
  100634. private _yawRange;
  100635. private _fowardAxis;
  100636. /**
  100637. * Gets or sets the minimum yaw angle that the bone can look to
  100638. */
  100639. minYaw: number;
  100640. /**
  100641. * Gets or sets the maximum yaw angle that the bone can look to
  100642. */
  100643. maxYaw: number;
  100644. /**
  100645. * Gets or sets the minimum pitch angle that the bone can look to
  100646. */
  100647. minPitch: number;
  100648. /**
  100649. * Gets or sets the maximum pitch angle that the bone can look to
  100650. */
  100651. maxPitch: number;
  100652. /**
  100653. * Create a BoneLookController
  100654. * @param mesh the mesh that the bone belongs to
  100655. * @param bone the bone that will be looking to the target
  100656. * @param target the target Vector3 to look at
  100657. * @param options optional settings:
  100658. * * maxYaw: the maximum angle the bone will yaw to
  100659. * * minYaw: the minimum angle the bone will yaw to
  100660. * * maxPitch: the maximum angle the bone will pitch to
  100661. * * minPitch: the minimum angle the bone will yaw to
  100662. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100663. * * upAxis: the up axis of the coordinate system
  100664. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100665. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100666. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100667. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100668. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100669. * * adjustRoll: used to make an adjustment to the roll of the bone
  100670. **/
  100671. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100672. maxYaw?: number;
  100673. minYaw?: number;
  100674. maxPitch?: number;
  100675. minPitch?: number;
  100676. slerpAmount?: number;
  100677. upAxis?: Vector3;
  100678. upAxisSpace?: Space;
  100679. yawAxis?: Vector3;
  100680. pitchAxis?: Vector3;
  100681. adjustYaw?: number;
  100682. adjustPitch?: number;
  100683. adjustRoll?: number;
  100684. });
  100685. /**
  100686. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100687. */
  100688. update(): void;
  100689. private _getAngleDiff;
  100690. private _getAngleBetween;
  100691. private _isAngleBetween;
  100692. }
  100693. }
  100694. declare module BABYLON {
  100695. /**
  100696. * Manage the gamepad inputs to control an arc rotate camera.
  100697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100698. */
  100699. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100700. /**
  100701. * Defines the camera the input is attached to.
  100702. */
  100703. camera: ArcRotateCamera;
  100704. /**
  100705. * Defines the gamepad the input is gathering event from.
  100706. */
  100707. gamepad: Nullable<Gamepad>;
  100708. /**
  100709. * Defines the gamepad rotation sensiblity.
  100710. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100711. */
  100712. gamepadRotationSensibility: number;
  100713. /**
  100714. * Defines the gamepad move sensiblity.
  100715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100716. */
  100717. gamepadMoveSensibility: number;
  100718. private _onGamepadConnectedObserver;
  100719. private _onGamepadDisconnectedObserver;
  100720. /**
  100721. * Attach the input controls to a specific dom element to get the input from.
  100722. * @param element Defines the element the controls should be listened from
  100723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100724. */
  100725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100726. /**
  100727. * Detach the current controls from the specified dom element.
  100728. * @param element Defines the element to stop listening the inputs from
  100729. */
  100730. detachControl(element: Nullable<HTMLElement>): void;
  100731. /**
  100732. * Update the current camera state depending on the inputs that have been used this frame.
  100733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100734. */
  100735. checkInputs(): void;
  100736. /**
  100737. * Gets the class name of the current intput.
  100738. * @returns the class name
  100739. */
  100740. getClassName(): string;
  100741. /**
  100742. * Get the friendly name associated with the input class.
  100743. * @returns the input friendly name
  100744. */
  100745. getSimpleName(): string;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. interface ArcRotateCameraInputsManager {
  100750. /**
  100751. * Add orientation input support to the input manager.
  100752. * @returns the current input manager
  100753. */
  100754. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100755. }
  100756. /**
  100757. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100759. */
  100760. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100761. /**
  100762. * Defines the camera the input is attached to.
  100763. */
  100764. camera: ArcRotateCamera;
  100765. /**
  100766. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100767. */
  100768. alphaCorrection: number;
  100769. /**
  100770. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100771. */
  100772. gammaCorrection: number;
  100773. private _alpha;
  100774. private _gamma;
  100775. private _dirty;
  100776. private _deviceOrientationHandler;
  100777. /**
  100778. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100779. */
  100780. constructor();
  100781. /**
  100782. * Attach the input controls to a specific dom element to get the input from.
  100783. * @param element Defines the element the controls should be listened from
  100784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100785. */
  100786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100787. /** @hidden */
  100788. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100789. /**
  100790. * Update the current camera state depending on the inputs that have been used this frame.
  100791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100792. */
  100793. checkInputs(): void;
  100794. /**
  100795. * Detach the current controls from the specified dom element.
  100796. * @param element Defines the element to stop listening the inputs from
  100797. */
  100798. detachControl(element: Nullable<HTMLElement>): void;
  100799. /**
  100800. * Gets the class name of the current intput.
  100801. * @returns the class name
  100802. */
  100803. getClassName(): string;
  100804. /**
  100805. * Get the friendly name associated with the input class.
  100806. * @returns the input friendly name
  100807. */
  100808. getSimpleName(): string;
  100809. }
  100810. }
  100811. declare module BABYLON {
  100812. /**
  100813. * Listen to mouse events to control the camera.
  100814. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100815. */
  100816. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  100817. /**
  100818. * Defines the camera the input is attached to.
  100819. */
  100820. camera: FlyCamera;
  100821. /**
  100822. * Defines if touch is enabled. (Default is true.)
  100823. */
  100824. touchEnabled: boolean;
  100825. /**
  100826. * Defines the buttons associated with the input to handle camera rotation.
  100827. */
  100828. buttons: number[];
  100829. /**
  100830. * Assign buttons for Yaw control.
  100831. */
  100832. buttonsYaw: number[];
  100833. /**
  100834. * Assign buttons for Pitch control.
  100835. */
  100836. buttonsPitch: number[];
  100837. /**
  100838. * Assign buttons for Roll control.
  100839. */
  100840. buttonsRoll: number[];
  100841. /**
  100842. * Detect if any button is being pressed while mouse is moved.
  100843. * -1 = Mouse locked.
  100844. * 0 = Left button.
  100845. * 1 = Middle Button.
  100846. * 2 = Right Button.
  100847. */
  100848. activeButton: number;
  100849. /**
  100850. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  100851. * Higher values reduce its sensitivity.
  100852. */
  100853. angularSensibility: number;
  100854. private _mousemoveCallback;
  100855. private _observer;
  100856. private _rollObserver;
  100857. private previousPosition;
  100858. private noPreventDefault;
  100859. private element;
  100860. /**
  100861. * Listen to mouse events to control the camera.
  100862. * @param touchEnabled Define if touch is enabled. (Default is true.)
  100863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100864. */
  100865. constructor(touchEnabled?: boolean);
  100866. /**
  100867. * Attach the mouse control to the HTML DOM element.
  100868. * @param element Defines the element that listens to the input events.
  100869. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  100870. */
  100871. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100872. /**
  100873. * Detach the current controls from the specified dom element.
  100874. * @param element Defines the element to stop listening the inputs from
  100875. */
  100876. detachControl(element: Nullable<HTMLElement>): void;
  100877. /**
  100878. * Gets the class name of the current input.
  100879. * @returns the class name.
  100880. */
  100881. getClassName(): string;
  100882. /**
  100883. * Get the friendly name associated with the input class.
  100884. * @returns the input's friendly name.
  100885. */
  100886. getSimpleName(): string;
  100887. private _pointerInput;
  100888. private _onMouseMove;
  100889. /**
  100890. * Rotate camera by mouse offset.
  100891. */
  100892. private rotateCamera;
  100893. }
  100894. }
  100895. declare module BABYLON {
  100896. /**
  100897. * Default Inputs manager for the FlyCamera.
  100898. * It groups all the default supported inputs for ease of use.
  100899. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100900. */
  100901. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  100902. /**
  100903. * Instantiates a new FlyCameraInputsManager.
  100904. * @param camera Defines the camera the inputs belong to.
  100905. */
  100906. constructor(camera: FlyCamera);
  100907. /**
  100908. * Add keyboard input support to the input manager.
  100909. * @returns the new FlyCameraKeyboardMoveInput().
  100910. */
  100911. addKeyboard(): FlyCameraInputsManager;
  100912. /**
  100913. * Add mouse input support to the input manager.
  100914. * @param touchEnabled Enable touch screen support.
  100915. * @returns the new FlyCameraMouseInput().
  100916. */
  100917. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100923. * such as in a 3D Space Shooter or a Flight Simulator.
  100924. */
  100925. export class FlyCamera extends TargetCamera {
  100926. /**
  100927. * Define the collision ellipsoid of the camera.
  100928. * This is helpful for simulating a camera body, like a player's body.
  100929. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100930. */
  100931. ellipsoid: Vector3;
  100932. /**
  100933. * Define an offset for the position of the ellipsoid around the camera.
  100934. * This can be helpful if the camera is attached away from the player's body center,
  100935. * such as at its head.
  100936. */
  100937. ellipsoidOffset: Vector3;
  100938. /**
  100939. * Enable or disable collisions of the camera with the rest of the scene objects.
  100940. */
  100941. checkCollisions: boolean;
  100942. /**
  100943. * Enable or disable gravity on the camera.
  100944. */
  100945. applyGravity: boolean;
  100946. /**
  100947. * Define the current direction the camera is moving to.
  100948. */
  100949. cameraDirection: Vector3;
  100950. /**
  100951. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  100952. * This overrides and empties cameraRotation.
  100953. */
  100954. rotationQuaternion: Quaternion;
  100955. /**
  100956. * Track Roll to maintain the wanted Rolling when looking around.
  100957. */
  100958. _trackRoll: number;
  100959. /**
  100960. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  100961. */
  100962. rollCorrect: number;
  100963. /**
  100964. * Mimic a banked turn, Rolling the camera when Yawing.
  100965. * It's recommended to use rollCorrect = 10 for faster banking correction.
  100966. */
  100967. bankedTurn: boolean;
  100968. /**
  100969. * Limit in radians for how much Roll banking will add. (Default: 90°)
  100970. */
  100971. bankedTurnLimit: number;
  100972. /**
  100973. * Value of 0 disables the banked Roll.
  100974. * Value of 1 is equal to the Yaw angle in radians.
  100975. */
  100976. bankedTurnMultiplier: number;
  100977. /**
  100978. * The inputs manager loads all the input sources, such as keyboard and mouse.
  100979. */
  100980. inputs: FlyCameraInputsManager;
  100981. /**
  100982. * Gets the input sensibility for mouse input.
  100983. * Higher values reduce sensitivity.
  100984. */
  100985. /**
  100986. * Sets the input sensibility for a mouse input.
  100987. * Higher values reduce sensitivity.
  100988. */
  100989. angularSensibility: number;
  100990. /**
  100991. * Get the keys for camera movement forward.
  100992. */
  100993. /**
  100994. * Set the keys for camera movement forward.
  100995. */
  100996. keysForward: number[];
  100997. /**
  100998. * Get the keys for camera movement backward.
  100999. */
  101000. keysBackward: number[];
  101001. /**
  101002. * Get the keys for camera movement up.
  101003. */
  101004. /**
  101005. * Set the keys for camera movement up.
  101006. */
  101007. keysUp: number[];
  101008. /**
  101009. * Get the keys for camera movement down.
  101010. */
  101011. /**
  101012. * Set the keys for camera movement down.
  101013. */
  101014. keysDown: number[];
  101015. /**
  101016. * Get the keys for camera movement left.
  101017. */
  101018. /**
  101019. * Set the keys for camera movement left.
  101020. */
  101021. keysLeft: number[];
  101022. /**
  101023. * Set the keys for camera movement right.
  101024. */
  101025. /**
  101026. * Set the keys for camera movement right.
  101027. */
  101028. keysRight: number[];
  101029. /**
  101030. * Event raised when the camera collides with a mesh in the scene.
  101031. */
  101032. onCollide: (collidedMesh: AbstractMesh) => void;
  101033. private _collider;
  101034. private _needMoveForGravity;
  101035. private _oldPosition;
  101036. private _diffPosition;
  101037. private _newPosition;
  101038. /** @hidden */
  101039. _localDirection: Vector3;
  101040. /** @hidden */
  101041. _transformedDirection: Vector3;
  101042. /**
  101043. * Instantiates a FlyCamera.
  101044. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101045. * such as in a 3D Space Shooter or a Flight Simulator.
  101046. * @param name Define the name of the camera in the scene.
  101047. * @param position Define the starting position of the camera in the scene.
  101048. * @param scene Define the scene the camera belongs to.
  101049. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101050. */
  101051. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101052. /**
  101053. * Attach a control to the HTML DOM element.
  101054. * @param element Defines the element that listens to the input events.
  101055. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101056. */
  101057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101058. /**
  101059. * Detach a control from the HTML DOM element.
  101060. * The camera will stop reacting to that input.
  101061. * @param element Defines the element that listens to the input events.
  101062. */
  101063. detachControl(element: HTMLElement): void;
  101064. private _collisionMask;
  101065. /**
  101066. * Get the mask that the camera ignores in collision events.
  101067. */
  101068. /**
  101069. * Set the mask that the camera ignores in collision events.
  101070. */
  101071. collisionMask: number;
  101072. /** @hidden */
  101073. _collideWithWorld(displacement: Vector3): void;
  101074. /** @hidden */
  101075. private _onCollisionPositionChange;
  101076. /** @hidden */
  101077. _checkInputs(): void;
  101078. /** @hidden */
  101079. _decideIfNeedsToMove(): boolean;
  101080. /** @hidden */
  101081. _updatePosition(): void;
  101082. /**
  101083. * Restore the Roll to its target value at the rate specified.
  101084. * @param rate - Higher means slower restoring.
  101085. * @hidden
  101086. */
  101087. restoreRoll(rate: number): void;
  101088. /**
  101089. * Destroy the camera and release the current resources held by it.
  101090. */
  101091. dispose(): void;
  101092. /**
  101093. * Get the current object class name.
  101094. * @returns the class name.
  101095. */
  101096. getClassName(): string;
  101097. }
  101098. }
  101099. declare module BABYLON {
  101100. /**
  101101. * Listen to keyboard events to control the camera.
  101102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101103. */
  101104. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101105. /**
  101106. * Defines the camera the input is attached to.
  101107. */
  101108. camera: FlyCamera;
  101109. /**
  101110. * The list of keyboard keys used to control the forward move of the camera.
  101111. */
  101112. keysForward: number[];
  101113. /**
  101114. * The list of keyboard keys used to control the backward move of the camera.
  101115. */
  101116. keysBackward: number[];
  101117. /**
  101118. * The list of keyboard keys used to control the forward move of the camera.
  101119. */
  101120. keysUp: number[];
  101121. /**
  101122. * The list of keyboard keys used to control the backward move of the camera.
  101123. */
  101124. keysDown: number[];
  101125. /**
  101126. * The list of keyboard keys used to control the right strafe move of the camera.
  101127. */
  101128. keysRight: number[];
  101129. /**
  101130. * The list of keyboard keys used to control the left strafe move of the camera.
  101131. */
  101132. keysLeft: number[];
  101133. private _keys;
  101134. private _onCanvasBlurObserver;
  101135. private _onKeyboardObserver;
  101136. private _engine;
  101137. private _scene;
  101138. /**
  101139. * Attach the input controls to a specific dom element to get the input from.
  101140. * @param element Defines the element the controls should be listened from
  101141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101142. */
  101143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101144. /**
  101145. * Detach the current controls from the specified dom element.
  101146. * @param element Defines the element to stop listening the inputs from
  101147. */
  101148. detachControl(element: Nullable<HTMLElement>): void;
  101149. /**
  101150. * Gets the class name of the current intput.
  101151. * @returns the class name
  101152. */
  101153. getClassName(): string;
  101154. /** @hidden */
  101155. _onLostFocus(e: FocusEvent): void;
  101156. /**
  101157. * Get the friendly name associated with the input class.
  101158. * @returns the input friendly name
  101159. */
  101160. getSimpleName(): string;
  101161. /**
  101162. * Update the current camera state depending on the inputs that have been used this frame.
  101163. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101164. */
  101165. checkInputs(): void;
  101166. }
  101167. }
  101168. declare module BABYLON {
  101169. /**
  101170. * Manage the mouse wheel inputs to control a follow camera.
  101171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101172. */
  101173. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101174. /**
  101175. * Defines the camera the input is attached to.
  101176. */
  101177. camera: FollowCamera;
  101178. /**
  101179. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101180. */
  101181. axisControlRadius: boolean;
  101182. /**
  101183. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101184. */
  101185. axisControlHeight: boolean;
  101186. /**
  101187. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101188. */
  101189. axisControlRotation: boolean;
  101190. /**
  101191. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101192. * relation to mouseWheel events.
  101193. */
  101194. wheelPrecision: number;
  101195. /**
  101196. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101197. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101198. */
  101199. wheelDeltaPercentage: number;
  101200. private _wheel;
  101201. private _observer;
  101202. /**
  101203. * Attach the input controls to a specific dom element to get the input from.
  101204. * @param element Defines the element the controls should be listened from
  101205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101206. */
  101207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101208. /**
  101209. * Detach the current controls from the specified dom element.
  101210. * @param element Defines the element to stop listening the inputs from
  101211. */
  101212. detachControl(element: Nullable<HTMLElement>): void;
  101213. /**
  101214. * Gets the class name of the current intput.
  101215. * @returns the class name
  101216. */
  101217. getClassName(): string;
  101218. /**
  101219. * Get the friendly name associated with the input class.
  101220. * @returns the input friendly name
  101221. */
  101222. getSimpleName(): string;
  101223. }
  101224. }
  101225. declare module BABYLON {
  101226. /**
  101227. * Manage the pointers inputs to control an follow camera.
  101228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101229. */
  101230. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101231. /**
  101232. * Defines the camera the input is attached to.
  101233. */
  101234. camera: FollowCamera;
  101235. /**
  101236. * Gets the class name of the current input.
  101237. * @returns the class name
  101238. */
  101239. getClassName(): string;
  101240. /**
  101241. * Defines the pointer angular sensibility along the X axis or how fast is
  101242. * the camera rotating.
  101243. * A negative number will reverse the axis direction.
  101244. */
  101245. angularSensibilityX: number;
  101246. /**
  101247. * Defines the pointer angular sensibility along the Y axis or how fast is
  101248. * the camera rotating.
  101249. * A negative number will reverse the axis direction.
  101250. */
  101251. angularSensibilityY: number;
  101252. /**
  101253. * Defines the pointer pinch precision or how fast is the camera zooming.
  101254. * A negative number will reverse the axis direction.
  101255. */
  101256. pinchPrecision: number;
  101257. /**
  101258. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101259. * from 0.
  101260. * It defines the percentage of current camera.radius to use as delta when
  101261. * pinch zoom is used.
  101262. */
  101263. pinchDeltaPercentage: number;
  101264. /**
  101265. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101266. */
  101267. axisXControlRadius: boolean;
  101268. /**
  101269. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101270. */
  101271. axisXControlHeight: boolean;
  101272. /**
  101273. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101274. */
  101275. axisXControlRotation: boolean;
  101276. /**
  101277. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101278. */
  101279. axisYControlRadius: boolean;
  101280. /**
  101281. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101282. */
  101283. axisYControlHeight: boolean;
  101284. /**
  101285. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101286. */
  101287. axisYControlRotation: boolean;
  101288. /**
  101289. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101290. */
  101291. axisPinchControlRadius: boolean;
  101292. /**
  101293. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101294. */
  101295. axisPinchControlHeight: boolean;
  101296. /**
  101297. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101298. */
  101299. axisPinchControlRotation: boolean;
  101300. /**
  101301. * Log error messages if basic misconfiguration has occurred.
  101302. */
  101303. warningEnable: boolean;
  101304. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101305. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101306. private _warningCounter;
  101307. private _warning;
  101308. }
  101309. }
  101310. declare module BABYLON {
  101311. /**
  101312. * Default Inputs manager for the FollowCamera.
  101313. * It groups all the default supported inputs for ease of use.
  101314. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101315. */
  101316. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101317. /**
  101318. * Instantiates a new FollowCameraInputsManager.
  101319. * @param camera Defines the camera the inputs belong to
  101320. */
  101321. constructor(camera: FollowCamera);
  101322. /**
  101323. * Add keyboard input support to the input manager.
  101324. * @returns the current input manager
  101325. */
  101326. addKeyboard(): FollowCameraInputsManager;
  101327. /**
  101328. * Add mouse wheel input support to the input manager.
  101329. * @returns the current input manager
  101330. */
  101331. addMouseWheel(): FollowCameraInputsManager;
  101332. /**
  101333. * Add pointers input support to the input manager.
  101334. * @returns the current input manager
  101335. */
  101336. addPointers(): FollowCameraInputsManager;
  101337. /**
  101338. * Add orientation input support to the input manager.
  101339. * @returns the current input manager
  101340. */
  101341. addVRDeviceOrientation(): FollowCameraInputsManager;
  101342. }
  101343. }
  101344. declare module BABYLON {
  101345. /**
  101346. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101347. * an arc rotate version arcFollowCamera are available.
  101348. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101349. */
  101350. export class FollowCamera extends TargetCamera {
  101351. /**
  101352. * Distance the follow camera should follow an object at
  101353. */
  101354. radius: number;
  101355. /**
  101356. * Minimum allowed distance of the camera to the axis of rotation
  101357. * (The camera can not get closer).
  101358. * This can help limiting how the Camera is able to move in the scene.
  101359. */
  101360. lowerRadiusLimit: Nullable<number>;
  101361. /**
  101362. * Maximum allowed distance of the camera to the axis of rotation
  101363. * (The camera can not get further).
  101364. * This can help limiting how the Camera is able to move in the scene.
  101365. */
  101366. upperRadiusLimit: Nullable<number>;
  101367. /**
  101368. * Define a rotation offset between the camera and the object it follows
  101369. */
  101370. rotationOffset: number;
  101371. /**
  101372. * Minimum allowed angle to camera position relative to target object.
  101373. * This can help limiting how the Camera is able to move in the scene.
  101374. */
  101375. lowerRotationOffsetLimit: Nullable<number>;
  101376. /**
  101377. * Maximum allowed angle to camera position relative to target object.
  101378. * This can help limiting how the Camera is able to move in the scene.
  101379. */
  101380. upperRotationOffsetLimit: Nullable<number>;
  101381. /**
  101382. * Define a height offset between the camera and the object it follows.
  101383. * It can help following an object from the top (like a car chaing a plane)
  101384. */
  101385. heightOffset: number;
  101386. /**
  101387. * Minimum allowed height of camera position relative to target object.
  101388. * This can help limiting how the Camera is able to move in the scene.
  101389. */
  101390. lowerHeightOffsetLimit: Nullable<number>;
  101391. /**
  101392. * Maximum allowed height of camera position relative to target object.
  101393. * This can help limiting how the Camera is able to move in the scene.
  101394. */
  101395. upperHeightOffsetLimit: Nullable<number>;
  101396. /**
  101397. * Define how fast the camera can accelerate to follow it s target.
  101398. */
  101399. cameraAcceleration: number;
  101400. /**
  101401. * Define the speed limit of the camera following an object.
  101402. */
  101403. maxCameraSpeed: number;
  101404. /**
  101405. * Define the target of the camera.
  101406. */
  101407. lockedTarget: Nullable<AbstractMesh>;
  101408. /**
  101409. * Defines the input associated with the camera.
  101410. */
  101411. inputs: FollowCameraInputsManager;
  101412. /**
  101413. * Instantiates the follow camera.
  101414. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101415. * @param name Define the name of the camera in the scene
  101416. * @param position Define the position of the camera
  101417. * @param scene Define the scene the camera belong to
  101418. * @param lockedTarget Define the target of the camera
  101419. */
  101420. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101421. private _follow;
  101422. /**
  101423. * Attached controls to the current camera.
  101424. * @param element Defines the element the controls should be listened from
  101425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101426. */
  101427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101428. /**
  101429. * Detach the current controls from the camera.
  101430. * The camera will stop reacting to inputs.
  101431. * @param element Defines the element to stop listening the inputs from
  101432. */
  101433. detachControl(element: HTMLElement): void;
  101434. /** @hidden */
  101435. _checkInputs(): void;
  101436. private _checkLimits;
  101437. /**
  101438. * Gets the camera class name.
  101439. * @returns the class name
  101440. */
  101441. getClassName(): string;
  101442. }
  101443. /**
  101444. * Arc Rotate version of the follow camera.
  101445. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101446. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101447. */
  101448. export class ArcFollowCamera extends TargetCamera {
  101449. /** The longitudinal angle of the camera */
  101450. alpha: number;
  101451. /** The latitudinal angle of the camera */
  101452. beta: number;
  101453. /** The radius of the camera from its target */
  101454. radius: number;
  101455. /** Define the camera target (the messh it should follow) */
  101456. target: Nullable<AbstractMesh>;
  101457. private _cartesianCoordinates;
  101458. /**
  101459. * Instantiates a new ArcFollowCamera
  101460. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101461. * @param name Define the name of the camera
  101462. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101463. * @param beta Define the rotation angle of the camera around the elevation axis
  101464. * @param radius Define the radius of the camera from its target point
  101465. * @param target Define the target of the camera
  101466. * @param scene Define the scene the camera belongs to
  101467. */
  101468. constructor(name: string,
  101469. /** The longitudinal angle of the camera */
  101470. alpha: number,
  101471. /** The latitudinal angle of the camera */
  101472. beta: number,
  101473. /** The radius of the camera from its target */
  101474. radius: number,
  101475. /** Define the camera target (the messh it should follow) */
  101476. target: Nullable<AbstractMesh>, scene: Scene);
  101477. private _follow;
  101478. /** @hidden */
  101479. _checkInputs(): void;
  101480. /**
  101481. * Returns the class name of the object.
  101482. * It is mostly used internally for serialization purposes.
  101483. */
  101484. getClassName(): string;
  101485. }
  101486. }
  101487. declare module BABYLON {
  101488. /**
  101489. * Manage the keyboard inputs to control the movement of a follow camera.
  101490. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101491. */
  101492. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101493. /**
  101494. * Defines the camera the input is attached to.
  101495. */
  101496. camera: FollowCamera;
  101497. /**
  101498. * Defines the list of key codes associated with the up action (increase heightOffset)
  101499. */
  101500. keysHeightOffsetIncr: number[];
  101501. /**
  101502. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101503. */
  101504. keysHeightOffsetDecr: number[];
  101505. /**
  101506. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101507. */
  101508. keysHeightOffsetModifierAlt: boolean;
  101509. /**
  101510. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101511. */
  101512. keysHeightOffsetModifierCtrl: boolean;
  101513. /**
  101514. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101515. */
  101516. keysHeightOffsetModifierShift: boolean;
  101517. /**
  101518. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101519. */
  101520. keysRotationOffsetIncr: number[];
  101521. /**
  101522. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101523. */
  101524. keysRotationOffsetDecr: number[];
  101525. /**
  101526. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101527. */
  101528. keysRotationOffsetModifierAlt: boolean;
  101529. /**
  101530. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101531. */
  101532. keysRotationOffsetModifierCtrl: boolean;
  101533. /**
  101534. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101535. */
  101536. keysRotationOffsetModifierShift: boolean;
  101537. /**
  101538. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101539. */
  101540. keysRadiusIncr: number[];
  101541. /**
  101542. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101543. */
  101544. keysRadiusDecr: number[];
  101545. /**
  101546. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101547. */
  101548. keysRadiusModifierAlt: boolean;
  101549. /**
  101550. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101551. */
  101552. keysRadiusModifierCtrl: boolean;
  101553. /**
  101554. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101555. */
  101556. keysRadiusModifierShift: boolean;
  101557. /**
  101558. * Defines the rate of change of heightOffset.
  101559. */
  101560. heightSensibility: number;
  101561. /**
  101562. * Defines the rate of change of rotationOffset.
  101563. */
  101564. rotationSensibility: number;
  101565. /**
  101566. * Defines the rate of change of radius.
  101567. */
  101568. radiusSensibility: number;
  101569. private _keys;
  101570. private _ctrlPressed;
  101571. private _altPressed;
  101572. private _shiftPressed;
  101573. private _onCanvasBlurObserver;
  101574. private _onKeyboardObserver;
  101575. private _engine;
  101576. private _scene;
  101577. /**
  101578. * Attach the input controls to a specific dom element to get the input from.
  101579. * @param element Defines the element the controls should be listened from
  101580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101581. */
  101582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101583. /**
  101584. * Detach the current controls from the specified dom element.
  101585. * @param element Defines the element to stop listening the inputs from
  101586. */
  101587. detachControl(element: Nullable<HTMLElement>): void;
  101588. /**
  101589. * Update the current camera state depending on the inputs that have been used this frame.
  101590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101591. */
  101592. checkInputs(): void;
  101593. /**
  101594. * Gets the class name of the current input.
  101595. * @returns the class name
  101596. */
  101597. getClassName(): string;
  101598. /**
  101599. * Get the friendly name associated with the input class.
  101600. * @returns the input friendly name
  101601. */
  101602. getSimpleName(): string;
  101603. /**
  101604. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101605. * allow modification of the heightOffset value.
  101606. */
  101607. private _modifierHeightOffset;
  101608. /**
  101609. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101610. * allow modification of the rotationOffset value.
  101611. */
  101612. private _modifierRotationOffset;
  101613. /**
  101614. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101615. * allow modification of the radius value.
  101616. */
  101617. private _modifierRadius;
  101618. }
  101619. }
  101620. declare module BABYLON {
  101621. interface FreeCameraInputsManager {
  101622. /**
  101623. * @hidden
  101624. */
  101625. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101626. /**
  101627. * Add orientation input support to the input manager.
  101628. * @returns the current input manager
  101629. */
  101630. addDeviceOrientation(): FreeCameraInputsManager;
  101631. }
  101632. /**
  101633. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101634. * Screen rotation is taken into account.
  101635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101636. */
  101637. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101638. private _camera;
  101639. private _screenOrientationAngle;
  101640. private _constantTranform;
  101641. private _screenQuaternion;
  101642. private _alpha;
  101643. private _beta;
  101644. private _gamma;
  101645. /**
  101646. * Can be used to detect if a device orientation sensor is availible on a device
  101647. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101648. * @returns a promise that will resolve on orientation change
  101649. */
  101650. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101651. /**
  101652. * @hidden
  101653. */
  101654. _onDeviceOrientationChangedObservable: Observable<void>;
  101655. /**
  101656. * Instantiates a new input
  101657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101658. */
  101659. constructor();
  101660. /**
  101661. * Define the camera controlled by the input.
  101662. */
  101663. camera: FreeCamera;
  101664. /**
  101665. * Attach the input controls to a specific dom element to get the input from.
  101666. * @param element Defines the element the controls should be listened from
  101667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101668. */
  101669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101670. private _orientationChanged;
  101671. private _deviceOrientation;
  101672. /**
  101673. * Detach the current controls from the specified dom element.
  101674. * @param element Defines the element to stop listening the inputs from
  101675. */
  101676. detachControl(element: Nullable<HTMLElement>): void;
  101677. /**
  101678. * Update the current camera state depending on the inputs that have been used this frame.
  101679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101680. */
  101681. checkInputs(): void;
  101682. /**
  101683. * Gets the class name of the current intput.
  101684. * @returns the class name
  101685. */
  101686. getClassName(): string;
  101687. /**
  101688. * Get the friendly name associated with the input class.
  101689. * @returns the input friendly name
  101690. */
  101691. getSimpleName(): string;
  101692. }
  101693. }
  101694. declare module BABYLON {
  101695. /**
  101696. * Manage the gamepad inputs to control a free camera.
  101697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101698. */
  101699. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101700. /**
  101701. * Define the camera the input is attached to.
  101702. */
  101703. camera: FreeCamera;
  101704. /**
  101705. * Define the Gamepad controlling the input
  101706. */
  101707. gamepad: Nullable<Gamepad>;
  101708. /**
  101709. * Defines the gamepad rotation sensiblity.
  101710. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101711. */
  101712. gamepadAngularSensibility: number;
  101713. /**
  101714. * Defines the gamepad move sensiblity.
  101715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101716. */
  101717. gamepadMoveSensibility: number;
  101718. private _onGamepadConnectedObserver;
  101719. private _onGamepadDisconnectedObserver;
  101720. private _cameraTransform;
  101721. private _deltaTransform;
  101722. private _vector3;
  101723. private _vector2;
  101724. /**
  101725. * Attach the input controls to a specific dom element to get the input from.
  101726. * @param element Defines the element the controls should be listened from
  101727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101728. */
  101729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101730. /**
  101731. * Detach the current controls from the specified dom element.
  101732. * @param element Defines the element to stop listening the inputs from
  101733. */
  101734. detachControl(element: Nullable<HTMLElement>): void;
  101735. /**
  101736. * Update the current camera state depending on the inputs that have been used this frame.
  101737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101738. */
  101739. checkInputs(): void;
  101740. /**
  101741. * Gets the class name of the current intput.
  101742. * @returns the class name
  101743. */
  101744. getClassName(): string;
  101745. /**
  101746. * Get the friendly name associated with the input class.
  101747. * @returns the input friendly name
  101748. */
  101749. getSimpleName(): string;
  101750. }
  101751. }
  101752. declare module BABYLON {
  101753. /**
  101754. * Defines the potential axis of a Joystick
  101755. */
  101756. export enum JoystickAxis {
  101757. /** X axis */
  101758. X = 0,
  101759. /** Y axis */
  101760. Y = 1,
  101761. /** Z axis */
  101762. Z = 2
  101763. }
  101764. /**
  101765. * Class used to define virtual joystick (used in touch mode)
  101766. */
  101767. export class VirtualJoystick {
  101768. /**
  101769. * Gets or sets a boolean indicating that left and right values must be inverted
  101770. */
  101771. reverseLeftRight: boolean;
  101772. /**
  101773. * Gets or sets a boolean indicating that up and down values must be inverted
  101774. */
  101775. reverseUpDown: boolean;
  101776. /**
  101777. * Gets the offset value for the position (ie. the change of the position value)
  101778. */
  101779. deltaPosition: Vector3;
  101780. /**
  101781. * Gets a boolean indicating if the virtual joystick was pressed
  101782. */
  101783. pressed: boolean;
  101784. /**
  101785. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101786. */
  101787. static Canvas: Nullable<HTMLCanvasElement>;
  101788. private static _globalJoystickIndex;
  101789. private static vjCanvasContext;
  101790. private static vjCanvasWidth;
  101791. private static vjCanvasHeight;
  101792. private static halfWidth;
  101793. private _action;
  101794. private _axisTargetedByLeftAndRight;
  101795. private _axisTargetedByUpAndDown;
  101796. private _joystickSensibility;
  101797. private _inversedSensibility;
  101798. private _joystickPointerID;
  101799. private _joystickColor;
  101800. private _joystickPointerPos;
  101801. private _joystickPreviousPointerPos;
  101802. private _joystickPointerStartPos;
  101803. private _deltaJoystickVector;
  101804. private _leftJoystick;
  101805. private _touches;
  101806. private _onPointerDownHandlerRef;
  101807. private _onPointerMoveHandlerRef;
  101808. private _onPointerUpHandlerRef;
  101809. private _onResize;
  101810. /**
  101811. * Creates a new virtual joystick
  101812. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101813. */
  101814. constructor(leftJoystick?: boolean);
  101815. /**
  101816. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101817. * @param newJoystickSensibility defines the new sensibility
  101818. */
  101819. setJoystickSensibility(newJoystickSensibility: number): void;
  101820. private _onPointerDown;
  101821. private _onPointerMove;
  101822. private _onPointerUp;
  101823. /**
  101824. * Change the color of the virtual joystick
  101825. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101826. */
  101827. setJoystickColor(newColor: string): void;
  101828. /**
  101829. * Defines a callback to call when the joystick is touched
  101830. * @param action defines the callback
  101831. */
  101832. setActionOnTouch(action: () => any): void;
  101833. /**
  101834. * Defines which axis you'd like to control for left & right
  101835. * @param axis defines the axis to use
  101836. */
  101837. setAxisForLeftRight(axis: JoystickAxis): void;
  101838. /**
  101839. * Defines which axis you'd like to control for up & down
  101840. * @param axis defines the axis to use
  101841. */
  101842. setAxisForUpDown(axis: JoystickAxis): void;
  101843. private _drawVirtualJoystick;
  101844. /**
  101845. * Release internal HTML canvas
  101846. */
  101847. releaseCanvas(): void;
  101848. }
  101849. }
  101850. declare module BABYLON {
  101851. interface FreeCameraInputsManager {
  101852. /**
  101853. * Add virtual joystick input support to the input manager.
  101854. * @returns the current input manager
  101855. */
  101856. addVirtualJoystick(): FreeCameraInputsManager;
  101857. }
  101858. /**
  101859. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  101860. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101861. */
  101862. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  101863. /**
  101864. * Defines the camera the input is attached to.
  101865. */
  101866. camera: FreeCamera;
  101867. private _leftjoystick;
  101868. private _rightjoystick;
  101869. /**
  101870. * Gets the left stick of the virtual joystick.
  101871. * @returns The virtual Joystick
  101872. */
  101873. getLeftJoystick(): VirtualJoystick;
  101874. /**
  101875. * Gets the right stick of the virtual joystick.
  101876. * @returns The virtual Joystick
  101877. */
  101878. getRightJoystick(): VirtualJoystick;
  101879. /**
  101880. * Update the current camera state depending on the inputs that have been used this frame.
  101881. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101882. */
  101883. checkInputs(): void;
  101884. /**
  101885. * Attach the input controls to a specific dom element to get the input from.
  101886. * @param element Defines the element the controls should be listened from
  101887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101888. */
  101889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101890. /**
  101891. * Detach the current controls from the specified dom element.
  101892. * @param element Defines the element to stop listening the inputs from
  101893. */
  101894. detachControl(element: Nullable<HTMLElement>): void;
  101895. /**
  101896. * Gets the class name of the current intput.
  101897. * @returns the class name
  101898. */
  101899. getClassName(): string;
  101900. /**
  101901. * Get the friendly name associated with the input class.
  101902. * @returns the input friendly name
  101903. */
  101904. getSimpleName(): string;
  101905. }
  101906. }
  101907. declare module BABYLON {
  101908. /**
  101909. * This represents a FPS type of camera controlled by touch.
  101910. * This is like a universal camera minus the Gamepad controls.
  101911. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101912. */
  101913. export class TouchCamera extends FreeCamera {
  101914. /**
  101915. * Defines the touch sensibility for rotation.
  101916. * The higher the faster.
  101917. */
  101918. touchAngularSensibility: number;
  101919. /**
  101920. * Defines the touch sensibility for move.
  101921. * The higher the faster.
  101922. */
  101923. touchMoveSensibility: number;
  101924. /**
  101925. * Instantiates a new touch camera.
  101926. * This represents a FPS type of camera controlled by touch.
  101927. * This is like a universal camera minus the Gamepad controls.
  101928. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101929. * @param name Define the name of the camera in the scene
  101930. * @param position Define the start position of the camera in the scene
  101931. * @param scene Define the scene the camera belongs to
  101932. */
  101933. constructor(name: string, position: Vector3, scene: Scene);
  101934. /**
  101935. * Gets the current object class name.
  101936. * @return the class name
  101937. */
  101938. getClassName(): string;
  101939. /** @hidden */
  101940. _setupInputs(): void;
  101941. }
  101942. }
  101943. declare module BABYLON {
  101944. /**
  101945. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  101946. * being tilted forward or back and left or right.
  101947. */
  101948. export class DeviceOrientationCamera extends FreeCamera {
  101949. private _initialQuaternion;
  101950. private _quaternionCache;
  101951. private _tmpDragQuaternion;
  101952. /**
  101953. * Creates a new device orientation camera
  101954. * @param name The name of the camera
  101955. * @param position The start position camera
  101956. * @param scene The scene the camera belongs to
  101957. */
  101958. constructor(name: string, position: Vector3, scene: Scene);
  101959. /**
  101960. * @hidden
  101961. * Disabled pointer input on first orientation sensor update (Default: true)
  101962. */
  101963. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  101964. private _dragFactor;
  101965. /**
  101966. * Enabled turning on the y axis when the orientation sensor is active
  101967. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  101968. */
  101969. enableHorizontalDragging(dragFactor?: number): void;
  101970. /**
  101971. * Gets the current instance class name ("DeviceOrientationCamera").
  101972. * This helps avoiding instanceof at run time.
  101973. * @returns the class name
  101974. */
  101975. getClassName(): string;
  101976. /**
  101977. * @hidden
  101978. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  101979. */
  101980. _checkInputs(): void;
  101981. /**
  101982. * Reset the camera to its default orientation on the specified axis only.
  101983. * @param axis The axis to reset
  101984. */
  101985. resetToCurrentRotation(axis?: Axis): void;
  101986. }
  101987. }
  101988. declare module BABYLON {
  101989. /**
  101990. * Defines supported buttons for XBox360 compatible gamepads
  101991. */
  101992. export enum Xbox360Button {
  101993. /** A */
  101994. A = 0,
  101995. /** B */
  101996. B = 1,
  101997. /** X */
  101998. X = 2,
  101999. /** Y */
  102000. Y = 3,
  102001. /** Start */
  102002. Start = 4,
  102003. /** Back */
  102004. Back = 5,
  102005. /** Left button */
  102006. LB = 6,
  102007. /** Right button */
  102008. RB = 7,
  102009. /** Left stick */
  102010. LeftStick = 8,
  102011. /** Right stick */
  102012. RightStick = 9
  102013. }
  102014. /** Defines values for XBox360 DPad */
  102015. export enum Xbox360Dpad {
  102016. /** Up */
  102017. Up = 0,
  102018. /** Down */
  102019. Down = 1,
  102020. /** Left */
  102021. Left = 2,
  102022. /** Right */
  102023. Right = 3
  102024. }
  102025. /**
  102026. * Defines a XBox360 gamepad
  102027. */
  102028. export class Xbox360Pad extends Gamepad {
  102029. private _leftTrigger;
  102030. private _rightTrigger;
  102031. private _onlefttriggerchanged;
  102032. private _onrighttriggerchanged;
  102033. private _onbuttondown;
  102034. private _onbuttonup;
  102035. private _ondpaddown;
  102036. private _ondpadup;
  102037. /** Observable raised when a button is pressed */
  102038. onButtonDownObservable: Observable<Xbox360Button>;
  102039. /** Observable raised when a button is released */
  102040. onButtonUpObservable: Observable<Xbox360Button>;
  102041. /** Observable raised when a pad is pressed */
  102042. onPadDownObservable: Observable<Xbox360Dpad>;
  102043. /** Observable raised when a pad is released */
  102044. onPadUpObservable: Observable<Xbox360Dpad>;
  102045. private _buttonA;
  102046. private _buttonB;
  102047. private _buttonX;
  102048. private _buttonY;
  102049. private _buttonBack;
  102050. private _buttonStart;
  102051. private _buttonLB;
  102052. private _buttonRB;
  102053. private _buttonLeftStick;
  102054. private _buttonRightStick;
  102055. private _dPadUp;
  102056. private _dPadDown;
  102057. private _dPadLeft;
  102058. private _dPadRight;
  102059. private _isXboxOnePad;
  102060. /**
  102061. * Creates a new XBox360 gamepad object
  102062. * @param id defines the id of this gamepad
  102063. * @param index defines its index
  102064. * @param gamepad defines the internal HTML gamepad object
  102065. * @param xboxOne defines if it is a XBox One gamepad
  102066. */
  102067. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102068. /**
  102069. * Defines the callback to call when left trigger is pressed
  102070. * @param callback defines the callback to use
  102071. */
  102072. onlefttriggerchanged(callback: (value: number) => void): void;
  102073. /**
  102074. * Defines the callback to call when right trigger is pressed
  102075. * @param callback defines the callback to use
  102076. */
  102077. onrighttriggerchanged(callback: (value: number) => void): void;
  102078. /**
  102079. * Gets the left trigger value
  102080. */
  102081. /**
  102082. * Sets the left trigger value
  102083. */
  102084. leftTrigger: number;
  102085. /**
  102086. * Gets the right trigger value
  102087. */
  102088. /**
  102089. * Sets the right trigger value
  102090. */
  102091. rightTrigger: number;
  102092. /**
  102093. * Defines the callback to call when a button is pressed
  102094. * @param callback defines the callback to use
  102095. */
  102096. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102097. /**
  102098. * Defines the callback to call when a button is released
  102099. * @param callback defines the callback to use
  102100. */
  102101. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102102. /**
  102103. * Defines the callback to call when a pad is pressed
  102104. * @param callback defines the callback to use
  102105. */
  102106. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102107. /**
  102108. * Defines the callback to call when a pad is released
  102109. * @param callback defines the callback to use
  102110. */
  102111. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102112. private _setButtonValue;
  102113. private _setDPadValue;
  102114. /**
  102115. * Gets the value of the `A` button
  102116. */
  102117. /**
  102118. * Sets the value of the `A` button
  102119. */
  102120. buttonA: number;
  102121. /**
  102122. * Gets the value of the `B` button
  102123. */
  102124. /**
  102125. * Sets the value of the `B` button
  102126. */
  102127. buttonB: number;
  102128. /**
  102129. * Gets the value of the `X` button
  102130. */
  102131. /**
  102132. * Sets the value of the `X` button
  102133. */
  102134. buttonX: number;
  102135. /**
  102136. * Gets the value of the `Y` button
  102137. */
  102138. /**
  102139. * Sets the value of the `Y` button
  102140. */
  102141. buttonY: number;
  102142. /**
  102143. * Gets the value of the `Start` button
  102144. */
  102145. /**
  102146. * Sets the value of the `Start` button
  102147. */
  102148. buttonStart: number;
  102149. /**
  102150. * Gets the value of the `Back` button
  102151. */
  102152. /**
  102153. * Sets the value of the `Back` button
  102154. */
  102155. buttonBack: number;
  102156. /**
  102157. * Gets the value of the `Left` button
  102158. */
  102159. /**
  102160. * Sets the value of the `Left` button
  102161. */
  102162. buttonLB: number;
  102163. /**
  102164. * Gets the value of the `Right` button
  102165. */
  102166. /**
  102167. * Sets the value of the `Right` button
  102168. */
  102169. buttonRB: number;
  102170. /**
  102171. * Gets the value of the Left joystick
  102172. */
  102173. /**
  102174. * Sets the value of the Left joystick
  102175. */
  102176. buttonLeftStick: number;
  102177. /**
  102178. * Gets the value of the Right joystick
  102179. */
  102180. /**
  102181. * Sets the value of the Right joystick
  102182. */
  102183. buttonRightStick: number;
  102184. /**
  102185. * Gets the value of D-pad up
  102186. */
  102187. /**
  102188. * Sets the value of D-pad up
  102189. */
  102190. dPadUp: number;
  102191. /**
  102192. * Gets the value of D-pad down
  102193. */
  102194. /**
  102195. * Sets the value of D-pad down
  102196. */
  102197. dPadDown: number;
  102198. /**
  102199. * Gets the value of D-pad left
  102200. */
  102201. /**
  102202. * Sets the value of D-pad left
  102203. */
  102204. dPadLeft: number;
  102205. /**
  102206. * Gets the value of D-pad right
  102207. */
  102208. /**
  102209. * Sets the value of D-pad right
  102210. */
  102211. dPadRight: number;
  102212. /**
  102213. * Force the gamepad to synchronize with device values
  102214. */
  102215. update(): void;
  102216. /**
  102217. * Disposes the gamepad
  102218. */
  102219. dispose(): void;
  102220. }
  102221. }
  102222. declare module BABYLON {
  102223. /**
  102224. * Manager for handling gamepads
  102225. */
  102226. export class GamepadManager {
  102227. private _scene?;
  102228. private _babylonGamepads;
  102229. private _oneGamepadConnected;
  102230. /** @hidden */
  102231. _isMonitoring: boolean;
  102232. private _gamepadEventSupported;
  102233. private _gamepadSupport;
  102234. /**
  102235. * observable to be triggered when the gamepad controller has been connected
  102236. */
  102237. onGamepadConnectedObservable: Observable<Gamepad>;
  102238. /**
  102239. * observable to be triggered when the gamepad controller has been disconnected
  102240. */
  102241. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102242. private _onGamepadConnectedEvent;
  102243. private _onGamepadDisconnectedEvent;
  102244. /**
  102245. * Initializes the gamepad manager
  102246. * @param _scene BabylonJS scene
  102247. */
  102248. constructor(_scene?: Scene | undefined);
  102249. /**
  102250. * The gamepads in the game pad manager
  102251. */
  102252. readonly gamepads: Gamepad[];
  102253. /**
  102254. * Get the gamepad controllers based on type
  102255. * @param type The type of gamepad controller
  102256. * @returns Nullable gamepad
  102257. */
  102258. getGamepadByType(type?: number): Nullable<Gamepad>;
  102259. /**
  102260. * Disposes the gamepad manager
  102261. */
  102262. dispose(): void;
  102263. private _addNewGamepad;
  102264. private _startMonitoringGamepads;
  102265. private _stopMonitoringGamepads;
  102266. /** @hidden */
  102267. _checkGamepadsStatus(): void;
  102268. private _updateGamepadObjects;
  102269. }
  102270. }
  102271. declare module BABYLON {
  102272. interface Scene {
  102273. /** @hidden */
  102274. _gamepadManager: Nullable<GamepadManager>;
  102275. /**
  102276. * Gets the gamepad manager associated with the scene
  102277. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102278. */
  102279. gamepadManager: GamepadManager;
  102280. }
  102281. /**
  102282. * Interface representing a free camera inputs manager
  102283. */
  102284. interface FreeCameraInputsManager {
  102285. /**
  102286. * Adds gamepad input support to the FreeCameraInputsManager.
  102287. * @returns the FreeCameraInputsManager
  102288. */
  102289. addGamepad(): FreeCameraInputsManager;
  102290. }
  102291. /**
  102292. * Interface representing an arc rotate camera inputs manager
  102293. */
  102294. interface ArcRotateCameraInputsManager {
  102295. /**
  102296. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102297. * @returns the camera inputs manager
  102298. */
  102299. addGamepad(): ArcRotateCameraInputsManager;
  102300. }
  102301. /**
  102302. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102303. */
  102304. export class GamepadSystemSceneComponent implements ISceneComponent {
  102305. /**
  102306. * The component name helpfull to identify the component in the list of scene components.
  102307. */
  102308. readonly name: string;
  102309. /**
  102310. * The scene the component belongs to.
  102311. */
  102312. scene: Scene;
  102313. /**
  102314. * Creates a new instance of the component for the given scene
  102315. * @param scene Defines the scene to register the component in
  102316. */
  102317. constructor(scene: Scene);
  102318. /**
  102319. * Registers the component in a given scene
  102320. */
  102321. register(): void;
  102322. /**
  102323. * Rebuilds the elements related to this component in case of
  102324. * context lost for instance.
  102325. */
  102326. rebuild(): void;
  102327. /**
  102328. * Disposes the component and the associated ressources
  102329. */
  102330. dispose(): void;
  102331. private _beforeCameraUpdate;
  102332. }
  102333. }
  102334. declare module BABYLON {
  102335. /**
  102336. * 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,
  102337. * which still works and will still be found in many Playgrounds.
  102338. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102339. */
  102340. export class UniversalCamera extends TouchCamera {
  102341. /**
  102342. * Defines the gamepad rotation sensiblity.
  102343. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102344. */
  102345. gamepadAngularSensibility: number;
  102346. /**
  102347. * Defines the gamepad move sensiblity.
  102348. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102349. */
  102350. gamepadMoveSensibility: number;
  102351. /**
  102352. * 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,
  102353. * which still works and will still be found in many Playgrounds.
  102354. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102355. * @param name Define the name of the camera in the scene
  102356. * @param position Define the start position of the camera in the scene
  102357. * @param scene Define the scene the camera belongs to
  102358. */
  102359. constructor(name: string, position: Vector3, scene: Scene);
  102360. /**
  102361. * Gets the current object class name.
  102362. * @return the class name
  102363. */
  102364. getClassName(): string;
  102365. }
  102366. }
  102367. declare module BABYLON {
  102368. /**
  102369. * This represents a FPS type of camera. This is only here for back compat purpose.
  102370. * Please use the UniversalCamera instead as both are identical.
  102371. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102372. */
  102373. export class GamepadCamera extends UniversalCamera {
  102374. /**
  102375. * Instantiates a new Gamepad Camera
  102376. * This represents a FPS type of camera. This is only here for back compat purpose.
  102377. * Please use the UniversalCamera instead as both are identical.
  102378. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102379. * @param name Define the name of the camera in the scene
  102380. * @param position Define the start position of the camera in the scene
  102381. * @param scene Define the scene the camera belongs to
  102382. */
  102383. constructor(name: string, position: Vector3, scene: Scene);
  102384. /**
  102385. * Gets the current object class name.
  102386. * @return the class name
  102387. */
  102388. getClassName(): string;
  102389. }
  102390. }
  102391. declare module BABYLON {
  102392. /** @hidden */
  102393. export var passPixelShader: {
  102394. name: string;
  102395. shader: string;
  102396. };
  102397. }
  102398. declare module BABYLON {
  102399. /** @hidden */
  102400. export var passCubePixelShader: {
  102401. name: string;
  102402. shader: string;
  102403. };
  102404. }
  102405. declare module BABYLON {
  102406. /**
  102407. * PassPostProcess which produces an output the same as it's input
  102408. */
  102409. export class PassPostProcess extends PostProcess {
  102410. /**
  102411. * Creates the PassPostProcess
  102412. * @param name The name of the effect.
  102413. * @param options The required width/height ratio to downsize to before computing the render pass.
  102414. * @param camera The camera to apply the render pass to.
  102415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102416. * @param engine The engine which the post process will be applied. (default: current engine)
  102417. * @param reusable If the post process can be reused on the same frame. (default: false)
  102418. * @param textureType The type of texture to be used when performing the post processing.
  102419. * @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)
  102420. */
  102421. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102422. }
  102423. /**
  102424. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102425. */
  102426. export class PassCubePostProcess extends PostProcess {
  102427. private _face;
  102428. /**
  102429. * Gets or sets the cube face to display.
  102430. * * 0 is +X
  102431. * * 1 is -X
  102432. * * 2 is +Y
  102433. * * 3 is -Y
  102434. * * 4 is +Z
  102435. * * 5 is -Z
  102436. */
  102437. face: number;
  102438. /**
  102439. * Creates the PassCubePostProcess
  102440. * @param name The name of the effect.
  102441. * @param options The required width/height ratio to downsize to before computing the render pass.
  102442. * @param camera The camera to apply the render pass to.
  102443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102444. * @param engine The engine which the post process will be applied. (default: current engine)
  102445. * @param reusable If the post process can be reused on the same frame. (default: false)
  102446. * @param textureType The type of texture to be used when performing the post processing.
  102447. * @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)
  102448. */
  102449. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102450. }
  102451. }
  102452. declare module BABYLON {
  102453. /** @hidden */
  102454. export var anaglyphPixelShader: {
  102455. name: string;
  102456. shader: string;
  102457. };
  102458. }
  102459. declare module BABYLON {
  102460. /**
  102461. * Postprocess used to generate anaglyphic rendering
  102462. */
  102463. export class AnaglyphPostProcess extends PostProcess {
  102464. private _passedProcess;
  102465. /**
  102466. * Creates a new AnaglyphPostProcess
  102467. * @param name defines postprocess name
  102468. * @param options defines creation options or target ratio scale
  102469. * @param rigCameras defines cameras using this postprocess
  102470. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102471. * @param engine defines hosting engine
  102472. * @param reusable defines if the postprocess will be reused multiple times per frame
  102473. */
  102474. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102475. }
  102476. }
  102477. declare module BABYLON {
  102478. /**
  102479. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102480. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102481. */
  102482. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102483. /**
  102484. * Creates a new AnaglyphArcRotateCamera
  102485. * @param name defines camera name
  102486. * @param alpha defines alpha angle (in radians)
  102487. * @param beta defines beta angle (in radians)
  102488. * @param radius defines radius
  102489. * @param target defines camera target
  102490. * @param interaxialDistance defines distance between each color axis
  102491. * @param scene defines the hosting scene
  102492. */
  102493. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102494. /**
  102495. * Gets camera class name
  102496. * @returns AnaglyphArcRotateCamera
  102497. */
  102498. getClassName(): string;
  102499. }
  102500. }
  102501. declare module BABYLON {
  102502. /**
  102503. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102504. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102505. */
  102506. export class AnaglyphFreeCamera extends FreeCamera {
  102507. /**
  102508. * Creates a new AnaglyphFreeCamera
  102509. * @param name defines camera name
  102510. * @param position defines initial position
  102511. * @param interaxialDistance defines distance between each color axis
  102512. * @param scene defines the hosting scene
  102513. */
  102514. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102515. /**
  102516. * Gets camera class name
  102517. * @returns AnaglyphFreeCamera
  102518. */
  102519. getClassName(): string;
  102520. }
  102521. }
  102522. declare module BABYLON {
  102523. /**
  102524. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102525. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102526. */
  102527. export class AnaglyphGamepadCamera extends GamepadCamera {
  102528. /**
  102529. * Creates a new AnaglyphGamepadCamera
  102530. * @param name defines camera name
  102531. * @param position defines initial position
  102532. * @param interaxialDistance defines distance between each color axis
  102533. * @param scene defines the hosting scene
  102534. */
  102535. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102536. /**
  102537. * Gets camera class name
  102538. * @returns AnaglyphGamepadCamera
  102539. */
  102540. getClassName(): string;
  102541. }
  102542. }
  102543. declare module BABYLON {
  102544. /**
  102545. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102546. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102547. */
  102548. export class AnaglyphUniversalCamera extends UniversalCamera {
  102549. /**
  102550. * Creates a new AnaglyphUniversalCamera
  102551. * @param name defines camera name
  102552. * @param position defines initial position
  102553. * @param interaxialDistance defines distance between each color axis
  102554. * @param scene defines the hosting scene
  102555. */
  102556. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102557. /**
  102558. * Gets camera class name
  102559. * @returns AnaglyphUniversalCamera
  102560. */
  102561. getClassName(): string;
  102562. }
  102563. }
  102564. declare module BABYLON {
  102565. /** @hidden */
  102566. export var stereoscopicInterlacePixelShader: {
  102567. name: string;
  102568. shader: string;
  102569. };
  102570. }
  102571. declare module BABYLON {
  102572. /**
  102573. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102574. */
  102575. export class StereoscopicInterlacePostProcess extends PostProcess {
  102576. private _stepSize;
  102577. private _passedProcess;
  102578. /**
  102579. * Initializes a StereoscopicInterlacePostProcess
  102580. * @param name The name of the effect.
  102581. * @param rigCameras The rig cameras to be appled to the post process
  102582. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102583. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102584. * @param engine The engine which the post process will be applied. (default: current engine)
  102585. * @param reusable If the post process can be reused on the same frame. (default: false)
  102586. */
  102587. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102588. }
  102589. }
  102590. declare module BABYLON {
  102591. /**
  102592. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102593. * @see http://doc.babylonjs.com/features/cameras
  102594. */
  102595. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102596. /**
  102597. * Creates a new StereoscopicArcRotateCamera
  102598. * @param name defines camera name
  102599. * @param alpha defines alpha angle (in radians)
  102600. * @param beta defines beta angle (in radians)
  102601. * @param radius defines radius
  102602. * @param target defines camera target
  102603. * @param interaxialDistance defines distance between each color axis
  102604. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102605. * @param scene defines the hosting scene
  102606. */
  102607. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102608. /**
  102609. * Gets camera class name
  102610. * @returns StereoscopicArcRotateCamera
  102611. */
  102612. getClassName(): string;
  102613. }
  102614. }
  102615. declare module BABYLON {
  102616. /**
  102617. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102618. * @see http://doc.babylonjs.com/features/cameras
  102619. */
  102620. export class StereoscopicFreeCamera extends FreeCamera {
  102621. /**
  102622. * Creates a new StereoscopicFreeCamera
  102623. * @param name defines camera name
  102624. * @param position defines initial position
  102625. * @param interaxialDistance defines distance between each color axis
  102626. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102627. * @param scene defines the hosting scene
  102628. */
  102629. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102630. /**
  102631. * Gets camera class name
  102632. * @returns StereoscopicFreeCamera
  102633. */
  102634. getClassName(): string;
  102635. }
  102636. }
  102637. declare module BABYLON {
  102638. /**
  102639. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102640. * @see http://doc.babylonjs.com/features/cameras
  102641. */
  102642. export class StereoscopicGamepadCamera extends GamepadCamera {
  102643. /**
  102644. * Creates a new StereoscopicGamepadCamera
  102645. * @param name defines camera name
  102646. * @param position defines initial position
  102647. * @param interaxialDistance defines distance between each color axis
  102648. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102649. * @param scene defines the hosting scene
  102650. */
  102651. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102652. /**
  102653. * Gets camera class name
  102654. * @returns StereoscopicGamepadCamera
  102655. */
  102656. getClassName(): string;
  102657. }
  102658. }
  102659. declare module BABYLON {
  102660. /**
  102661. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102662. * @see http://doc.babylonjs.com/features/cameras
  102663. */
  102664. export class StereoscopicUniversalCamera extends UniversalCamera {
  102665. /**
  102666. * Creates a new StereoscopicUniversalCamera
  102667. * @param name defines camera name
  102668. * @param position defines initial position
  102669. * @param interaxialDistance defines distance between each color axis
  102670. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102671. * @param scene defines the hosting scene
  102672. */
  102673. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102674. /**
  102675. * Gets camera class name
  102676. * @returns StereoscopicUniversalCamera
  102677. */
  102678. getClassName(): string;
  102679. }
  102680. }
  102681. declare module BABYLON {
  102682. /**
  102683. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102684. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102685. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102686. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102687. */
  102688. export class VirtualJoysticksCamera extends FreeCamera {
  102689. /**
  102690. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102691. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102692. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102693. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102694. * @param name Define the name of the camera in the scene
  102695. * @param position Define the start position of the camera in the scene
  102696. * @param scene Define the scene the camera belongs to
  102697. */
  102698. constructor(name: string, position: Vector3, scene: Scene);
  102699. /**
  102700. * Gets the current object class name.
  102701. * @return the class name
  102702. */
  102703. getClassName(): string;
  102704. }
  102705. }
  102706. declare module BABYLON {
  102707. /**
  102708. * This represents all the required metrics to create a VR camera.
  102709. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102710. */
  102711. export class VRCameraMetrics {
  102712. /**
  102713. * Define the horizontal resolution off the screen.
  102714. */
  102715. hResolution: number;
  102716. /**
  102717. * Define the vertical resolution off the screen.
  102718. */
  102719. vResolution: number;
  102720. /**
  102721. * Define the horizontal screen size.
  102722. */
  102723. hScreenSize: number;
  102724. /**
  102725. * Define the vertical screen size.
  102726. */
  102727. vScreenSize: number;
  102728. /**
  102729. * Define the vertical screen center position.
  102730. */
  102731. vScreenCenter: number;
  102732. /**
  102733. * Define the distance of the eyes to the screen.
  102734. */
  102735. eyeToScreenDistance: number;
  102736. /**
  102737. * Define the distance between both lenses
  102738. */
  102739. lensSeparationDistance: number;
  102740. /**
  102741. * Define the distance between both viewer's eyes.
  102742. */
  102743. interpupillaryDistance: number;
  102744. /**
  102745. * Define the distortion factor of the VR postprocess.
  102746. * Please, touch with care.
  102747. */
  102748. distortionK: number[];
  102749. /**
  102750. * Define the chromatic aberration correction factors for the VR post process.
  102751. */
  102752. chromaAbCorrection: number[];
  102753. /**
  102754. * Define the scale factor of the post process.
  102755. * The smaller the better but the slower.
  102756. */
  102757. postProcessScaleFactor: number;
  102758. /**
  102759. * Define an offset for the lens center.
  102760. */
  102761. lensCenterOffset: number;
  102762. /**
  102763. * Define if the current vr camera should compensate the distortion of the lense or not.
  102764. */
  102765. compensateDistortion: boolean;
  102766. /**
  102767. * Defines if multiview should be enabled when rendering (Default: false)
  102768. */
  102769. multiviewEnabled: boolean;
  102770. /**
  102771. * Gets the rendering aspect ratio based on the provided resolutions.
  102772. */
  102773. readonly aspectRatio: number;
  102774. /**
  102775. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102776. */
  102777. readonly aspectRatioFov: number;
  102778. /**
  102779. * @hidden
  102780. */
  102781. readonly leftHMatrix: Matrix;
  102782. /**
  102783. * @hidden
  102784. */
  102785. readonly rightHMatrix: Matrix;
  102786. /**
  102787. * @hidden
  102788. */
  102789. readonly leftPreViewMatrix: Matrix;
  102790. /**
  102791. * @hidden
  102792. */
  102793. readonly rightPreViewMatrix: Matrix;
  102794. /**
  102795. * Get the default VRMetrics based on the most generic setup.
  102796. * @returns the default vr metrics
  102797. */
  102798. static GetDefault(): VRCameraMetrics;
  102799. }
  102800. }
  102801. declare module BABYLON {
  102802. /** @hidden */
  102803. export var vrDistortionCorrectionPixelShader: {
  102804. name: string;
  102805. shader: string;
  102806. };
  102807. }
  102808. declare module BABYLON {
  102809. /**
  102810. * VRDistortionCorrectionPostProcess used for mobile VR
  102811. */
  102812. export class VRDistortionCorrectionPostProcess extends PostProcess {
  102813. private _isRightEye;
  102814. private _distortionFactors;
  102815. private _postProcessScaleFactor;
  102816. private _lensCenterOffset;
  102817. private _scaleIn;
  102818. private _scaleFactor;
  102819. private _lensCenter;
  102820. /**
  102821. * Initializes the VRDistortionCorrectionPostProcess
  102822. * @param name The name of the effect.
  102823. * @param camera The camera to apply the render pass to.
  102824. * @param isRightEye If this is for the right eye distortion
  102825. * @param vrMetrics All the required metrics for the VR camera
  102826. */
  102827. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  102828. }
  102829. }
  102830. declare module BABYLON {
  102831. /**
  102832. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  102833. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102834. */
  102835. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  102836. /**
  102837. * Creates a new VRDeviceOrientationArcRotateCamera
  102838. * @param name defines camera name
  102839. * @param alpha defines the camera rotation along the logitudinal axis
  102840. * @param beta defines the camera rotation along the latitudinal axis
  102841. * @param radius defines the camera distance from its target
  102842. * @param target defines the camera target
  102843. * @param scene defines the scene the camera belongs to
  102844. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102845. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102846. */
  102847. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102848. /**
  102849. * Gets camera class name
  102850. * @returns VRDeviceOrientationArcRotateCamera
  102851. */
  102852. getClassName(): string;
  102853. }
  102854. }
  102855. declare module BABYLON {
  102856. /**
  102857. * Camera used to simulate VR rendering (based on FreeCamera)
  102858. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102859. */
  102860. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  102861. /**
  102862. * Creates a new VRDeviceOrientationFreeCamera
  102863. * @param name defines camera name
  102864. * @param position defines the start position of the camera
  102865. * @param scene defines the scene the camera belongs to
  102866. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102867. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102868. */
  102869. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102870. /**
  102871. * Gets camera class name
  102872. * @returns VRDeviceOrientationFreeCamera
  102873. */
  102874. getClassName(): string;
  102875. }
  102876. }
  102877. declare module BABYLON {
  102878. /**
  102879. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  102880. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102881. */
  102882. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  102883. /**
  102884. * Creates a new VRDeviceOrientationGamepadCamera
  102885. * @param name defines camera name
  102886. * @param position defines the start position of the camera
  102887. * @param scene defines the scene the camera belongs to
  102888. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102889. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102890. */
  102891. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102892. /**
  102893. * Gets camera class name
  102894. * @returns VRDeviceOrientationGamepadCamera
  102895. */
  102896. getClassName(): string;
  102897. }
  102898. }
  102899. declare module BABYLON {
  102900. /**
  102901. * Base class of materials working in push mode in babylon JS
  102902. * @hidden
  102903. */
  102904. export class PushMaterial extends Material {
  102905. protected _activeEffect: Effect;
  102906. protected _normalMatrix: Matrix;
  102907. /**
  102908. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102909. * This means that the material can keep using a previous shader while a new one is being compiled.
  102910. * This is mostly used when shader parallel compilation is supported (true by default)
  102911. */
  102912. allowShaderHotSwapping: boolean;
  102913. constructor(name: string, scene: Scene);
  102914. getEffect(): Effect;
  102915. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102916. /**
  102917. * Binds the given world matrix to the active effect
  102918. *
  102919. * @param world the matrix to bind
  102920. */
  102921. bindOnlyWorldMatrix(world: Matrix): void;
  102922. /**
  102923. * Binds the given normal matrix to the active effect
  102924. *
  102925. * @param normalMatrix the matrix to bind
  102926. */
  102927. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102928. bind(world: Matrix, mesh?: Mesh): void;
  102929. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102930. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102931. }
  102932. }
  102933. declare module BABYLON {
  102934. /**
  102935. * This groups all the flags used to control the materials channel.
  102936. */
  102937. export class MaterialFlags {
  102938. private static _DiffuseTextureEnabled;
  102939. /**
  102940. * Are diffuse textures enabled in the application.
  102941. */
  102942. static DiffuseTextureEnabled: boolean;
  102943. private static _AmbientTextureEnabled;
  102944. /**
  102945. * Are ambient textures enabled in the application.
  102946. */
  102947. static AmbientTextureEnabled: boolean;
  102948. private static _OpacityTextureEnabled;
  102949. /**
  102950. * Are opacity textures enabled in the application.
  102951. */
  102952. static OpacityTextureEnabled: boolean;
  102953. private static _ReflectionTextureEnabled;
  102954. /**
  102955. * Are reflection textures enabled in the application.
  102956. */
  102957. static ReflectionTextureEnabled: boolean;
  102958. private static _EmissiveTextureEnabled;
  102959. /**
  102960. * Are emissive textures enabled in the application.
  102961. */
  102962. static EmissiveTextureEnabled: boolean;
  102963. private static _SpecularTextureEnabled;
  102964. /**
  102965. * Are specular textures enabled in the application.
  102966. */
  102967. static SpecularTextureEnabled: boolean;
  102968. private static _BumpTextureEnabled;
  102969. /**
  102970. * Are bump textures enabled in the application.
  102971. */
  102972. static BumpTextureEnabled: boolean;
  102973. private static _LightmapTextureEnabled;
  102974. /**
  102975. * Are lightmap textures enabled in the application.
  102976. */
  102977. static LightmapTextureEnabled: boolean;
  102978. private static _RefractionTextureEnabled;
  102979. /**
  102980. * Are refraction textures enabled in the application.
  102981. */
  102982. static RefractionTextureEnabled: boolean;
  102983. private static _ColorGradingTextureEnabled;
  102984. /**
  102985. * Are color grading textures enabled in the application.
  102986. */
  102987. static ColorGradingTextureEnabled: boolean;
  102988. private static _FresnelEnabled;
  102989. /**
  102990. * Are fresnels enabled in the application.
  102991. */
  102992. static FresnelEnabled: boolean;
  102993. private static _ClearCoatTextureEnabled;
  102994. /**
  102995. * Are clear coat textures enabled in the application.
  102996. */
  102997. static ClearCoatTextureEnabled: boolean;
  102998. private static _ClearCoatBumpTextureEnabled;
  102999. /**
  103000. * Are clear coat bump textures enabled in the application.
  103001. */
  103002. static ClearCoatBumpTextureEnabled: boolean;
  103003. private static _ClearCoatTintTextureEnabled;
  103004. /**
  103005. * Are clear coat tint textures enabled in the application.
  103006. */
  103007. static ClearCoatTintTextureEnabled: boolean;
  103008. private static _SheenTextureEnabled;
  103009. /**
  103010. * Are sheen textures enabled in the application.
  103011. */
  103012. static SheenTextureEnabled: boolean;
  103013. private static _AnisotropicTextureEnabled;
  103014. /**
  103015. * Are anisotropic textures enabled in the application.
  103016. */
  103017. static AnisotropicTextureEnabled: boolean;
  103018. private static _ThicknessTextureEnabled;
  103019. /**
  103020. * Are thickness textures enabled in the application.
  103021. */
  103022. static ThicknessTextureEnabled: boolean;
  103023. }
  103024. }
  103025. declare module BABYLON {
  103026. /** @hidden */
  103027. export var defaultFragmentDeclaration: {
  103028. name: string;
  103029. shader: string;
  103030. };
  103031. }
  103032. declare module BABYLON {
  103033. /** @hidden */
  103034. export var defaultUboDeclaration: {
  103035. name: string;
  103036. shader: string;
  103037. };
  103038. }
  103039. declare module BABYLON {
  103040. /** @hidden */
  103041. export var lightFragmentDeclaration: {
  103042. name: string;
  103043. shader: string;
  103044. };
  103045. }
  103046. declare module BABYLON {
  103047. /** @hidden */
  103048. export var lightUboDeclaration: {
  103049. name: string;
  103050. shader: string;
  103051. };
  103052. }
  103053. declare module BABYLON {
  103054. /** @hidden */
  103055. export var lightsFragmentFunctions: {
  103056. name: string;
  103057. shader: string;
  103058. };
  103059. }
  103060. declare module BABYLON {
  103061. /** @hidden */
  103062. export var shadowsFragmentFunctions: {
  103063. name: string;
  103064. shader: string;
  103065. };
  103066. }
  103067. declare module BABYLON {
  103068. /** @hidden */
  103069. export var fresnelFunction: {
  103070. name: string;
  103071. shader: string;
  103072. };
  103073. }
  103074. declare module BABYLON {
  103075. /** @hidden */
  103076. export var reflectionFunction: {
  103077. name: string;
  103078. shader: string;
  103079. };
  103080. }
  103081. declare module BABYLON {
  103082. /** @hidden */
  103083. export var bumpFragmentFunctions: {
  103084. name: string;
  103085. shader: string;
  103086. };
  103087. }
  103088. declare module BABYLON {
  103089. /** @hidden */
  103090. export var logDepthDeclaration: {
  103091. name: string;
  103092. shader: string;
  103093. };
  103094. }
  103095. declare module BABYLON {
  103096. /** @hidden */
  103097. export var bumpFragment: {
  103098. name: string;
  103099. shader: string;
  103100. };
  103101. }
  103102. declare module BABYLON {
  103103. /** @hidden */
  103104. export var depthPrePass: {
  103105. name: string;
  103106. shader: string;
  103107. };
  103108. }
  103109. declare module BABYLON {
  103110. /** @hidden */
  103111. export var lightFragment: {
  103112. name: string;
  103113. shader: string;
  103114. };
  103115. }
  103116. declare module BABYLON {
  103117. /** @hidden */
  103118. export var logDepthFragment: {
  103119. name: string;
  103120. shader: string;
  103121. };
  103122. }
  103123. declare module BABYLON {
  103124. /** @hidden */
  103125. export var defaultPixelShader: {
  103126. name: string;
  103127. shader: string;
  103128. };
  103129. }
  103130. declare module BABYLON {
  103131. /** @hidden */
  103132. export var defaultVertexDeclaration: {
  103133. name: string;
  103134. shader: string;
  103135. };
  103136. }
  103137. declare module BABYLON {
  103138. /** @hidden */
  103139. export var bumpVertexDeclaration: {
  103140. name: string;
  103141. shader: string;
  103142. };
  103143. }
  103144. declare module BABYLON {
  103145. /** @hidden */
  103146. export var bumpVertex: {
  103147. name: string;
  103148. shader: string;
  103149. };
  103150. }
  103151. declare module BABYLON {
  103152. /** @hidden */
  103153. export var fogVertex: {
  103154. name: string;
  103155. shader: string;
  103156. };
  103157. }
  103158. declare module BABYLON {
  103159. /** @hidden */
  103160. export var shadowsVertex: {
  103161. name: string;
  103162. shader: string;
  103163. };
  103164. }
  103165. declare module BABYLON {
  103166. /** @hidden */
  103167. export var pointCloudVertex: {
  103168. name: string;
  103169. shader: string;
  103170. };
  103171. }
  103172. declare module BABYLON {
  103173. /** @hidden */
  103174. export var logDepthVertex: {
  103175. name: string;
  103176. shader: string;
  103177. };
  103178. }
  103179. declare module BABYLON {
  103180. /** @hidden */
  103181. export var defaultVertexShader: {
  103182. name: string;
  103183. shader: string;
  103184. };
  103185. }
  103186. declare module BABYLON {
  103187. /** @hidden */
  103188. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103189. MAINUV1: boolean;
  103190. MAINUV2: boolean;
  103191. DIFFUSE: boolean;
  103192. DIFFUSEDIRECTUV: number;
  103193. AMBIENT: boolean;
  103194. AMBIENTDIRECTUV: number;
  103195. OPACITY: boolean;
  103196. OPACITYDIRECTUV: number;
  103197. OPACITYRGB: boolean;
  103198. REFLECTION: boolean;
  103199. EMISSIVE: boolean;
  103200. EMISSIVEDIRECTUV: number;
  103201. SPECULAR: boolean;
  103202. SPECULARDIRECTUV: number;
  103203. BUMP: boolean;
  103204. BUMPDIRECTUV: number;
  103205. PARALLAX: boolean;
  103206. PARALLAXOCCLUSION: boolean;
  103207. SPECULAROVERALPHA: boolean;
  103208. CLIPPLANE: boolean;
  103209. CLIPPLANE2: boolean;
  103210. CLIPPLANE3: boolean;
  103211. CLIPPLANE4: boolean;
  103212. ALPHATEST: boolean;
  103213. DEPTHPREPASS: boolean;
  103214. ALPHAFROMDIFFUSE: boolean;
  103215. POINTSIZE: boolean;
  103216. FOG: boolean;
  103217. SPECULARTERM: boolean;
  103218. DIFFUSEFRESNEL: boolean;
  103219. OPACITYFRESNEL: boolean;
  103220. REFLECTIONFRESNEL: boolean;
  103221. REFRACTIONFRESNEL: boolean;
  103222. EMISSIVEFRESNEL: boolean;
  103223. FRESNEL: boolean;
  103224. NORMAL: boolean;
  103225. UV1: boolean;
  103226. UV2: boolean;
  103227. VERTEXCOLOR: boolean;
  103228. VERTEXALPHA: boolean;
  103229. NUM_BONE_INFLUENCERS: number;
  103230. BonesPerMesh: number;
  103231. BONETEXTURE: boolean;
  103232. INSTANCES: boolean;
  103233. GLOSSINESS: boolean;
  103234. ROUGHNESS: boolean;
  103235. EMISSIVEASILLUMINATION: boolean;
  103236. LINKEMISSIVEWITHDIFFUSE: boolean;
  103237. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103238. LIGHTMAP: boolean;
  103239. LIGHTMAPDIRECTUV: number;
  103240. OBJECTSPACE_NORMALMAP: boolean;
  103241. USELIGHTMAPASSHADOWMAP: boolean;
  103242. REFLECTIONMAP_3D: boolean;
  103243. REFLECTIONMAP_SPHERICAL: boolean;
  103244. REFLECTIONMAP_PLANAR: boolean;
  103245. REFLECTIONMAP_CUBIC: boolean;
  103246. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103247. REFLECTIONMAP_PROJECTION: boolean;
  103248. REFLECTIONMAP_SKYBOX: boolean;
  103249. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103250. REFLECTIONMAP_EXPLICIT: boolean;
  103251. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103252. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103253. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103254. INVERTCUBICMAP: boolean;
  103255. LOGARITHMICDEPTH: boolean;
  103256. REFRACTION: boolean;
  103257. REFRACTIONMAP_3D: boolean;
  103258. REFLECTIONOVERALPHA: boolean;
  103259. TWOSIDEDLIGHTING: boolean;
  103260. SHADOWFLOAT: boolean;
  103261. MORPHTARGETS: boolean;
  103262. MORPHTARGETS_NORMAL: boolean;
  103263. MORPHTARGETS_TANGENT: boolean;
  103264. MORPHTARGETS_UV: boolean;
  103265. NUM_MORPH_INFLUENCERS: number;
  103266. NONUNIFORMSCALING: boolean;
  103267. PREMULTIPLYALPHA: boolean;
  103268. IMAGEPROCESSING: boolean;
  103269. VIGNETTE: boolean;
  103270. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103271. VIGNETTEBLENDMODEOPAQUE: boolean;
  103272. TONEMAPPING: boolean;
  103273. TONEMAPPING_ACES: boolean;
  103274. CONTRAST: boolean;
  103275. COLORCURVES: boolean;
  103276. COLORGRADING: boolean;
  103277. COLORGRADING3D: boolean;
  103278. SAMPLER3DGREENDEPTH: boolean;
  103279. SAMPLER3DBGRMAP: boolean;
  103280. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103281. MULTIVIEW: boolean;
  103282. /**
  103283. * If the reflection texture on this material is in linear color space
  103284. * @hidden
  103285. */
  103286. IS_REFLECTION_LINEAR: boolean;
  103287. /**
  103288. * If the refraction texture on this material is in linear color space
  103289. * @hidden
  103290. */
  103291. IS_REFRACTION_LINEAR: boolean;
  103292. EXPOSURE: boolean;
  103293. constructor();
  103294. setReflectionMode(modeToEnable: string): void;
  103295. }
  103296. /**
  103297. * This is the default material used in Babylon. It is the best trade off between quality
  103298. * and performances.
  103299. * @see http://doc.babylonjs.com/babylon101/materials
  103300. */
  103301. export class StandardMaterial extends PushMaterial {
  103302. private _diffuseTexture;
  103303. /**
  103304. * The basic texture of the material as viewed under a light.
  103305. */
  103306. diffuseTexture: Nullable<BaseTexture>;
  103307. private _ambientTexture;
  103308. /**
  103309. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103310. */
  103311. ambientTexture: Nullable<BaseTexture>;
  103312. private _opacityTexture;
  103313. /**
  103314. * Define the transparency of the material from a texture.
  103315. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103316. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103317. */
  103318. opacityTexture: Nullable<BaseTexture>;
  103319. private _reflectionTexture;
  103320. /**
  103321. * Define the texture used to display the reflection.
  103322. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103323. */
  103324. reflectionTexture: Nullable<BaseTexture>;
  103325. private _emissiveTexture;
  103326. /**
  103327. * Define texture of the material as if self lit.
  103328. * This will be mixed in the final result even in the absence of light.
  103329. */
  103330. emissiveTexture: Nullable<BaseTexture>;
  103331. private _specularTexture;
  103332. /**
  103333. * Define how the color and intensity of the highlight given by the light in the material.
  103334. */
  103335. specularTexture: Nullable<BaseTexture>;
  103336. private _bumpTexture;
  103337. /**
  103338. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103339. * 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.
  103340. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103341. */
  103342. bumpTexture: Nullable<BaseTexture>;
  103343. private _lightmapTexture;
  103344. /**
  103345. * Complex lighting can be computationally expensive to compute at runtime.
  103346. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103347. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103348. */
  103349. lightmapTexture: Nullable<BaseTexture>;
  103350. private _refractionTexture;
  103351. /**
  103352. * Define the texture used to display the refraction.
  103353. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103354. */
  103355. refractionTexture: Nullable<BaseTexture>;
  103356. /**
  103357. * The color of the material lit by the environmental background lighting.
  103358. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103359. */
  103360. ambientColor: Color3;
  103361. /**
  103362. * The basic color of the material as viewed under a light.
  103363. */
  103364. diffuseColor: Color3;
  103365. /**
  103366. * Define how the color and intensity of the highlight given by the light in the material.
  103367. */
  103368. specularColor: Color3;
  103369. /**
  103370. * Define the color of the material as if self lit.
  103371. * This will be mixed in the final result even in the absence of light.
  103372. */
  103373. emissiveColor: Color3;
  103374. /**
  103375. * Defines how sharp are the highlights in the material.
  103376. * The bigger the value the sharper giving a more glossy feeling to the result.
  103377. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103378. */
  103379. specularPower: number;
  103380. private _useAlphaFromDiffuseTexture;
  103381. /**
  103382. * Does the transparency come from the diffuse texture alpha channel.
  103383. */
  103384. useAlphaFromDiffuseTexture: boolean;
  103385. private _useEmissiveAsIllumination;
  103386. /**
  103387. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103388. */
  103389. useEmissiveAsIllumination: boolean;
  103390. private _linkEmissiveWithDiffuse;
  103391. /**
  103392. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103393. * the emissive level when the final color is close to one.
  103394. */
  103395. linkEmissiveWithDiffuse: boolean;
  103396. private _useSpecularOverAlpha;
  103397. /**
  103398. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103399. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103400. */
  103401. useSpecularOverAlpha: boolean;
  103402. private _useReflectionOverAlpha;
  103403. /**
  103404. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103405. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103406. */
  103407. useReflectionOverAlpha: boolean;
  103408. private _disableLighting;
  103409. /**
  103410. * Does lights from the scene impacts this material.
  103411. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103412. */
  103413. disableLighting: boolean;
  103414. private _useObjectSpaceNormalMap;
  103415. /**
  103416. * Allows using an object space normal map (instead of tangent space).
  103417. */
  103418. useObjectSpaceNormalMap: boolean;
  103419. private _useParallax;
  103420. /**
  103421. * Is parallax enabled or not.
  103422. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103423. */
  103424. useParallax: boolean;
  103425. private _useParallaxOcclusion;
  103426. /**
  103427. * Is parallax occlusion enabled or not.
  103428. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103429. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103430. */
  103431. useParallaxOcclusion: boolean;
  103432. /**
  103433. * 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.
  103434. */
  103435. parallaxScaleBias: number;
  103436. private _roughness;
  103437. /**
  103438. * Helps to define how blurry the reflections should appears in the material.
  103439. */
  103440. roughness: number;
  103441. /**
  103442. * In case of refraction, define the value of the index of refraction.
  103443. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103444. */
  103445. indexOfRefraction: number;
  103446. /**
  103447. * Invert the refraction texture alongside the y axis.
  103448. * It can be useful with procedural textures or probe for instance.
  103449. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103450. */
  103451. invertRefractionY: boolean;
  103452. /**
  103453. * Defines the alpha limits in alpha test mode.
  103454. */
  103455. alphaCutOff: number;
  103456. private _useLightmapAsShadowmap;
  103457. /**
  103458. * In case of light mapping, define whether the map contains light or shadow informations.
  103459. */
  103460. useLightmapAsShadowmap: boolean;
  103461. private _diffuseFresnelParameters;
  103462. /**
  103463. * Define the diffuse fresnel parameters of the material.
  103464. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103465. */
  103466. diffuseFresnelParameters: FresnelParameters;
  103467. private _opacityFresnelParameters;
  103468. /**
  103469. * Define the opacity fresnel parameters of the material.
  103470. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103471. */
  103472. opacityFresnelParameters: FresnelParameters;
  103473. private _reflectionFresnelParameters;
  103474. /**
  103475. * Define the reflection fresnel parameters of the material.
  103476. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103477. */
  103478. reflectionFresnelParameters: FresnelParameters;
  103479. private _refractionFresnelParameters;
  103480. /**
  103481. * Define the refraction fresnel parameters of the material.
  103482. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103483. */
  103484. refractionFresnelParameters: FresnelParameters;
  103485. private _emissiveFresnelParameters;
  103486. /**
  103487. * Define the emissive fresnel parameters of the material.
  103488. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103489. */
  103490. emissiveFresnelParameters: FresnelParameters;
  103491. private _useReflectionFresnelFromSpecular;
  103492. /**
  103493. * If true automatically deducts the fresnels values from the material specularity.
  103494. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103495. */
  103496. useReflectionFresnelFromSpecular: boolean;
  103497. private _useGlossinessFromSpecularMapAlpha;
  103498. /**
  103499. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103500. */
  103501. useGlossinessFromSpecularMapAlpha: boolean;
  103502. private _maxSimultaneousLights;
  103503. /**
  103504. * Defines the maximum number of lights that can be used in the material
  103505. */
  103506. maxSimultaneousLights: number;
  103507. private _invertNormalMapX;
  103508. /**
  103509. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103510. */
  103511. invertNormalMapX: boolean;
  103512. private _invertNormalMapY;
  103513. /**
  103514. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103515. */
  103516. invertNormalMapY: boolean;
  103517. private _twoSidedLighting;
  103518. /**
  103519. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103520. */
  103521. twoSidedLighting: boolean;
  103522. /**
  103523. * Default configuration related to image processing available in the standard Material.
  103524. */
  103525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103526. /**
  103527. * Gets the image processing configuration used either in this material.
  103528. */
  103529. /**
  103530. * Sets the Default image processing configuration used either in the this material.
  103531. *
  103532. * If sets to null, the scene one is in use.
  103533. */
  103534. imageProcessingConfiguration: ImageProcessingConfiguration;
  103535. /**
  103536. * Keep track of the image processing observer to allow dispose and replace.
  103537. */
  103538. private _imageProcessingObserver;
  103539. /**
  103540. * Attaches a new image processing configuration to the Standard Material.
  103541. * @param configuration
  103542. */
  103543. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103544. /**
  103545. * Gets wether the color curves effect is enabled.
  103546. */
  103547. /**
  103548. * Sets wether the color curves effect is enabled.
  103549. */
  103550. cameraColorCurvesEnabled: boolean;
  103551. /**
  103552. * Gets wether the color grading effect is enabled.
  103553. */
  103554. /**
  103555. * Gets wether the color grading effect is enabled.
  103556. */
  103557. cameraColorGradingEnabled: boolean;
  103558. /**
  103559. * Gets wether tonemapping is enabled or not.
  103560. */
  103561. /**
  103562. * Sets wether tonemapping is enabled or not
  103563. */
  103564. cameraToneMappingEnabled: boolean;
  103565. /**
  103566. * The camera exposure used on this material.
  103567. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103568. * This corresponds to a photographic exposure.
  103569. */
  103570. /**
  103571. * The camera exposure used on this material.
  103572. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103573. * This corresponds to a photographic exposure.
  103574. */
  103575. cameraExposure: number;
  103576. /**
  103577. * Gets The camera contrast used on this material.
  103578. */
  103579. /**
  103580. * Sets The camera contrast used on this material.
  103581. */
  103582. cameraContrast: number;
  103583. /**
  103584. * Gets the Color Grading 2D Lookup Texture.
  103585. */
  103586. /**
  103587. * Sets the Color Grading 2D Lookup Texture.
  103588. */
  103589. cameraColorGradingTexture: Nullable<BaseTexture>;
  103590. /**
  103591. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103592. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103593. * 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;
  103594. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103595. */
  103596. /**
  103597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103599. * 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;
  103600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103601. */
  103602. cameraColorCurves: Nullable<ColorCurves>;
  103603. /**
  103604. * Custom callback helping to override the default shader used in the material.
  103605. */
  103606. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103607. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103608. protected _worldViewProjectionMatrix: Matrix;
  103609. protected _globalAmbientColor: Color3;
  103610. protected _useLogarithmicDepth: boolean;
  103611. /**
  103612. * Instantiates a new standard material.
  103613. * This is the default material used in Babylon. It is the best trade off between quality
  103614. * and performances.
  103615. * @see http://doc.babylonjs.com/babylon101/materials
  103616. * @param name Define the name of the material in the scene
  103617. * @param scene Define the scene the material belong to
  103618. */
  103619. constructor(name: string, scene: Scene);
  103620. /**
  103621. * Gets a boolean indicating that current material needs to register RTT
  103622. */
  103623. readonly hasRenderTargetTextures: boolean;
  103624. /**
  103625. * Gets the current class name of the material e.g. "StandardMaterial"
  103626. * Mainly use in serialization.
  103627. * @returns the class name
  103628. */
  103629. getClassName(): string;
  103630. /**
  103631. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103632. * You can try switching to logarithmic depth.
  103633. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103634. */
  103635. useLogarithmicDepth: boolean;
  103636. /**
  103637. * Specifies if the material will require alpha blending
  103638. * @returns a boolean specifying if alpha blending is needed
  103639. */
  103640. needAlphaBlending(): boolean;
  103641. /**
  103642. * Specifies if this material should be rendered in alpha test mode
  103643. * @returns a boolean specifying if an alpha test is needed.
  103644. */
  103645. needAlphaTesting(): boolean;
  103646. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103647. /**
  103648. * Get the texture used for alpha test purpose.
  103649. * @returns the diffuse texture in case of the standard material.
  103650. */
  103651. getAlphaTestTexture(): Nullable<BaseTexture>;
  103652. /**
  103653. * Get if the submesh is ready to be used and all its information available.
  103654. * Child classes can use it to update shaders
  103655. * @param mesh defines the mesh to check
  103656. * @param subMesh defines which submesh to check
  103657. * @param useInstances specifies that instances should be used
  103658. * @returns a boolean indicating that the submesh is ready or not
  103659. */
  103660. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103661. /**
  103662. * Builds the material UBO layouts.
  103663. * Used internally during the effect preparation.
  103664. */
  103665. buildUniformLayout(): void;
  103666. /**
  103667. * Unbinds the material from the mesh
  103668. */
  103669. unbind(): void;
  103670. /**
  103671. * Binds the submesh to this material by preparing the effect and shader to draw
  103672. * @param world defines the world transformation matrix
  103673. * @param mesh defines the mesh containing the submesh
  103674. * @param subMesh defines the submesh to bind the material to
  103675. */
  103676. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103677. /**
  103678. * Get the list of animatables in the material.
  103679. * @returns the list of animatables object used in the material
  103680. */
  103681. getAnimatables(): IAnimatable[];
  103682. /**
  103683. * Gets the active textures from the material
  103684. * @returns an array of textures
  103685. */
  103686. getActiveTextures(): BaseTexture[];
  103687. /**
  103688. * Specifies if the material uses a texture
  103689. * @param texture defines the texture to check against the material
  103690. * @returns a boolean specifying if the material uses the texture
  103691. */
  103692. hasTexture(texture: BaseTexture): boolean;
  103693. /**
  103694. * Disposes the material
  103695. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103696. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103697. */
  103698. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103699. /**
  103700. * Makes a duplicate of the material, and gives it a new name
  103701. * @param name defines the new name for the duplicated material
  103702. * @returns the cloned material
  103703. */
  103704. clone(name: string): StandardMaterial;
  103705. /**
  103706. * Serializes this material in a JSON representation
  103707. * @returns the serialized material object
  103708. */
  103709. serialize(): any;
  103710. /**
  103711. * Creates a standard material from parsed material data
  103712. * @param source defines the JSON representation of the material
  103713. * @param scene defines the hosting scene
  103714. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103715. * @returns a new standard material
  103716. */
  103717. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103718. /**
  103719. * Are diffuse textures enabled in the application.
  103720. */
  103721. static DiffuseTextureEnabled: boolean;
  103722. /**
  103723. * Are ambient textures enabled in the application.
  103724. */
  103725. static AmbientTextureEnabled: boolean;
  103726. /**
  103727. * Are opacity textures enabled in the application.
  103728. */
  103729. static OpacityTextureEnabled: boolean;
  103730. /**
  103731. * Are reflection textures enabled in the application.
  103732. */
  103733. static ReflectionTextureEnabled: boolean;
  103734. /**
  103735. * Are emissive textures enabled in the application.
  103736. */
  103737. static EmissiveTextureEnabled: boolean;
  103738. /**
  103739. * Are specular textures enabled in the application.
  103740. */
  103741. static SpecularTextureEnabled: boolean;
  103742. /**
  103743. * Are bump textures enabled in the application.
  103744. */
  103745. static BumpTextureEnabled: boolean;
  103746. /**
  103747. * Are lightmap textures enabled in the application.
  103748. */
  103749. static LightmapTextureEnabled: boolean;
  103750. /**
  103751. * Are refraction textures enabled in the application.
  103752. */
  103753. static RefractionTextureEnabled: boolean;
  103754. /**
  103755. * Are color grading textures enabled in the application.
  103756. */
  103757. static ColorGradingTextureEnabled: boolean;
  103758. /**
  103759. * Are fresnels enabled in the application.
  103760. */
  103761. static FresnelEnabled: boolean;
  103762. }
  103763. }
  103764. declare module BABYLON {
  103765. /**
  103766. * A class extending Texture allowing drawing on a texture
  103767. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103768. */
  103769. export class DynamicTexture extends Texture {
  103770. private _generateMipMaps;
  103771. private _canvas;
  103772. private _context;
  103773. private _engine;
  103774. /**
  103775. * Creates a DynamicTexture
  103776. * @param name defines the name of the texture
  103777. * @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
  103778. * @param scene defines the scene where you want the texture
  103779. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103780. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103781. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103782. */
  103783. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103784. /**
  103785. * Get the current class name of the texture useful for serialization or dynamic coding.
  103786. * @returns "DynamicTexture"
  103787. */
  103788. getClassName(): string;
  103789. /**
  103790. * Gets the current state of canRescale
  103791. */
  103792. readonly canRescale: boolean;
  103793. private _recreate;
  103794. /**
  103795. * Scales the texture
  103796. * @param ratio the scale factor to apply to both width and height
  103797. */
  103798. scale(ratio: number): void;
  103799. /**
  103800. * Resizes the texture
  103801. * @param width the new width
  103802. * @param height the new height
  103803. */
  103804. scaleTo(width: number, height: number): void;
  103805. /**
  103806. * Gets the context of the canvas used by the texture
  103807. * @returns the canvas context of the dynamic texture
  103808. */
  103809. getContext(): CanvasRenderingContext2D;
  103810. /**
  103811. * Clears the texture
  103812. */
  103813. clear(): void;
  103814. /**
  103815. * Updates the texture
  103816. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103817. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  103818. */
  103819. update(invertY?: boolean, premulAlpha?: boolean): void;
  103820. /**
  103821. * Draws text onto the texture
  103822. * @param text defines the text to be drawn
  103823. * @param x defines the placement of the text from the left
  103824. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  103825. * @param font defines the font to be used with font-style, font-size, font-name
  103826. * @param color defines the color used for the text
  103827. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  103828. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103829. * @param update defines whether texture is immediately update (default is true)
  103830. */
  103831. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  103832. /**
  103833. * Clones the texture
  103834. * @returns the clone of the texture.
  103835. */
  103836. clone(): DynamicTexture;
  103837. /**
  103838. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  103839. * @returns a serialized dynamic texture object
  103840. */
  103841. serialize(): any;
  103842. /** @hidden */
  103843. _rebuild(): void;
  103844. }
  103845. }
  103846. declare module BABYLON {
  103847. /** @hidden */
  103848. export var imageProcessingPixelShader: {
  103849. name: string;
  103850. shader: string;
  103851. };
  103852. }
  103853. declare module BABYLON {
  103854. /**
  103855. * ImageProcessingPostProcess
  103856. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103857. */
  103858. export class ImageProcessingPostProcess extends PostProcess {
  103859. /**
  103860. * Default configuration related to image processing available in the PBR Material.
  103861. */
  103862. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103863. /**
  103864. * Gets the image processing configuration used either in this material.
  103865. */
  103866. /**
  103867. * Sets the Default image processing configuration used either in the this material.
  103868. *
  103869. * If sets to null, the scene one is in use.
  103870. */
  103871. imageProcessingConfiguration: ImageProcessingConfiguration;
  103872. /**
  103873. * Keep track of the image processing observer to allow dispose and replace.
  103874. */
  103875. private _imageProcessingObserver;
  103876. /**
  103877. * Attaches a new image processing configuration to the PBR Material.
  103878. * @param configuration
  103879. */
  103880. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103881. /**
  103882. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103883. */
  103884. /**
  103885. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103886. */
  103887. colorCurves: Nullable<ColorCurves>;
  103888. /**
  103889. * Gets wether the color curves effect is enabled.
  103890. */
  103891. /**
  103892. * Sets wether the color curves effect is enabled.
  103893. */
  103894. colorCurvesEnabled: boolean;
  103895. /**
  103896. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103897. */
  103898. /**
  103899. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103900. */
  103901. colorGradingTexture: Nullable<BaseTexture>;
  103902. /**
  103903. * Gets wether the color grading effect is enabled.
  103904. */
  103905. /**
  103906. * Gets wether the color grading effect is enabled.
  103907. */
  103908. colorGradingEnabled: boolean;
  103909. /**
  103910. * Gets exposure used in the effect.
  103911. */
  103912. /**
  103913. * Sets exposure used in the effect.
  103914. */
  103915. exposure: number;
  103916. /**
  103917. * Gets wether tonemapping is enabled or not.
  103918. */
  103919. /**
  103920. * Sets wether tonemapping is enabled or not
  103921. */
  103922. toneMappingEnabled: boolean;
  103923. /**
  103924. * Gets the type of tone mapping effect.
  103925. */
  103926. /**
  103927. * Sets the type of tone mapping effect.
  103928. */
  103929. toneMappingType: number;
  103930. /**
  103931. * Gets contrast used in the effect.
  103932. */
  103933. /**
  103934. * Sets contrast used in the effect.
  103935. */
  103936. contrast: number;
  103937. /**
  103938. * Gets Vignette stretch size.
  103939. */
  103940. /**
  103941. * Sets Vignette stretch size.
  103942. */
  103943. vignetteStretch: number;
  103944. /**
  103945. * Gets Vignette centre X Offset.
  103946. */
  103947. /**
  103948. * Sets Vignette centre X Offset.
  103949. */
  103950. vignetteCentreX: number;
  103951. /**
  103952. * Gets Vignette centre Y Offset.
  103953. */
  103954. /**
  103955. * Sets Vignette centre Y Offset.
  103956. */
  103957. vignetteCentreY: number;
  103958. /**
  103959. * Gets Vignette weight or intensity of the vignette effect.
  103960. */
  103961. /**
  103962. * Sets Vignette weight or intensity of the vignette effect.
  103963. */
  103964. vignetteWeight: number;
  103965. /**
  103966. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103967. * if vignetteEnabled is set to true.
  103968. */
  103969. /**
  103970. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103971. * if vignetteEnabled is set to true.
  103972. */
  103973. vignetteColor: Color4;
  103974. /**
  103975. * Gets Camera field of view used by the Vignette effect.
  103976. */
  103977. /**
  103978. * Sets Camera field of view used by the Vignette effect.
  103979. */
  103980. vignetteCameraFov: number;
  103981. /**
  103982. * Gets the vignette blend mode allowing different kind of effect.
  103983. */
  103984. /**
  103985. * Sets the vignette blend mode allowing different kind of effect.
  103986. */
  103987. vignetteBlendMode: number;
  103988. /**
  103989. * Gets wether the vignette effect is enabled.
  103990. */
  103991. /**
  103992. * Sets wether the vignette effect is enabled.
  103993. */
  103994. vignetteEnabled: boolean;
  103995. private _fromLinearSpace;
  103996. /**
  103997. * Gets wether the input of the processing is in Gamma or Linear Space.
  103998. */
  103999. /**
  104000. * Sets wether the input of the processing is in Gamma or Linear Space.
  104001. */
  104002. fromLinearSpace: boolean;
  104003. /**
  104004. * Defines cache preventing GC.
  104005. */
  104006. private _defines;
  104007. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104008. /**
  104009. * "ImageProcessingPostProcess"
  104010. * @returns "ImageProcessingPostProcess"
  104011. */
  104012. getClassName(): string;
  104013. protected _updateParameters(): void;
  104014. dispose(camera?: Camera): void;
  104015. }
  104016. }
  104017. declare module BABYLON {
  104018. /**
  104019. * Class containing static functions to help procedurally build meshes
  104020. */
  104021. export class GroundBuilder {
  104022. /**
  104023. * Creates a ground mesh
  104024. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  104025. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  104026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104027. * @param name defines the name of the mesh
  104028. * @param options defines the options used to create the mesh
  104029. * @param scene defines the hosting scene
  104030. * @returns the ground mesh
  104031. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104032. */
  104033. static CreateGround(name: string, options: {
  104034. width?: number;
  104035. height?: number;
  104036. subdivisions?: number;
  104037. subdivisionsX?: number;
  104038. subdivisionsY?: number;
  104039. updatable?: boolean;
  104040. }, scene: any): Mesh;
  104041. /**
  104042. * Creates a tiled ground mesh
  104043. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104044. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104045. * * 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
  104046. * * 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
  104047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104048. * @param name defines the name of the mesh
  104049. * @param options defines the options used to create the mesh
  104050. * @param scene defines the hosting scene
  104051. * @returns the tiled ground mesh
  104052. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104053. */
  104054. static CreateTiledGround(name: string, options: {
  104055. xmin: number;
  104056. zmin: number;
  104057. xmax: number;
  104058. zmax: number;
  104059. subdivisions?: {
  104060. w: number;
  104061. h: number;
  104062. };
  104063. precision?: {
  104064. w: number;
  104065. h: number;
  104066. };
  104067. updatable?: boolean;
  104068. }, scene?: Nullable<Scene>): Mesh;
  104069. /**
  104070. * Creates a ground mesh from a height map
  104071. * * The parameter `url` sets the URL of the height map image resource.
  104072. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104073. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104074. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104075. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104076. * * 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.
  104077. * * 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).
  104078. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104080. * @param name defines the name of the mesh
  104081. * @param url defines the url to the height map
  104082. * @param options defines the options used to create the mesh
  104083. * @param scene defines the hosting scene
  104084. * @returns the ground mesh
  104085. * @see https://doc.babylonjs.com/babylon101/height_map
  104086. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104087. */
  104088. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104089. width?: number;
  104090. height?: number;
  104091. subdivisions?: number;
  104092. minHeight?: number;
  104093. maxHeight?: number;
  104094. colorFilter?: Color3;
  104095. alphaFilter?: number;
  104096. updatable?: boolean;
  104097. onReady?: (mesh: GroundMesh) => void;
  104098. }, scene?: Nullable<Scene>): GroundMesh;
  104099. }
  104100. }
  104101. declare module BABYLON {
  104102. /**
  104103. * Class containing static functions to help procedurally build meshes
  104104. */
  104105. export class TorusBuilder {
  104106. /**
  104107. * Creates a torus mesh
  104108. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104109. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104110. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104114. * @param name defines the name of the mesh
  104115. * @param options defines the options used to create the mesh
  104116. * @param scene defines the hosting scene
  104117. * @returns the torus mesh
  104118. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104119. */
  104120. static CreateTorus(name: string, options: {
  104121. diameter?: number;
  104122. thickness?: number;
  104123. tessellation?: number;
  104124. updatable?: boolean;
  104125. sideOrientation?: number;
  104126. frontUVs?: Vector4;
  104127. backUVs?: Vector4;
  104128. }, scene: any): Mesh;
  104129. }
  104130. }
  104131. declare module BABYLON {
  104132. /**
  104133. * Class containing static functions to help procedurally build meshes
  104134. */
  104135. export class CylinderBuilder {
  104136. /**
  104137. * Creates a cylinder or a cone mesh
  104138. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104139. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104140. * * 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.
  104141. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104142. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104143. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104144. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104145. * * 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).
  104146. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104147. * * 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).
  104148. * * 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
  104149. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104150. * * 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
  104151. * * 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.
  104152. * * If `enclose` is false, a ring surface is one element.
  104153. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104154. * * 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
  104155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104158. * @param name defines the name of the mesh
  104159. * @param options defines the options used to create the mesh
  104160. * @param scene defines the hosting scene
  104161. * @returns the cylinder mesh
  104162. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104163. */
  104164. static CreateCylinder(name: string, options: {
  104165. height?: number;
  104166. diameterTop?: number;
  104167. diameterBottom?: number;
  104168. diameter?: number;
  104169. tessellation?: number;
  104170. subdivisions?: number;
  104171. arc?: number;
  104172. faceColors?: Color4[];
  104173. faceUV?: Vector4[];
  104174. updatable?: boolean;
  104175. hasRings?: boolean;
  104176. enclose?: boolean;
  104177. cap?: number;
  104178. sideOrientation?: number;
  104179. frontUVs?: Vector4;
  104180. backUVs?: Vector4;
  104181. }, scene: any): Mesh;
  104182. }
  104183. }
  104184. declare module BABYLON {
  104185. /**
  104186. * Options to modify the vr teleportation behavior.
  104187. */
  104188. export interface VRTeleportationOptions {
  104189. /**
  104190. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104191. */
  104192. floorMeshName?: string;
  104193. /**
  104194. * A list of meshes to be used as the teleportation floor. (default: empty)
  104195. */
  104196. floorMeshes?: Mesh[];
  104197. }
  104198. /**
  104199. * Options to modify the vr experience helper's behavior.
  104200. */
  104201. export interface VRExperienceHelperOptions extends WebVROptions {
  104202. /**
  104203. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104204. */
  104205. createDeviceOrientationCamera?: boolean;
  104206. /**
  104207. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104208. */
  104209. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104210. /**
  104211. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104212. */
  104213. laserToggle?: boolean;
  104214. /**
  104215. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104216. */
  104217. floorMeshes?: Mesh[];
  104218. /**
  104219. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104220. */
  104221. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104222. }
  104223. /**
  104224. * Event containing information after VR has been entered
  104225. */
  104226. export class OnAfterEnteringVRObservableEvent {
  104227. /**
  104228. * If entering vr was successful
  104229. */
  104230. success: boolean;
  104231. }
  104232. /**
  104233. * Helps to quickly add VR support to an existing scene.
  104234. * See http://doc.babylonjs.com/how_to/webvr_helper
  104235. */
  104236. export class VRExperienceHelper {
  104237. /** Options to modify the vr experience helper's behavior. */
  104238. webVROptions: VRExperienceHelperOptions;
  104239. private _scene;
  104240. private _position;
  104241. private _btnVR;
  104242. private _btnVRDisplayed;
  104243. private _webVRsupported;
  104244. private _webVRready;
  104245. private _webVRrequesting;
  104246. private _webVRpresenting;
  104247. private _hasEnteredVR;
  104248. private _fullscreenVRpresenting;
  104249. private _canvas;
  104250. private _webVRCamera;
  104251. private _vrDeviceOrientationCamera;
  104252. private _deviceOrientationCamera;
  104253. private _existingCamera;
  104254. private _onKeyDown;
  104255. private _onVrDisplayPresentChange;
  104256. private _onVRDisplayChanged;
  104257. private _onVRRequestPresentStart;
  104258. private _onVRRequestPresentComplete;
  104259. /**
  104260. * 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)
  104261. */
  104262. enableGazeEvenWhenNoPointerLock: boolean;
  104263. /**
  104264. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104265. */
  104266. exitVROnDoubleTap: boolean;
  104267. /**
  104268. * Observable raised right before entering VR.
  104269. */
  104270. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104271. /**
  104272. * Observable raised when entering VR has completed.
  104273. */
  104274. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104275. /**
  104276. * Observable raised when exiting VR.
  104277. */
  104278. onExitingVRObservable: Observable<VRExperienceHelper>;
  104279. /**
  104280. * Observable raised when controller mesh is loaded.
  104281. */
  104282. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104283. /** Return this.onEnteringVRObservable
  104284. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104285. */
  104286. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104287. /** Return this.onExitingVRObservable
  104288. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104289. */
  104290. readonly onExitingVR: Observable<VRExperienceHelper>;
  104291. /** Return this.onControllerMeshLoadedObservable
  104292. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104293. */
  104294. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104295. private _rayLength;
  104296. private _useCustomVRButton;
  104297. private _teleportationRequested;
  104298. private _teleportActive;
  104299. private _floorMeshName;
  104300. private _floorMeshesCollection;
  104301. private _rotationAllowed;
  104302. private _teleportBackwardsVector;
  104303. private _teleportationTarget;
  104304. private _isDefaultTeleportationTarget;
  104305. private _postProcessMove;
  104306. private _teleportationFillColor;
  104307. private _teleportationBorderColor;
  104308. private _rotationAngle;
  104309. private _haloCenter;
  104310. private _cameraGazer;
  104311. private _padSensibilityUp;
  104312. private _padSensibilityDown;
  104313. private _leftController;
  104314. private _rightController;
  104315. /**
  104316. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104317. */
  104318. onNewMeshSelected: Observable<AbstractMesh>;
  104319. /**
  104320. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104321. */
  104322. onNewMeshPicked: Observable<PickingInfo>;
  104323. private _circleEase;
  104324. /**
  104325. * Observable raised before camera teleportation
  104326. */
  104327. onBeforeCameraTeleport: Observable<Vector3>;
  104328. /**
  104329. * Observable raised after camera teleportation
  104330. */
  104331. onAfterCameraTeleport: Observable<Vector3>;
  104332. /**
  104333. * Observable raised when current selected mesh gets unselected
  104334. */
  104335. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104336. private _raySelectionPredicate;
  104337. /**
  104338. * To be optionaly changed by user to define custom ray selection
  104339. */
  104340. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104341. /**
  104342. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104343. */
  104344. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104345. /**
  104346. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104347. */
  104348. teleportationEnabled: boolean;
  104349. private _defaultHeight;
  104350. private _teleportationInitialized;
  104351. private _interactionsEnabled;
  104352. private _interactionsRequested;
  104353. private _displayGaze;
  104354. private _displayLaserPointer;
  104355. /**
  104356. * The mesh used to display where the user is going to teleport.
  104357. */
  104358. /**
  104359. * Sets the mesh to be used to display where the user is going to teleport.
  104360. */
  104361. teleportationTarget: Mesh;
  104362. /**
  104363. * 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
  104364. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104365. * See http://doc.babylonjs.com/resources/baking_transformations
  104366. */
  104367. gazeTrackerMesh: Mesh;
  104368. /**
  104369. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104370. */
  104371. updateGazeTrackerScale: boolean;
  104372. /**
  104373. * If the gaze trackers color should be updated when selecting meshes
  104374. */
  104375. updateGazeTrackerColor: boolean;
  104376. /**
  104377. * The gaze tracking mesh corresponding to the left controller
  104378. */
  104379. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104380. /**
  104381. * The gaze tracking mesh corresponding to the right controller
  104382. */
  104383. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104384. /**
  104385. * If the ray of the gaze should be displayed.
  104386. */
  104387. /**
  104388. * Sets if the ray of the gaze should be displayed.
  104389. */
  104390. displayGaze: boolean;
  104391. /**
  104392. * If the ray of the LaserPointer should be displayed.
  104393. */
  104394. /**
  104395. * Sets if the ray of the LaserPointer should be displayed.
  104396. */
  104397. displayLaserPointer: boolean;
  104398. /**
  104399. * The deviceOrientationCamera used as the camera when not in VR.
  104400. */
  104401. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104402. /**
  104403. * Based on the current WebVR support, returns the current VR camera used.
  104404. */
  104405. readonly currentVRCamera: Nullable<Camera>;
  104406. /**
  104407. * The webVRCamera which is used when in VR.
  104408. */
  104409. readonly webVRCamera: WebVRFreeCamera;
  104410. /**
  104411. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104412. */
  104413. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104414. /**
  104415. * The html button that is used to trigger entering into VR.
  104416. */
  104417. readonly vrButton: Nullable<HTMLButtonElement>;
  104418. private readonly _teleportationRequestInitiated;
  104419. /**
  104420. * Defines wether or not Pointer lock should be requested when switching to
  104421. * full screen.
  104422. */
  104423. requestPointerLockOnFullScreen: boolean;
  104424. /**
  104425. * Instantiates a VRExperienceHelper.
  104426. * Helps to quickly add VR support to an existing scene.
  104427. * @param scene The scene the VRExperienceHelper belongs to.
  104428. * @param webVROptions Options to modify the vr experience helper's behavior.
  104429. */
  104430. constructor(scene: Scene,
  104431. /** Options to modify the vr experience helper's behavior. */
  104432. webVROptions?: VRExperienceHelperOptions);
  104433. private _onDefaultMeshLoaded;
  104434. private _onResize;
  104435. private _onFullscreenChange;
  104436. /**
  104437. * Gets a value indicating if we are currently in VR mode.
  104438. */
  104439. readonly isInVRMode: boolean;
  104440. private onVrDisplayPresentChange;
  104441. private onVRDisplayChanged;
  104442. private moveButtonToBottomRight;
  104443. private displayVRButton;
  104444. private updateButtonVisibility;
  104445. private _cachedAngularSensibility;
  104446. /**
  104447. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104448. * Otherwise, will use the fullscreen API.
  104449. */
  104450. enterVR(): void;
  104451. /**
  104452. * Attempt to exit VR, or fullscreen.
  104453. */
  104454. exitVR(): void;
  104455. /**
  104456. * The position of the vr experience helper.
  104457. */
  104458. /**
  104459. * Sets the position of the vr experience helper.
  104460. */
  104461. position: Vector3;
  104462. /**
  104463. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104464. */
  104465. enableInteractions(): void;
  104466. private readonly _noControllerIsActive;
  104467. private beforeRender;
  104468. private _isTeleportationFloor;
  104469. /**
  104470. * Adds a floor mesh to be used for teleportation.
  104471. * @param floorMesh the mesh to be used for teleportation.
  104472. */
  104473. addFloorMesh(floorMesh: Mesh): void;
  104474. /**
  104475. * Removes a floor mesh from being used for teleportation.
  104476. * @param floorMesh the mesh to be removed.
  104477. */
  104478. removeFloorMesh(floorMesh: Mesh): void;
  104479. /**
  104480. * Enables interactions and teleportation using the VR controllers and gaze.
  104481. * @param vrTeleportationOptions options to modify teleportation behavior.
  104482. */
  104483. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104484. private _onNewGamepadConnected;
  104485. private _tryEnableInteractionOnController;
  104486. private _onNewGamepadDisconnected;
  104487. private _enableInteractionOnController;
  104488. private _checkTeleportWithRay;
  104489. private _checkRotate;
  104490. private _checkTeleportBackwards;
  104491. private _enableTeleportationOnController;
  104492. private _createTeleportationCircles;
  104493. private _displayTeleportationTarget;
  104494. private _hideTeleportationTarget;
  104495. private _rotateCamera;
  104496. private _moveTeleportationSelectorTo;
  104497. private _workingVector;
  104498. private _workingQuaternion;
  104499. private _workingMatrix;
  104500. /**
  104501. * Teleports the users feet to the desired location
  104502. * @param location The location where the user's feet should be placed
  104503. */
  104504. teleportCamera(location: Vector3): void;
  104505. private _convertNormalToDirectionOfRay;
  104506. private _castRayAndSelectObject;
  104507. private _notifySelectedMeshUnselected;
  104508. /**
  104509. * Sets the color of the laser ray from the vr controllers.
  104510. * @param color new color for the ray.
  104511. */
  104512. changeLaserColor(color: Color3): void;
  104513. /**
  104514. * Sets the color of the ray from the vr headsets gaze.
  104515. * @param color new color for the ray.
  104516. */
  104517. changeGazeColor(color: Color3): void;
  104518. /**
  104519. * Exits VR and disposes of the vr experience helper
  104520. */
  104521. dispose(): void;
  104522. /**
  104523. * Gets the name of the VRExperienceHelper class
  104524. * @returns "VRExperienceHelper"
  104525. */
  104526. getClassName(): string;
  104527. }
  104528. }
  104529. declare module BABYLON {
  104530. /**
  104531. * Manages an XRSession to work with Babylon's engine
  104532. * @see https://doc.babylonjs.com/how_to/webxr
  104533. */
  104534. export class WebXRSessionManager implements IDisposable {
  104535. private scene;
  104536. /**
  104537. * Fires every time a new xrFrame arrives which can be used to update the camera
  104538. */
  104539. onXRFrameObservable: Observable<any>;
  104540. /**
  104541. * Fires when the xr session is ended either by the device or manually done
  104542. */
  104543. onXRSessionEnded: Observable<any>;
  104544. /**
  104545. * Underlying xr session
  104546. */
  104547. session: XRSession;
  104548. /**
  104549. * Type of reference space used when creating the session
  104550. */
  104551. referenceSpace: XRReferenceSpace;
  104552. /** @hidden */
  104553. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104554. /**
  104555. * Current XR frame
  104556. */
  104557. currentFrame: Nullable<XRFrame>;
  104558. private _xrNavigator;
  104559. private baseLayer;
  104560. /**
  104561. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104562. * @param scene The scene which the session should be created for
  104563. */
  104564. constructor(scene: Scene);
  104565. /**
  104566. * Initializes the manager
  104567. * After initialization enterXR can be called to start an XR session
  104568. * @returns Promise which resolves after it is initialized
  104569. */
  104570. initializeAsync(): Promise<void>;
  104571. /**
  104572. * Initializes an xr session
  104573. * @param xrSessionMode mode to initialize
  104574. * @returns a promise which will resolve once the session has been initialized
  104575. */
  104576. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104577. /**
  104578. * Sets the reference space on the xr session
  104579. * @param referenceSpace space to set
  104580. * @returns a promise that will resolve once the reference space has been set
  104581. */
  104582. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104583. /**
  104584. * Updates the render state of the session
  104585. * @param state state to set
  104586. * @returns a promise that resolves once the render state has been updated
  104587. */
  104588. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104589. /**
  104590. * Starts rendering to the xr layer
  104591. * @returns a promise that will resolve once rendering has started
  104592. */
  104593. startRenderingToXRAsync(): Promise<void>;
  104594. /**
  104595. * Stops the xrSession and restores the renderloop
  104596. * @returns Promise which resolves after it exits XR
  104597. */
  104598. exitXRAsync(): Promise<unknown>;
  104599. /**
  104600. * Checks if a session would be supported for the creation options specified
  104601. * @param sessionMode session mode to check if supported eg. immersive-vr
  104602. * @returns true if supported
  104603. */
  104604. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104605. /**
  104606. * @hidden
  104607. * Converts the render layer of xrSession to a render target
  104608. * @param session session to create render target for
  104609. * @param scene scene the new render target should be created for
  104610. */
  104611. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104612. /**
  104613. * Disposes of the session manager
  104614. */
  104615. dispose(): void;
  104616. }
  104617. }
  104618. declare module BABYLON {
  104619. /**
  104620. * WebXR Camera which holds the views for the xrSession
  104621. * @see https://doc.babylonjs.com/how_to/webxr
  104622. */
  104623. export class WebXRCamera extends FreeCamera {
  104624. private static _TmpMatrix;
  104625. /**
  104626. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104627. * @param name the name of the camera
  104628. * @param scene the scene to add the camera to
  104629. */
  104630. constructor(name: string, scene: Scene);
  104631. private _updateNumberOfRigCameras;
  104632. /** @hidden */
  104633. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104634. /**
  104635. * Updates the cameras position from the current pose information of the XR session
  104636. * @param xrSessionManager the session containing pose information
  104637. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104638. */
  104639. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104640. }
  104641. }
  104642. declare module BABYLON {
  104643. /**
  104644. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104645. */
  104646. export class WebXRManagedOutputCanvas implements IDisposable {
  104647. private helper;
  104648. private _canvas;
  104649. /**
  104650. * xrpresent context of the canvas which can be used to display/mirror xr content
  104651. */
  104652. canvasContext: WebGLRenderingContext;
  104653. /**
  104654. * xr layer for the canvas
  104655. */
  104656. xrLayer: Nullable<XRWebGLLayer>;
  104657. /**
  104658. * Initializes the xr layer for the session
  104659. * @param xrSession xr session
  104660. * @returns a promise that will resolve once the XR Layer has been created
  104661. */
  104662. initializeXRLayerAsync(xrSession: any): any;
  104663. /**
  104664. * Initializes the canvas to be added/removed upon entering/exiting xr
  104665. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104666. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104667. */
  104668. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104669. /**
  104670. * Disposes of the object
  104671. */
  104672. dispose(): void;
  104673. private _setManagedOutputCanvas;
  104674. private _addCanvas;
  104675. private _removeCanvas;
  104676. }
  104677. }
  104678. declare module BABYLON {
  104679. /**
  104680. * States of the webXR experience
  104681. */
  104682. export enum WebXRState {
  104683. /**
  104684. * Transitioning to being in XR mode
  104685. */
  104686. ENTERING_XR = 0,
  104687. /**
  104688. * Transitioning to non XR mode
  104689. */
  104690. EXITING_XR = 1,
  104691. /**
  104692. * In XR mode and presenting
  104693. */
  104694. IN_XR = 2,
  104695. /**
  104696. * Not entered XR mode
  104697. */
  104698. NOT_IN_XR = 3
  104699. }
  104700. /**
  104701. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104702. * @see https://doc.babylonjs.com/how_to/webxr
  104703. */
  104704. export class WebXRExperienceHelper implements IDisposable {
  104705. private scene;
  104706. /**
  104707. * 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
  104708. */
  104709. container: AbstractMesh;
  104710. /**
  104711. * Camera used to render xr content
  104712. */
  104713. camera: WebXRCamera;
  104714. /**
  104715. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104716. */
  104717. state: WebXRState;
  104718. private _setState;
  104719. private static _TmpVector;
  104720. /**
  104721. * Fires when the state of the experience helper has changed
  104722. */
  104723. onStateChangedObservable: Observable<WebXRState>;
  104724. /** Session manager used to keep track of xr session */
  104725. sessionManager: WebXRSessionManager;
  104726. private _nonVRCamera;
  104727. private _originalSceneAutoClear;
  104728. private _supported;
  104729. /**
  104730. * Creates the experience helper
  104731. * @param scene the scene to attach the experience helper to
  104732. * @returns a promise for the experience helper
  104733. */
  104734. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104735. /**
  104736. * Creates a WebXRExperienceHelper
  104737. * @param scene The scene the helper should be created in
  104738. */
  104739. private constructor();
  104740. /**
  104741. * Exits XR mode and returns the scene to its original state
  104742. * @returns promise that resolves after xr mode has exited
  104743. */
  104744. exitXRAsync(): Promise<unknown>;
  104745. /**
  104746. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104747. * @param sessionCreationOptions options for the XR session
  104748. * @param referenceSpaceType frame of reference of the XR session
  104749. * @param outputCanvas the output canvas that will be used to enter XR mode
  104750. * @returns promise that resolves after xr mode has entered
  104751. */
  104752. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104753. /**
  104754. * Updates the global position of the camera by moving the camera's container
  104755. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104756. * @param position The desired global position of the camera
  104757. */
  104758. setPositionOfCameraUsingContainer(position: Vector3): void;
  104759. /**
  104760. * Rotates the xr camera by rotating the camera's container around the camera's position
  104761. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104762. * @param rotation the desired quaternion rotation to apply to the camera
  104763. */
  104764. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104765. /**
  104766. * Disposes of the experience helper
  104767. */
  104768. dispose(): void;
  104769. }
  104770. }
  104771. declare module BABYLON {
  104772. /**
  104773. * Button which can be used to enter a different mode of XR
  104774. */
  104775. export class WebXREnterExitUIButton {
  104776. /** button element */
  104777. element: HTMLElement;
  104778. /** XR initialization options for the button */
  104779. sessionMode: XRSessionMode;
  104780. /** Reference space type */
  104781. referenceSpaceType: XRReferenceSpaceType;
  104782. /**
  104783. * Creates a WebXREnterExitUIButton
  104784. * @param element button element
  104785. * @param sessionMode XR initialization session mode
  104786. * @param referenceSpaceType the type of reference space to be used
  104787. */
  104788. constructor(
  104789. /** button element */
  104790. element: HTMLElement,
  104791. /** XR initialization options for the button */
  104792. sessionMode: XRSessionMode,
  104793. /** Reference space type */
  104794. referenceSpaceType: XRReferenceSpaceType);
  104795. /**
  104796. * Overwritable function which can be used to update the button's visuals when the state changes
  104797. * @param activeButton the current active button in the UI
  104798. */
  104799. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104800. }
  104801. /**
  104802. * Options to create the webXR UI
  104803. */
  104804. export class WebXREnterExitUIOptions {
  104805. /**
  104806. * Context to enter xr with
  104807. */
  104808. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104809. /**
  104810. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  104811. */
  104812. customButtons?: Array<WebXREnterExitUIButton>;
  104813. }
  104814. /**
  104815. * UI to allow the user to enter/exit XR mode
  104816. */
  104817. export class WebXREnterExitUI implements IDisposable {
  104818. private scene;
  104819. private _overlay;
  104820. private _buttons;
  104821. private _activeButton;
  104822. /**
  104823. * Fired every time the active button is changed.
  104824. *
  104825. * When xr is entered via a button that launches xr that button will be the callback parameter
  104826. *
  104827. * When exiting xr the callback parameter will be null)
  104828. */
  104829. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  104830. /**
  104831. * Creates UI to allow the user to enter/exit XR mode
  104832. * @param scene the scene to add the ui to
  104833. * @param helper the xr experience helper to enter/exit xr with
  104834. * @param options options to configure the UI
  104835. * @returns the created ui
  104836. */
  104837. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  104838. private constructor();
  104839. private _updateButtons;
  104840. /**
  104841. * Disposes of the object
  104842. */
  104843. dispose(): void;
  104844. }
  104845. }
  104846. declare module BABYLON {
  104847. /**
  104848. * Represents an XR input
  104849. */
  104850. export class WebXRController {
  104851. private scene;
  104852. /** The underlying input source for the controller */
  104853. inputSource: XRInputSource;
  104854. private parentContainer;
  104855. /**
  104856. * 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
  104857. */
  104858. grip?: AbstractMesh;
  104859. /**
  104860. * Pointer which can be used to select objects or attach a visible laser to
  104861. */
  104862. pointer: AbstractMesh;
  104863. /**
  104864. * Event that fires when the controller is removed/disposed
  104865. */
  104866. onDisposeObservable: Observable<{}>;
  104867. private _tmpMatrix;
  104868. private _tmpQuaternion;
  104869. private _tmpVector;
  104870. /**
  104871. * Creates the controller
  104872. * @see https://doc.babylonjs.com/how_to/webxr
  104873. * @param scene the scene which the controller should be associated to
  104874. * @param inputSource the underlying input source for the controller
  104875. * @param parentContainer parent that the controller meshes should be children of
  104876. */
  104877. constructor(scene: Scene,
  104878. /** The underlying input source for the controller */
  104879. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  104880. /**
  104881. * Updates the controller pose based on the given XRFrame
  104882. * @param xrFrame xr frame to update the pose with
  104883. * @param referenceSpace reference space to use
  104884. */
  104885. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  104886. /**
  104887. * Gets a world space ray coming from the controller
  104888. * @param result the resulting ray
  104889. */
  104890. getWorldPointerRayToRef(result: Ray): void;
  104891. /**
  104892. * Disposes of the object
  104893. */
  104894. dispose(): void;
  104895. }
  104896. }
  104897. declare module BABYLON {
  104898. /**
  104899. * XR input used to track XR inputs such as controllers/rays
  104900. */
  104901. export class WebXRInput implements IDisposable {
  104902. /**
  104903. * Base experience the input listens to
  104904. */
  104905. baseExperience: WebXRExperienceHelper;
  104906. /**
  104907. * XR controllers being tracked
  104908. */
  104909. controllers: Array<WebXRController>;
  104910. private _frameObserver;
  104911. private _stateObserver;
  104912. /**
  104913. * Event when a controller has been connected/added
  104914. */
  104915. onControllerAddedObservable: Observable<WebXRController>;
  104916. /**
  104917. * Event when a controller has been removed/disconnected
  104918. */
  104919. onControllerRemovedObservable: Observable<WebXRController>;
  104920. /**
  104921. * Initializes the WebXRInput
  104922. * @param baseExperience experience helper which the input should be created for
  104923. */
  104924. constructor(
  104925. /**
  104926. * Base experience the input listens to
  104927. */
  104928. baseExperience: WebXRExperienceHelper);
  104929. private _onInputSourcesChange;
  104930. private _addAndRemoveControllers;
  104931. /**
  104932. * Disposes of the object
  104933. */
  104934. dispose(): void;
  104935. }
  104936. }
  104937. declare module BABYLON {
  104938. /**
  104939. * Enables teleportation
  104940. */
  104941. export class WebXRControllerTeleportation {
  104942. private _teleportationFillColor;
  104943. private _teleportationBorderColor;
  104944. private _tmpRay;
  104945. private _tmpVector;
  104946. /**
  104947. * Creates a WebXRControllerTeleportation
  104948. * @param input input manager to add teleportation to
  104949. * @param floorMeshes floormeshes which can be teleported to
  104950. */
  104951. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  104952. }
  104953. }
  104954. declare module BABYLON {
  104955. /**
  104956. * Handles pointer input automatically for the pointer of XR controllers
  104957. */
  104958. export class WebXRControllerPointerSelection {
  104959. private static _idCounter;
  104960. private _tmpRay;
  104961. /**
  104962. * Creates a WebXRControllerPointerSelection
  104963. * @param input input manager to setup pointer selection
  104964. */
  104965. constructor(input: WebXRInput);
  104966. private _convertNormalToDirectionOfRay;
  104967. private _updatePointerDistance;
  104968. }
  104969. }
  104970. declare module BABYLON {
  104971. /**
  104972. * Class used to represent data loading progression
  104973. */
  104974. export class SceneLoaderProgressEvent {
  104975. /** defines if data length to load can be evaluated */
  104976. readonly lengthComputable: boolean;
  104977. /** defines the loaded data length */
  104978. readonly loaded: number;
  104979. /** defines the data length to load */
  104980. readonly total: number;
  104981. /**
  104982. * Create a new progress event
  104983. * @param lengthComputable defines if data length to load can be evaluated
  104984. * @param loaded defines the loaded data length
  104985. * @param total defines the data length to load
  104986. */
  104987. constructor(
  104988. /** defines if data length to load can be evaluated */
  104989. lengthComputable: boolean,
  104990. /** defines the loaded data length */
  104991. loaded: number,
  104992. /** defines the data length to load */
  104993. total: number);
  104994. /**
  104995. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104996. * @param event defines the source event
  104997. * @returns a new SceneLoaderProgressEvent
  104998. */
  104999. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105000. }
  105001. /**
  105002. * Interface used by SceneLoader plugins to define supported file extensions
  105003. */
  105004. export interface ISceneLoaderPluginExtensions {
  105005. /**
  105006. * Defines the list of supported extensions
  105007. */
  105008. [extension: string]: {
  105009. isBinary: boolean;
  105010. };
  105011. }
  105012. /**
  105013. * Interface used by SceneLoader plugin factory
  105014. */
  105015. export interface ISceneLoaderPluginFactory {
  105016. /**
  105017. * Defines the name of the factory
  105018. */
  105019. name: string;
  105020. /**
  105021. * Function called to create a new plugin
  105022. * @return the new plugin
  105023. */
  105024. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105025. /**
  105026. * Boolean indicating if the plugin can direct load specific data
  105027. */
  105028. canDirectLoad?: (data: string) => boolean;
  105029. }
  105030. /**
  105031. * Interface used to define a SceneLoader plugin
  105032. */
  105033. export interface ISceneLoaderPlugin {
  105034. /**
  105035. * The friendly name of this plugin.
  105036. */
  105037. name: string;
  105038. /**
  105039. * The file extensions supported by this plugin.
  105040. */
  105041. extensions: string | ISceneLoaderPluginExtensions;
  105042. /**
  105043. * Import meshes into a scene.
  105044. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105045. * @param scene The scene to import into
  105046. * @param data The data to import
  105047. * @param rootUrl The root url for scene and resources
  105048. * @param meshes The meshes array to import into
  105049. * @param particleSystems The particle systems array to import into
  105050. * @param skeletons The skeletons array to import into
  105051. * @param onError The callback when import fails
  105052. * @returns True if successful or false otherwise
  105053. */
  105054. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105055. /**
  105056. * Load into a scene.
  105057. * @param scene The scene to load into
  105058. * @param data The data to import
  105059. * @param rootUrl The root url for scene and resources
  105060. * @param onError The callback when import fails
  105061. * @returns true if successful or false otherwise
  105062. */
  105063. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105064. /**
  105065. * The callback that returns true if the data can be directly loaded.
  105066. */
  105067. canDirectLoad?: (data: string) => boolean;
  105068. /**
  105069. * The callback that allows custom handling of the root url based on the response url.
  105070. */
  105071. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105072. /**
  105073. * Load into an asset container.
  105074. * @param scene The scene to load into
  105075. * @param data The data to import
  105076. * @param rootUrl The root url for scene and resources
  105077. * @param onError The callback when import fails
  105078. * @returns The loaded asset container
  105079. */
  105080. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105081. }
  105082. /**
  105083. * Interface used to define an async SceneLoader plugin
  105084. */
  105085. export interface ISceneLoaderPluginAsync {
  105086. /**
  105087. * The friendly name of this plugin.
  105088. */
  105089. name: string;
  105090. /**
  105091. * The file extensions supported by this plugin.
  105092. */
  105093. extensions: string | ISceneLoaderPluginExtensions;
  105094. /**
  105095. * Import meshes into a scene.
  105096. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105097. * @param scene The scene to import into
  105098. * @param data The data to import
  105099. * @param rootUrl The root url for scene and resources
  105100. * @param onProgress The callback when the load progresses
  105101. * @param fileName Defines the name of the file to load
  105102. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105103. */
  105104. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105105. meshes: AbstractMesh[];
  105106. particleSystems: IParticleSystem[];
  105107. skeletons: Skeleton[];
  105108. animationGroups: AnimationGroup[];
  105109. }>;
  105110. /**
  105111. * Load into a scene.
  105112. * @param scene The scene to load into
  105113. * @param data The data to import
  105114. * @param rootUrl The root url for scene and resources
  105115. * @param onProgress The callback when the load progresses
  105116. * @param fileName Defines the name of the file to load
  105117. * @returns Nothing
  105118. */
  105119. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105120. /**
  105121. * The callback that returns true if the data can be directly loaded.
  105122. */
  105123. canDirectLoad?: (data: string) => boolean;
  105124. /**
  105125. * The callback that allows custom handling of the root url based on the response url.
  105126. */
  105127. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105128. /**
  105129. * Load into an asset container.
  105130. * @param scene The scene to load into
  105131. * @param data The data to import
  105132. * @param rootUrl The root url for scene and resources
  105133. * @param onProgress The callback when the load progresses
  105134. * @param fileName Defines the name of the file to load
  105135. * @returns The loaded asset container
  105136. */
  105137. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105138. }
  105139. /**
  105140. * Class used to load scene from various file formats using registered plugins
  105141. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105142. */
  105143. export class SceneLoader {
  105144. /**
  105145. * No logging while loading
  105146. */
  105147. static readonly NO_LOGGING: number;
  105148. /**
  105149. * Minimal logging while loading
  105150. */
  105151. static readonly MINIMAL_LOGGING: number;
  105152. /**
  105153. * Summary logging while loading
  105154. */
  105155. static readonly SUMMARY_LOGGING: number;
  105156. /**
  105157. * Detailled logging while loading
  105158. */
  105159. static readonly DETAILED_LOGGING: number;
  105160. /**
  105161. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105162. */
  105163. static ForceFullSceneLoadingForIncremental: boolean;
  105164. /**
  105165. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105166. */
  105167. static ShowLoadingScreen: boolean;
  105168. /**
  105169. * Defines the current logging level (while loading the scene)
  105170. * @ignorenaming
  105171. */
  105172. static loggingLevel: number;
  105173. /**
  105174. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105175. */
  105176. static CleanBoneMatrixWeights: boolean;
  105177. /**
  105178. * Event raised when a plugin is used to load a scene
  105179. */
  105180. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105181. private static _registeredPlugins;
  105182. private static _getDefaultPlugin;
  105183. private static _getPluginForExtension;
  105184. private static _getPluginForDirectLoad;
  105185. private static _getPluginForFilename;
  105186. private static _getDirectLoad;
  105187. private static _loadData;
  105188. private static _getFileInfo;
  105189. /**
  105190. * Gets a plugin that can load the given extension
  105191. * @param extension defines the extension to load
  105192. * @returns a plugin or null if none works
  105193. */
  105194. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105195. /**
  105196. * Gets a boolean indicating that the given extension can be loaded
  105197. * @param extension defines the extension to load
  105198. * @returns true if the extension is supported
  105199. */
  105200. static IsPluginForExtensionAvailable(extension: string): boolean;
  105201. /**
  105202. * Adds a new plugin to the list of registered plugins
  105203. * @param plugin defines the plugin to add
  105204. */
  105205. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105206. /**
  105207. * Import meshes into a scene
  105208. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105209. * @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)
  105210. * @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)
  105211. * @param scene the instance of BABYLON.Scene to append to
  105212. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105213. * @param onProgress a callback with a progress event for each file being loaded
  105214. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105215. * @param pluginExtension the extension used to determine the plugin
  105216. * @returns The loaded plugin
  105217. */
  105218. 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>;
  105219. /**
  105220. * Import meshes into a scene
  105221. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105222. * @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)
  105223. * @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)
  105224. * @param scene the instance of BABYLON.Scene to append to
  105225. * @param onProgress a callback with a progress event for each file being loaded
  105226. * @param pluginExtension the extension used to determine the plugin
  105227. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105228. */
  105229. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105230. meshes: AbstractMesh[];
  105231. particleSystems: IParticleSystem[];
  105232. skeletons: Skeleton[];
  105233. animationGroups: AnimationGroup[];
  105234. }>;
  105235. /**
  105236. * Load a scene
  105237. * @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)
  105238. * @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)
  105239. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105240. * @param onSuccess a callback with the scene when import succeeds
  105241. * @param onProgress a callback with a progress event for each file being loaded
  105242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105243. * @param pluginExtension the extension used to determine the plugin
  105244. * @returns The loaded plugin
  105245. */
  105246. 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>;
  105247. /**
  105248. * Load a scene
  105249. * @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)
  105250. * @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)
  105251. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105252. * @param onProgress a callback with a progress event for each file being loaded
  105253. * @param pluginExtension the extension used to determine the plugin
  105254. * @returns The loaded scene
  105255. */
  105256. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105257. /**
  105258. * Append a scene
  105259. * @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)
  105260. * @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)
  105261. * @param scene is the instance of BABYLON.Scene to append to
  105262. * @param onSuccess a callback with the scene when import succeeds
  105263. * @param onProgress a callback with a progress event for each file being loaded
  105264. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105265. * @param pluginExtension the extension used to determine the plugin
  105266. * @returns The loaded plugin
  105267. */
  105268. 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>;
  105269. /**
  105270. * Append a scene
  105271. * @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)
  105272. * @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)
  105273. * @param scene is the instance of BABYLON.Scene to append to
  105274. * @param onProgress a callback with a progress event for each file being loaded
  105275. * @param pluginExtension the extension used to determine the plugin
  105276. * @returns The given scene
  105277. */
  105278. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105279. /**
  105280. * Load a scene into an asset container
  105281. * @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)
  105282. * @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)
  105283. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105284. * @param onSuccess a callback with the scene when import succeeds
  105285. * @param onProgress a callback with a progress event for each file being loaded
  105286. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105287. * @param pluginExtension the extension used to determine the plugin
  105288. * @returns The loaded plugin
  105289. */
  105290. 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>;
  105291. /**
  105292. * Load a scene into an asset container
  105293. * @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)
  105294. * @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)
  105295. * @param scene is the instance of Scene to append to
  105296. * @param onProgress a callback with a progress event for each file being loaded
  105297. * @param pluginExtension the extension used to determine the plugin
  105298. * @returns The loaded asset container
  105299. */
  105300. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105301. }
  105302. }
  105303. declare module BABYLON {
  105304. /**
  105305. * Generic Controller
  105306. */
  105307. export class GenericController extends WebVRController {
  105308. /**
  105309. * Base Url for the controller model.
  105310. */
  105311. static readonly MODEL_BASE_URL: string;
  105312. /**
  105313. * File name for the controller model.
  105314. */
  105315. static readonly MODEL_FILENAME: string;
  105316. /**
  105317. * Creates a new GenericController from a gamepad
  105318. * @param vrGamepad the gamepad that the controller should be created from
  105319. */
  105320. constructor(vrGamepad: any);
  105321. /**
  105322. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105323. * @param scene scene in which to add meshes
  105324. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105325. */
  105326. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105327. /**
  105328. * Called once for each button that changed state since the last frame
  105329. * @param buttonIdx Which button index changed
  105330. * @param state New state of the button
  105331. * @param changes Which properties on the state changed since last frame
  105332. */
  105333. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105334. }
  105335. }
  105336. declare module BABYLON {
  105337. /**
  105338. * Defines the WindowsMotionController object that the state of the windows motion controller
  105339. */
  105340. export class WindowsMotionController extends WebVRController {
  105341. /**
  105342. * The base url used to load the left and right controller models
  105343. */
  105344. static MODEL_BASE_URL: string;
  105345. /**
  105346. * The name of the left controller model file
  105347. */
  105348. static MODEL_LEFT_FILENAME: string;
  105349. /**
  105350. * The name of the right controller model file
  105351. */
  105352. static MODEL_RIGHT_FILENAME: string;
  105353. /**
  105354. * The controller name prefix for this controller type
  105355. */
  105356. static readonly GAMEPAD_ID_PREFIX: string;
  105357. /**
  105358. * The controller id pattern for this controller type
  105359. */
  105360. private static readonly GAMEPAD_ID_PATTERN;
  105361. private _loadedMeshInfo;
  105362. private readonly _mapping;
  105363. /**
  105364. * Fired when the trackpad on this controller is clicked
  105365. */
  105366. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105367. /**
  105368. * Fired when the trackpad on this controller is modified
  105369. */
  105370. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105371. /**
  105372. * The current x and y values of this controller's trackpad
  105373. */
  105374. trackpad: StickValues;
  105375. /**
  105376. * Creates a new WindowsMotionController from a gamepad
  105377. * @param vrGamepad the gamepad that the controller should be created from
  105378. */
  105379. constructor(vrGamepad: any);
  105380. /**
  105381. * Fired when the trigger on this controller is modified
  105382. */
  105383. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105384. /**
  105385. * Fired when the menu button on this controller is modified
  105386. */
  105387. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105388. /**
  105389. * Fired when the grip button on this controller is modified
  105390. */
  105391. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105392. /**
  105393. * Fired when the thumbstick button on this controller is modified
  105394. */
  105395. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105396. /**
  105397. * Fired when the touchpad button on this controller is modified
  105398. */
  105399. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105400. /**
  105401. * Fired when the touchpad values on this controller are modified
  105402. */
  105403. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105404. private _updateTrackpad;
  105405. /**
  105406. * Called once per frame by the engine.
  105407. */
  105408. update(): void;
  105409. /**
  105410. * Called once for each button that changed state since the last frame
  105411. * @param buttonIdx Which button index changed
  105412. * @param state New state of the button
  105413. * @param changes Which properties on the state changed since last frame
  105414. */
  105415. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105416. /**
  105417. * Moves the buttons on the controller mesh based on their current state
  105418. * @param buttonName the name of the button to move
  105419. * @param buttonValue the value of the button which determines the buttons new position
  105420. */
  105421. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105422. /**
  105423. * Moves the axis on the controller mesh based on its current state
  105424. * @param axis the index of the axis
  105425. * @param axisValue the value of the axis which determines the meshes new position
  105426. * @hidden
  105427. */
  105428. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105429. /**
  105430. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105431. * @param scene scene in which to add meshes
  105432. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105433. */
  105434. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105435. /**
  105436. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105437. * can be transformed by button presses and axes values, based on this._mapping.
  105438. *
  105439. * @param scene scene in which the meshes exist
  105440. * @param meshes list of meshes that make up the controller model to process
  105441. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105442. */
  105443. private processModel;
  105444. private createMeshInfo;
  105445. /**
  105446. * Gets the ray of the controller in the direction the controller is pointing
  105447. * @param length the length the resulting ray should be
  105448. * @returns a ray in the direction the controller is pointing
  105449. */
  105450. getForwardRay(length?: number): Ray;
  105451. /**
  105452. * Disposes of the controller
  105453. */
  105454. dispose(): void;
  105455. }
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * Oculus Touch Controller
  105460. */
  105461. export class OculusTouchController extends WebVRController {
  105462. /**
  105463. * Base Url for the controller model.
  105464. */
  105465. static MODEL_BASE_URL: string;
  105466. /**
  105467. * File name for the left controller model.
  105468. */
  105469. static MODEL_LEFT_FILENAME: string;
  105470. /**
  105471. * File name for the right controller model.
  105472. */
  105473. static MODEL_RIGHT_FILENAME: string;
  105474. /**
  105475. * Base Url for the Quest controller model.
  105476. */
  105477. static QUEST_MODEL_BASE_URL: string;
  105478. /**
  105479. * @hidden
  105480. * If the controllers are running on a device that needs the updated Quest controller models
  105481. */
  105482. static _IsQuest: boolean;
  105483. /**
  105484. * Fired when the secondary trigger on this controller is modified
  105485. */
  105486. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105487. /**
  105488. * Fired when the thumb rest on this controller is modified
  105489. */
  105490. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105491. /**
  105492. * Creates a new OculusTouchController from a gamepad
  105493. * @param vrGamepad the gamepad that the controller should be created from
  105494. */
  105495. constructor(vrGamepad: any);
  105496. /**
  105497. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105498. * @param scene scene in which to add meshes
  105499. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105500. */
  105501. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105502. /**
  105503. * Fired when the A button on this controller is modified
  105504. */
  105505. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105506. /**
  105507. * Fired when the B button on this controller is modified
  105508. */
  105509. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105510. /**
  105511. * Fired when the X button on this controller is modified
  105512. */
  105513. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105514. /**
  105515. * Fired when the Y button on this controller is modified
  105516. */
  105517. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105518. /**
  105519. * Called once for each button that changed state since the last frame
  105520. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105521. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105522. * 2) secondary trigger (same)
  105523. * 3) A (right) X (left), touch, pressed = value
  105524. * 4) B / Y
  105525. * 5) thumb rest
  105526. * @param buttonIdx Which button index changed
  105527. * @param state New state of the button
  105528. * @param changes Which properties on the state changed since last frame
  105529. */
  105530. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105531. }
  105532. }
  105533. declare module BABYLON {
  105534. /**
  105535. * Vive Controller
  105536. */
  105537. export class ViveController extends WebVRController {
  105538. /**
  105539. * Base Url for the controller model.
  105540. */
  105541. static MODEL_BASE_URL: string;
  105542. /**
  105543. * File name for the controller model.
  105544. */
  105545. static MODEL_FILENAME: string;
  105546. /**
  105547. * Creates a new ViveController from a gamepad
  105548. * @param vrGamepad the gamepad that the controller should be created from
  105549. */
  105550. constructor(vrGamepad: any);
  105551. /**
  105552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105553. * @param scene scene in which to add meshes
  105554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105555. */
  105556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105557. /**
  105558. * Fired when the left button on this controller is modified
  105559. */
  105560. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105561. /**
  105562. * Fired when the right button on this controller is modified
  105563. */
  105564. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105565. /**
  105566. * Fired when the menu button on this controller is modified
  105567. */
  105568. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105569. /**
  105570. * Called once for each button that changed state since the last frame
  105571. * Vive mapping:
  105572. * 0: touchpad
  105573. * 1: trigger
  105574. * 2: left AND right buttons
  105575. * 3: menu button
  105576. * @param buttonIdx Which button index changed
  105577. * @param state New state of the button
  105578. * @param changes Which properties on the state changed since last frame
  105579. */
  105580. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105581. }
  105582. }
  105583. declare module BABYLON {
  105584. /**
  105585. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105586. */
  105587. export class WebXRControllerModelLoader {
  105588. /**
  105589. * Creates the WebXRControllerModelLoader
  105590. * @param input xr input that creates the controllers
  105591. */
  105592. constructor(input: WebXRInput);
  105593. }
  105594. }
  105595. declare module BABYLON {
  105596. /**
  105597. * Contains an array of blocks representing the octree
  105598. */
  105599. export interface IOctreeContainer<T> {
  105600. /**
  105601. * Blocks within the octree
  105602. */
  105603. blocks: Array<OctreeBlock<T>>;
  105604. }
  105605. /**
  105606. * Class used to store a cell in an octree
  105607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105608. */
  105609. export class OctreeBlock<T> {
  105610. /**
  105611. * Gets the content of the current block
  105612. */
  105613. entries: T[];
  105614. /**
  105615. * Gets the list of block children
  105616. */
  105617. blocks: Array<OctreeBlock<T>>;
  105618. private _depth;
  105619. private _maxDepth;
  105620. private _capacity;
  105621. private _minPoint;
  105622. private _maxPoint;
  105623. private _boundingVectors;
  105624. private _creationFunc;
  105625. /**
  105626. * Creates a new block
  105627. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105628. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105629. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105630. * @param depth defines the current depth of this block in the octree
  105631. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105632. * @param creationFunc defines a callback to call when an element is added to the block
  105633. */
  105634. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105635. /**
  105636. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105637. */
  105638. readonly capacity: number;
  105639. /**
  105640. * Gets the minimum vector (in world space) of the block's bounding box
  105641. */
  105642. readonly minPoint: Vector3;
  105643. /**
  105644. * Gets the maximum vector (in world space) of the block's bounding box
  105645. */
  105646. readonly maxPoint: Vector3;
  105647. /**
  105648. * Add a new element to this block
  105649. * @param entry defines the element to add
  105650. */
  105651. addEntry(entry: T): void;
  105652. /**
  105653. * Remove an element from this block
  105654. * @param entry defines the element to remove
  105655. */
  105656. removeEntry(entry: T): void;
  105657. /**
  105658. * Add an array of elements to this block
  105659. * @param entries defines the array of elements to add
  105660. */
  105661. addEntries(entries: T[]): void;
  105662. /**
  105663. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105664. * @param frustumPlanes defines the frustum planes to test
  105665. * @param selection defines the array to store current content if selection is positive
  105666. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105667. */
  105668. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105669. /**
  105670. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105671. * @param sphereCenter defines the bounding sphere center
  105672. * @param sphereRadius defines the bounding sphere radius
  105673. * @param selection defines the array to store current content if selection is positive
  105674. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105675. */
  105676. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105677. /**
  105678. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105679. * @param ray defines the ray to test with
  105680. * @param selection defines the array to store current content if selection is positive
  105681. */
  105682. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105683. /**
  105684. * Subdivide the content into child blocks (this block will then be empty)
  105685. */
  105686. createInnerBlocks(): void;
  105687. /**
  105688. * @hidden
  105689. */
  105690. 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;
  105691. }
  105692. }
  105693. declare module BABYLON {
  105694. /**
  105695. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105696. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105697. */
  105698. export class Octree<T> {
  105699. /** 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.) */
  105700. maxDepth: number;
  105701. /**
  105702. * Blocks within the octree containing objects
  105703. */
  105704. blocks: Array<OctreeBlock<T>>;
  105705. /**
  105706. * Content stored in the octree
  105707. */
  105708. dynamicContent: T[];
  105709. private _maxBlockCapacity;
  105710. private _selectionContent;
  105711. private _creationFunc;
  105712. /**
  105713. * Creates a octree
  105714. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105715. * @param creationFunc function to be used to instatiate the octree
  105716. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105717. * @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.)
  105718. */
  105719. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105720. /** 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.) */
  105721. maxDepth?: number);
  105722. /**
  105723. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105724. * @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);
  105725. * @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);
  105726. * @param entries meshes to be added to the octree blocks
  105727. */
  105728. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105729. /**
  105730. * Adds a mesh to the octree
  105731. * @param entry Mesh to add to the octree
  105732. */
  105733. addMesh(entry: T): void;
  105734. /**
  105735. * Remove an element from the octree
  105736. * @param entry defines the element to remove
  105737. */
  105738. removeMesh(entry: T): void;
  105739. /**
  105740. * Selects an array of meshes within the frustum
  105741. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105742. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105743. * @returns array of meshes within the frustum
  105744. */
  105745. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105746. /**
  105747. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105748. * @param sphereCenter defines the bounding sphere center
  105749. * @param sphereRadius defines the bounding sphere radius
  105750. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105751. * @returns an array of objects that intersect the sphere
  105752. */
  105753. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105754. /**
  105755. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105756. * @param ray defines the ray to test with
  105757. * @returns array of intersected objects
  105758. */
  105759. intersectsRay(ray: Ray): SmartArray<T>;
  105760. /**
  105761. * Adds a mesh into the octree block if it intersects the block
  105762. */
  105763. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105764. /**
  105765. * Adds a submesh into the octree block if it intersects the block
  105766. */
  105767. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. interface Scene {
  105772. /**
  105773. * @hidden
  105774. * Backing Filed
  105775. */
  105776. _selectionOctree: Octree<AbstractMesh>;
  105777. /**
  105778. * Gets the octree used to boost mesh selection (picking)
  105779. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105780. */
  105781. selectionOctree: Octree<AbstractMesh>;
  105782. /**
  105783. * Creates or updates the octree used to boost selection (picking)
  105784. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105785. * @param maxCapacity defines the maximum capacity per leaf
  105786. * @param maxDepth defines the maximum depth of the octree
  105787. * @returns an octree of AbstractMesh
  105788. */
  105789. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105790. }
  105791. interface AbstractMesh {
  105792. /**
  105793. * @hidden
  105794. * Backing Field
  105795. */
  105796. _submeshesOctree: Octree<SubMesh>;
  105797. /**
  105798. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105799. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105800. * @param maxCapacity defines the maximum size of each block (64 by default)
  105801. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105802. * @returns the new octree
  105803. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105804. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105805. */
  105806. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105807. }
  105808. /**
  105809. * Defines the octree scene component responsible to manage any octrees
  105810. * in a given scene.
  105811. */
  105812. export class OctreeSceneComponent {
  105813. /**
  105814. * The component name help to identify the component in the list of scene components.
  105815. */
  105816. readonly name: string;
  105817. /**
  105818. * The scene the component belongs to.
  105819. */
  105820. scene: Scene;
  105821. /**
  105822. * Indicates if the meshes have been checked to make sure they are isEnabled()
  105823. */
  105824. readonly checksIsEnabled: boolean;
  105825. /**
  105826. * Creates a new instance of the component for the given scene
  105827. * @param scene Defines the scene to register the component in
  105828. */
  105829. constructor(scene: Scene);
  105830. /**
  105831. * Registers the component in a given scene
  105832. */
  105833. register(): void;
  105834. /**
  105835. * Return the list of active meshes
  105836. * @returns the list of active meshes
  105837. */
  105838. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105839. /**
  105840. * Return the list of active sub meshes
  105841. * @param mesh The mesh to get the candidates sub meshes from
  105842. * @returns the list of active sub meshes
  105843. */
  105844. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105845. private _tempRay;
  105846. /**
  105847. * Return the list of sub meshes intersecting with a given local ray
  105848. * @param mesh defines the mesh to find the submesh for
  105849. * @param localRay defines the ray in local space
  105850. * @returns the list of intersecting sub meshes
  105851. */
  105852. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  105853. /**
  105854. * Return the list of sub meshes colliding with a collider
  105855. * @param mesh defines the mesh to find the submesh for
  105856. * @param collider defines the collider to evaluate the collision against
  105857. * @returns the list of colliding sub meshes
  105858. */
  105859. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  105860. /**
  105861. * Rebuilds the elements related to this component in case of
  105862. * context lost for instance.
  105863. */
  105864. rebuild(): void;
  105865. /**
  105866. * Disposes the component and the associated ressources.
  105867. */
  105868. dispose(): void;
  105869. }
  105870. }
  105871. declare module BABYLON {
  105872. /**
  105873. * Renders a layer on top of an existing scene
  105874. */
  105875. export class UtilityLayerRenderer implements IDisposable {
  105876. /** the original scene that will be rendered on top of */
  105877. originalScene: Scene;
  105878. private _pointerCaptures;
  105879. private _lastPointerEvents;
  105880. private static _DefaultUtilityLayer;
  105881. private static _DefaultKeepDepthUtilityLayer;
  105882. private _sharedGizmoLight;
  105883. private _renderCamera;
  105884. /**
  105885. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  105886. * @returns the camera that is used when rendering the utility layer
  105887. */
  105888. getRenderCamera(): Nullable<Camera>;
  105889. /**
  105890. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  105891. * @param cam the camera that should be used when rendering the utility layer
  105892. */
  105893. setRenderCamera(cam: Nullable<Camera>): void;
  105894. /**
  105895. * @hidden
  105896. * Light which used by gizmos to get light shading
  105897. */
  105898. _getSharedGizmoLight(): HemisphericLight;
  105899. /**
  105900. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  105901. */
  105902. pickUtilitySceneFirst: boolean;
  105903. /**
  105904. * 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)
  105905. */
  105906. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  105907. /**
  105908. * 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)
  105909. */
  105910. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  105911. /**
  105912. * The scene that is rendered on top of the original scene
  105913. */
  105914. utilityLayerScene: Scene;
  105915. /**
  105916. * If the utility layer should automatically be rendered on top of existing scene
  105917. */
  105918. shouldRender: boolean;
  105919. /**
  105920. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  105921. */
  105922. onlyCheckPointerDownEvents: boolean;
  105923. /**
  105924. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  105925. */
  105926. processAllEvents: boolean;
  105927. /**
  105928. * Observable raised when the pointer move from the utility layer scene to the main scene
  105929. */
  105930. onPointerOutObservable: Observable<number>;
  105931. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  105932. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  105933. private _afterRenderObserver;
  105934. private _sceneDisposeObserver;
  105935. private _originalPointerObserver;
  105936. /**
  105937. * Instantiates a UtilityLayerRenderer
  105938. * @param originalScene the original scene that will be rendered on top of
  105939. * @param handleEvents boolean indicating if the utility layer should handle events
  105940. */
  105941. constructor(
  105942. /** the original scene that will be rendered on top of */
  105943. originalScene: Scene, handleEvents?: boolean);
  105944. private _notifyObservers;
  105945. /**
  105946. * Renders the utility layers scene on top of the original scene
  105947. */
  105948. render(): void;
  105949. /**
  105950. * Disposes of the renderer
  105951. */
  105952. dispose(): void;
  105953. private _updateCamera;
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /**
  105958. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  105959. */
  105960. export class Gizmo implements IDisposable {
  105961. /** The utility layer the gizmo will be added to */
  105962. gizmoLayer: UtilityLayerRenderer;
  105963. /**
  105964. * The root mesh of the gizmo
  105965. */
  105966. _rootMesh: Mesh;
  105967. private _attachedMesh;
  105968. /**
  105969. * Ratio for the scale of the gizmo (Default: 1)
  105970. */
  105971. scaleRatio: number;
  105972. /**
  105973. * If a custom mesh has been set (Default: false)
  105974. */
  105975. protected _customMeshSet: boolean;
  105976. /**
  105977. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  105978. * * When set, interactions will be enabled
  105979. */
  105980. attachedMesh: Nullable<AbstractMesh>;
  105981. /**
  105982. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105983. * @param mesh The mesh to replace the default mesh of the gizmo
  105984. */
  105985. setCustomMesh(mesh: Mesh): void;
  105986. /**
  105987. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  105988. */
  105989. updateGizmoRotationToMatchAttachedMesh: boolean;
  105990. /**
  105991. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  105992. */
  105993. updateGizmoPositionToMatchAttachedMesh: boolean;
  105994. /**
  105995. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  105996. */
  105997. updateScale: boolean;
  105998. protected _interactionsEnabled: boolean;
  105999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106000. private _beforeRenderObserver;
  106001. private _tempVector;
  106002. /**
  106003. * Creates a gizmo
  106004. * @param gizmoLayer The utility layer the gizmo will be added to
  106005. */
  106006. constructor(
  106007. /** The utility layer the gizmo will be added to */
  106008. gizmoLayer?: UtilityLayerRenderer);
  106009. /**
  106010. * Updates the gizmo to match the attached mesh's position/rotation
  106011. */
  106012. protected _update(): void;
  106013. /**
  106014. * Disposes of the gizmo
  106015. */
  106016. dispose(): void;
  106017. }
  106018. }
  106019. declare module BABYLON {
  106020. /**
  106021. * Single plane drag gizmo
  106022. */
  106023. export class PlaneDragGizmo extends Gizmo {
  106024. /**
  106025. * Drag behavior responsible for the gizmos dragging interactions
  106026. */
  106027. dragBehavior: PointerDragBehavior;
  106028. private _pointerObserver;
  106029. /**
  106030. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106031. */
  106032. snapDistance: number;
  106033. /**
  106034. * Event that fires each time the gizmo snaps to a new location.
  106035. * * snapDistance is the the change in distance
  106036. */
  106037. onSnapObservable: Observable<{
  106038. snapDistance: number;
  106039. }>;
  106040. private _plane;
  106041. private _coloredMaterial;
  106042. private _hoverMaterial;
  106043. private _isEnabled;
  106044. private _parent;
  106045. /** @hidden */
  106046. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106047. /** @hidden */
  106048. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106049. /**
  106050. * Creates a PlaneDragGizmo
  106051. * @param gizmoLayer The utility layer the gizmo will be added to
  106052. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106053. * @param color The color of the gizmo
  106054. */
  106055. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106056. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106057. /**
  106058. * If the gizmo is enabled
  106059. */
  106060. isEnabled: boolean;
  106061. /**
  106062. * Disposes of the gizmo
  106063. */
  106064. dispose(): void;
  106065. }
  106066. }
  106067. declare module BABYLON {
  106068. /**
  106069. * Gizmo that enables dragging a mesh along 3 axis
  106070. */
  106071. export class PositionGizmo extends Gizmo {
  106072. /**
  106073. * Internal gizmo used for interactions on the x axis
  106074. */
  106075. xGizmo: AxisDragGizmo;
  106076. /**
  106077. * Internal gizmo used for interactions on the y axis
  106078. */
  106079. yGizmo: AxisDragGizmo;
  106080. /**
  106081. * Internal gizmo used for interactions on the z axis
  106082. */
  106083. zGizmo: AxisDragGizmo;
  106084. /**
  106085. * Internal gizmo used for interactions on the yz plane
  106086. */
  106087. xPlaneGizmo: PlaneDragGizmo;
  106088. /**
  106089. * Internal gizmo used for interactions on the xz plane
  106090. */
  106091. yPlaneGizmo: PlaneDragGizmo;
  106092. /**
  106093. * Internal gizmo used for interactions on the xy plane
  106094. */
  106095. zPlaneGizmo: PlaneDragGizmo;
  106096. /**
  106097. * private variables
  106098. */
  106099. private _meshAttached;
  106100. private _updateGizmoRotationToMatchAttachedMesh;
  106101. private _snapDistance;
  106102. private _scaleRatio;
  106103. /** Fires an event when any of it's sub gizmos are dragged */
  106104. onDragStartObservable: Observable<unknown>;
  106105. /** Fires an event when any of it's sub gizmos are released from dragging */
  106106. onDragEndObservable: Observable<unknown>;
  106107. /**
  106108. * If set to true, planar drag is enabled
  106109. */
  106110. private _planarGizmoEnabled;
  106111. attachedMesh: Nullable<AbstractMesh>;
  106112. /**
  106113. * Creates a PositionGizmo
  106114. * @param gizmoLayer The utility layer the gizmo will be added to
  106115. */
  106116. constructor(gizmoLayer?: UtilityLayerRenderer);
  106117. /**
  106118. * If the planar drag gizmo is enabled
  106119. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106120. */
  106121. planarGizmoEnabled: boolean;
  106122. updateGizmoRotationToMatchAttachedMesh: boolean;
  106123. /**
  106124. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106125. */
  106126. snapDistance: number;
  106127. /**
  106128. * Ratio for the scale of the gizmo (Default: 1)
  106129. */
  106130. scaleRatio: number;
  106131. /**
  106132. * Disposes of the gizmo
  106133. */
  106134. dispose(): void;
  106135. /**
  106136. * CustomMeshes are not supported by this gizmo
  106137. * @param mesh The mesh to replace the default mesh of the gizmo
  106138. */
  106139. setCustomMesh(mesh: Mesh): void;
  106140. }
  106141. }
  106142. declare module BABYLON {
  106143. /**
  106144. * Single axis drag gizmo
  106145. */
  106146. export class AxisDragGizmo extends Gizmo {
  106147. /**
  106148. * Drag behavior responsible for the gizmos dragging interactions
  106149. */
  106150. dragBehavior: PointerDragBehavior;
  106151. private _pointerObserver;
  106152. /**
  106153. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106154. */
  106155. snapDistance: number;
  106156. /**
  106157. * Event that fires each time the gizmo snaps to a new location.
  106158. * * snapDistance is the the change in distance
  106159. */
  106160. onSnapObservable: Observable<{
  106161. snapDistance: number;
  106162. }>;
  106163. private _isEnabled;
  106164. private _parent;
  106165. private _arrow;
  106166. private _coloredMaterial;
  106167. private _hoverMaterial;
  106168. /** @hidden */
  106169. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106170. /** @hidden */
  106171. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106172. /**
  106173. * Creates an AxisDragGizmo
  106174. * @param gizmoLayer The utility layer the gizmo will be added to
  106175. * @param dragAxis The axis which the gizmo will be able to drag on
  106176. * @param color The color of the gizmo
  106177. */
  106178. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106179. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106180. /**
  106181. * If the gizmo is enabled
  106182. */
  106183. isEnabled: boolean;
  106184. /**
  106185. * Disposes of the gizmo
  106186. */
  106187. dispose(): void;
  106188. }
  106189. }
  106190. declare module BABYLON.Debug {
  106191. /**
  106192. * The Axes viewer will show 3 axes in a specific point in space
  106193. */
  106194. export class AxesViewer {
  106195. private _xAxis;
  106196. private _yAxis;
  106197. private _zAxis;
  106198. private _scaleLinesFactor;
  106199. private _instanced;
  106200. /**
  106201. * Gets the hosting scene
  106202. */
  106203. scene: Scene;
  106204. /**
  106205. * Gets or sets a number used to scale line length
  106206. */
  106207. scaleLines: number;
  106208. /** Gets the node hierarchy used to render x-axis */
  106209. readonly xAxis: TransformNode;
  106210. /** Gets the node hierarchy used to render y-axis */
  106211. readonly yAxis: TransformNode;
  106212. /** Gets the node hierarchy used to render z-axis */
  106213. readonly zAxis: TransformNode;
  106214. /**
  106215. * Creates a new AxesViewer
  106216. * @param scene defines the hosting scene
  106217. * @param scaleLines defines a number used to scale line length (1 by default)
  106218. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106219. * @param xAxis defines the node hierarchy used to render the x-axis
  106220. * @param yAxis defines the node hierarchy used to render the y-axis
  106221. * @param zAxis defines the node hierarchy used to render the z-axis
  106222. */
  106223. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106224. /**
  106225. * Force the viewer to update
  106226. * @param position defines the position of the viewer
  106227. * @param xaxis defines the x axis of the viewer
  106228. * @param yaxis defines the y axis of the viewer
  106229. * @param zaxis defines the z axis of the viewer
  106230. */
  106231. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106232. /**
  106233. * Creates an instance of this axes viewer.
  106234. * @returns a new axes viewer with instanced meshes
  106235. */
  106236. createInstance(): AxesViewer;
  106237. /** Releases resources */
  106238. dispose(): void;
  106239. private static _SetRenderingGroupId;
  106240. }
  106241. }
  106242. declare module BABYLON.Debug {
  106243. /**
  106244. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106245. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106246. */
  106247. export class BoneAxesViewer extends AxesViewer {
  106248. /**
  106249. * Gets or sets the target mesh where to display the axes viewer
  106250. */
  106251. mesh: Nullable<Mesh>;
  106252. /**
  106253. * Gets or sets the target bone where to display the axes viewer
  106254. */
  106255. bone: Nullable<Bone>;
  106256. /** Gets current position */
  106257. pos: Vector3;
  106258. /** Gets direction of X axis */
  106259. xaxis: Vector3;
  106260. /** Gets direction of Y axis */
  106261. yaxis: Vector3;
  106262. /** Gets direction of Z axis */
  106263. zaxis: Vector3;
  106264. /**
  106265. * Creates a new BoneAxesViewer
  106266. * @param scene defines the hosting scene
  106267. * @param bone defines the target bone
  106268. * @param mesh defines the target mesh
  106269. * @param scaleLines defines a scaling factor for line length (1 by default)
  106270. */
  106271. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106272. /**
  106273. * Force the viewer to update
  106274. */
  106275. update(): void;
  106276. /** Releases resources */
  106277. dispose(): void;
  106278. }
  106279. }
  106280. declare module BABYLON {
  106281. /**
  106282. * Interface used to define scene explorer extensibility option
  106283. */
  106284. export interface IExplorerExtensibilityOption {
  106285. /**
  106286. * Define the option label
  106287. */
  106288. label: string;
  106289. /**
  106290. * Defines the action to execute on click
  106291. */
  106292. action: (entity: any) => void;
  106293. }
  106294. /**
  106295. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106296. */
  106297. export interface IExplorerExtensibilityGroup {
  106298. /**
  106299. * Defines a predicate to test if a given type mut be extended
  106300. */
  106301. predicate: (entity: any) => boolean;
  106302. /**
  106303. * Gets the list of options added to a type
  106304. */
  106305. entries: IExplorerExtensibilityOption[];
  106306. }
  106307. /**
  106308. * Interface used to define the options to use to create the Inspector
  106309. */
  106310. export interface IInspectorOptions {
  106311. /**
  106312. * Display in overlay mode (default: false)
  106313. */
  106314. overlay?: boolean;
  106315. /**
  106316. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106317. */
  106318. globalRoot?: HTMLElement;
  106319. /**
  106320. * Display the Scene explorer
  106321. */
  106322. showExplorer?: boolean;
  106323. /**
  106324. * Display the property inspector
  106325. */
  106326. showInspector?: boolean;
  106327. /**
  106328. * Display in embed mode (both panes on the right)
  106329. */
  106330. embedMode?: boolean;
  106331. /**
  106332. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106333. */
  106334. handleResize?: boolean;
  106335. /**
  106336. * Allow the panes to popup (default: true)
  106337. */
  106338. enablePopup?: boolean;
  106339. /**
  106340. * Allow the panes to be closed by users (default: true)
  106341. */
  106342. enableClose?: boolean;
  106343. /**
  106344. * Optional list of extensibility entries
  106345. */
  106346. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106347. /**
  106348. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106349. */
  106350. inspectorURL?: string;
  106351. }
  106352. interface Scene {
  106353. /**
  106354. * @hidden
  106355. * Backing field
  106356. */
  106357. _debugLayer: DebugLayer;
  106358. /**
  106359. * Gets the debug layer (aka Inspector) associated with the scene
  106360. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106361. */
  106362. debugLayer: DebugLayer;
  106363. }
  106364. /**
  106365. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106366. * what is happening in your scene
  106367. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106368. */
  106369. export class DebugLayer {
  106370. /**
  106371. * Define the url to get the inspector script from.
  106372. * By default it uses the babylonjs CDN.
  106373. * @ignoreNaming
  106374. */
  106375. static InspectorURL: string;
  106376. private _scene;
  106377. private BJSINSPECTOR;
  106378. private _onPropertyChangedObservable?;
  106379. /**
  106380. * Observable triggered when a property is changed through the inspector.
  106381. */
  106382. readonly onPropertyChangedObservable: any;
  106383. /**
  106384. * Instantiates a new debug layer.
  106385. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106386. * what is happening in your scene
  106387. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106388. * @param scene Defines the scene to inspect
  106389. */
  106390. constructor(scene: Scene);
  106391. /** Creates the inspector window. */
  106392. private _createInspector;
  106393. /**
  106394. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106395. * @param entity defines the entity to select
  106396. * @param lineContainerTitle defines the specific block to highlight
  106397. */
  106398. select(entity: any, lineContainerTitle?: string): void;
  106399. /** Get the inspector from bundle or global */
  106400. private _getGlobalInspector;
  106401. /**
  106402. * Get if the inspector is visible or not.
  106403. * @returns true if visible otherwise, false
  106404. */
  106405. isVisible(): boolean;
  106406. /**
  106407. * Hide the inspector and close its window.
  106408. */
  106409. hide(): void;
  106410. /**
  106411. * Launch the debugLayer.
  106412. * @param config Define the configuration of the inspector
  106413. * @return a promise fulfilled when the debug layer is visible
  106414. */
  106415. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106416. }
  106417. }
  106418. declare module BABYLON {
  106419. /**
  106420. * Class containing static functions to help procedurally build meshes
  106421. */
  106422. export class BoxBuilder {
  106423. /**
  106424. * Creates a box mesh
  106425. * * The parameter `size` sets the size (float) of each box side (default 1)
  106426. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106427. * * 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)
  106428. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106432. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106433. * @param name defines the name of the mesh
  106434. * @param options defines the options used to create the mesh
  106435. * @param scene defines the hosting scene
  106436. * @returns the box mesh
  106437. */
  106438. static CreateBox(name: string, options: {
  106439. size?: number;
  106440. width?: number;
  106441. height?: number;
  106442. depth?: number;
  106443. faceUV?: Vector4[];
  106444. faceColors?: Color4[];
  106445. sideOrientation?: number;
  106446. frontUVs?: Vector4;
  106447. backUVs?: Vector4;
  106448. wrap?: boolean;
  106449. topBaseAt?: number;
  106450. bottomBaseAt?: number;
  106451. updatable?: boolean;
  106452. }, scene?: Nullable<Scene>): Mesh;
  106453. }
  106454. }
  106455. declare module BABYLON {
  106456. /**
  106457. * Class containing static functions to help procedurally build meshes
  106458. */
  106459. export class SphereBuilder {
  106460. /**
  106461. * Creates a sphere mesh
  106462. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106463. * * 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`)
  106464. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106465. * * 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
  106466. * * 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)
  106467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106470. * @param name defines the name of the mesh
  106471. * @param options defines the options used to create the mesh
  106472. * @param scene defines the hosting scene
  106473. * @returns the sphere mesh
  106474. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106475. */
  106476. static CreateSphere(name: string, options: {
  106477. segments?: number;
  106478. diameter?: number;
  106479. diameterX?: number;
  106480. diameterY?: number;
  106481. diameterZ?: number;
  106482. arc?: number;
  106483. slice?: number;
  106484. sideOrientation?: number;
  106485. frontUVs?: Vector4;
  106486. backUVs?: Vector4;
  106487. updatable?: boolean;
  106488. }, scene: any): Mesh;
  106489. }
  106490. }
  106491. declare module BABYLON.Debug {
  106492. /**
  106493. * Used to show the physics impostor around the specific mesh
  106494. */
  106495. export class PhysicsViewer {
  106496. /** @hidden */
  106497. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106498. /** @hidden */
  106499. protected _meshes: Array<Nullable<AbstractMesh>>;
  106500. /** @hidden */
  106501. protected _scene: Nullable<Scene>;
  106502. /** @hidden */
  106503. protected _numMeshes: number;
  106504. /** @hidden */
  106505. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106506. private _renderFunction;
  106507. private _utilityLayer;
  106508. private _debugBoxMesh;
  106509. private _debugSphereMesh;
  106510. private _debugCylinderMesh;
  106511. private _debugMaterial;
  106512. private _debugMeshMeshes;
  106513. /**
  106514. * Creates a new PhysicsViewer
  106515. * @param scene defines the hosting scene
  106516. */
  106517. constructor(scene: Scene);
  106518. /** @hidden */
  106519. protected _updateDebugMeshes(): void;
  106520. /**
  106521. * Renders a specified physic impostor
  106522. * @param impostor defines the impostor to render
  106523. * @param targetMesh defines the mesh represented by the impostor
  106524. * @returns the new debug mesh used to render the impostor
  106525. */
  106526. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106527. /**
  106528. * Hides a specified physic impostor
  106529. * @param impostor defines the impostor to hide
  106530. */
  106531. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106532. private _getDebugMaterial;
  106533. private _getDebugBoxMesh;
  106534. private _getDebugSphereMesh;
  106535. private _getDebugCylinderMesh;
  106536. private _getDebugMeshMesh;
  106537. private _getDebugMesh;
  106538. /** Releases all resources */
  106539. dispose(): void;
  106540. }
  106541. }
  106542. declare module BABYLON {
  106543. /**
  106544. * Class containing static functions to help procedurally build meshes
  106545. */
  106546. export class LinesBuilder {
  106547. /**
  106548. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106549. * * 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
  106550. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106551. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106552. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106553. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106554. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106555. * * 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
  106556. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106558. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106559. * @param name defines the name of the new line system
  106560. * @param options defines the options used to create the line system
  106561. * @param scene defines the hosting scene
  106562. * @returns a new line system mesh
  106563. */
  106564. static CreateLineSystem(name: string, options: {
  106565. lines: Vector3[][];
  106566. updatable?: boolean;
  106567. instance?: Nullable<LinesMesh>;
  106568. colors?: Nullable<Color4[][]>;
  106569. useVertexAlpha?: boolean;
  106570. }, scene: Nullable<Scene>): LinesMesh;
  106571. /**
  106572. * Creates a line mesh
  106573. * 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
  106574. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106575. * * The parameter `points` is an array successive Vector3
  106576. * * 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
  106577. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106578. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106579. * * When updating an instance, remember that only point positions can change, not the number of points
  106580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106581. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106582. * @param name defines the name of the new line system
  106583. * @param options defines the options used to create the line system
  106584. * @param scene defines the hosting scene
  106585. * @returns a new line mesh
  106586. */
  106587. static CreateLines(name: string, options: {
  106588. points: Vector3[];
  106589. updatable?: boolean;
  106590. instance?: Nullable<LinesMesh>;
  106591. colors?: Color4[];
  106592. useVertexAlpha?: boolean;
  106593. }, scene?: Nullable<Scene>): LinesMesh;
  106594. /**
  106595. * Creates a dashed line mesh
  106596. * * 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
  106597. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106598. * * The parameter `points` is an array successive Vector3
  106599. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106600. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106601. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106602. * * 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
  106603. * * When updating an instance, remember that only point positions can change, not the number of points
  106604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106605. * @param name defines the name of the mesh
  106606. * @param options defines the options used to create the mesh
  106607. * @param scene defines the hosting scene
  106608. * @returns the dashed line mesh
  106609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106610. */
  106611. static CreateDashedLines(name: string, options: {
  106612. points: Vector3[];
  106613. dashSize?: number;
  106614. gapSize?: number;
  106615. dashNb?: number;
  106616. updatable?: boolean;
  106617. instance?: LinesMesh;
  106618. }, scene?: Nullable<Scene>): LinesMesh;
  106619. }
  106620. }
  106621. declare module BABYLON {
  106622. /**
  106623. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106624. * in order to better appreciate the issue one might have.
  106625. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106626. */
  106627. export class RayHelper {
  106628. /**
  106629. * Defines the ray we are currently tryin to visualize.
  106630. */
  106631. ray: Nullable<Ray>;
  106632. private _renderPoints;
  106633. private _renderLine;
  106634. private _renderFunction;
  106635. private _scene;
  106636. private _updateToMeshFunction;
  106637. private _attachedToMesh;
  106638. private _meshSpaceDirection;
  106639. private _meshSpaceOrigin;
  106640. /**
  106641. * Helper function to create a colored helper in a scene in one line.
  106642. * @param ray Defines the ray we are currently tryin to visualize
  106643. * @param scene Defines the scene the ray is used in
  106644. * @param color Defines the color we want to see the ray in
  106645. * @returns The newly created ray helper.
  106646. */
  106647. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106648. /**
  106649. * Instantiate a new ray helper.
  106650. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106651. * in order to better appreciate the issue one might have.
  106652. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106653. * @param ray Defines the ray we are currently tryin to visualize
  106654. */
  106655. constructor(ray: Ray);
  106656. /**
  106657. * Shows the ray we are willing to debug.
  106658. * @param scene Defines the scene the ray needs to be rendered in
  106659. * @param color Defines the color the ray needs to be rendered in
  106660. */
  106661. show(scene: Scene, color?: Color3): void;
  106662. /**
  106663. * Hides the ray we are debugging.
  106664. */
  106665. hide(): void;
  106666. private _render;
  106667. /**
  106668. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106669. * @param mesh Defines the mesh we want the helper attached to
  106670. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106671. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106672. * @param length Defines the length of the ray
  106673. */
  106674. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106675. /**
  106676. * Detach the ray helper from the mesh it has previously been attached to.
  106677. */
  106678. detachFromMesh(): void;
  106679. private _updateToMesh;
  106680. /**
  106681. * Dispose the helper and release its associated resources.
  106682. */
  106683. dispose(): void;
  106684. }
  106685. }
  106686. declare module BABYLON.Debug {
  106687. /**
  106688. * Class used to render a debug view of a given skeleton
  106689. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106690. */
  106691. export class SkeletonViewer {
  106692. /** defines the skeleton to render */
  106693. skeleton: Skeleton;
  106694. /** defines the mesh attached to the skeleton */
  106695. mesh: AbstractMesh;
  106696. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106697. autoUpdateBonesMatrices: boolean;
  106698. /** defines the rendering group id to use with the viewer */
  106699. renderingGroupId: number;
  106700. /** Gets or sets the color used to render the skeleton */
  106701. color: Color3;
  106702. private _scene;
  106703. private _debugLines;
  106704. private _debugMesh;
  106705. private _isEnabled;
  106706. private _renderFunction;
  106707. private _utilityLayer;
  106708. /**
  106709. * Returns the mesh used to render the bones
  106710. */
  106711. readonly debugMesh: Nullable<LinesMesh>;
  106712. /**
  106713. * Creates a new SkeletonViewer
  106714. * @param skeleton defines the skeleton to render
  106715. * @param mesh defines the mesh attached to the skeleton
  106716. * @param scene defines the hosting scene
  106717. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106718. * @param renderingGroupId defines the rendering group id to use with the viewer
  106719. */
  106720. constructor(
  106721. /** defines the skeleton to render */
  106722. skeleton: Skeleton,
  106723. /** defines the mesh attached to the skeleton */
  106724. mesh: AbstractMesh, scene: Scene,
  106725. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106726. autoUpdateBonesMatrices?: boolean,
  106727. /** defines the rendering group id to use with the viewer */
  106728. renderingGroupId?: number);
  106729. /** Gets or sets a boolean indicating if the viewer is enabled */
  106730. isEnabled: boolean;
  106731. private _getBonePosition;
  106732. private _getLinesForBonesWithLength;
  106733. private _getLinesForBonesNoLength;
  106734. /** Update the viewer to sync with current skeleton state */
  106735. update(): void;
  106736. /** Release associated resources */
  106737. dispose(): void;
  106738. }
  106739. }
  106740. declare module BABYLON {
  106741. /**
  106742. * Options to create the null engine
  106743. */
  106744. export class NullEngineOptions {
  106745. /**
  106746. * Render width (Default: 512)
  106747. */
  106748. renderWidth: number;
  106749. /**
  106750. * Render height (Default: 256)
  106751. */
  106752. renderHeight: number;
  106753. /**
  106754. * Texture size (Default: 512)
  106755. */
  106756. textureSize: number;
  106757. /**
  106758. * If delta time between frames should be constant
  106759. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106760. */
  106761. deterministicLockstep: boolean;
  106762. /**
  106763. * Maximum about of steps between frames (Default: 4)
  106764. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106765. */
  106766. lockstepMaxSteps: number;
  106767. }
  106768. /**
  106769. * The null engine class provides support for headless version of babylon.js.
  106770. * This can be used in server side scenario or for testing purposes
  106771. */
  106772. export class NullEngine extends Engine {
  106773. private _options;
  106774. /**
  106775. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106776. */
  106777. isDeterministicLockStep(): boolean;
  106778. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106779. getLockstepMaxSteps(): number;
  106780. /**
  106781. * Sets hardware scaling, used to save performance if needed
  106782. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106783. */
  106784. getHardwareScalingLevel(): number;
  106785. constructor(options?: NullEngineOptions);
  106786. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106787. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106788. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106789. getRenderWidth(useScreen?: boolean): number;
  106790. getRenderHeight(useScreen?: boolean): number;
  106791. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106792. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106793. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106794. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106795. bindSamplers(effect: Effect): void;
  106796. enableEffect(effect: Effect): void;
  106797. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106798. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106799. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106800. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106801. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106802. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106803. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106804. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106805. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106806. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106807. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106808. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106809. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106810. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  106811. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106812. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106813. setFloat(uniform: WebGLUniformLocation, value: number): void;
  106814. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  106815. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  106816. setBool(uniform: WebGLUniformLocation, bool: number): void;
  106817. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  106818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106819. bindBuffers(vertexBuffers: {
  106820. [key: string]: VertexBuffer;
  106821. }, indexBuffer: DataBuffer, effect: Effect): void;
  106822. wipeCaches(bruteForce?: boolean): void;
  106823. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106824. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106826. /** @hidden */
  106827. _createTexture(): WebGLTexture;
  106828. /** @hidden */
  106829. _releaseTexture(texture: InternalTexture): void;
  106830. 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;
  106831. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  106832. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  106833. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  106834. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106835. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  106836. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  106837. areAllEffectsReady(): boolean;
  106838. /**
  106839. * @hidden
  106840. * Get the current error code of the webGL context
  106841. * @returns the error code
  106842. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106843. */
  106844. getError(): number;
  106845. /** @hidden */
  106846. _getUnpackAlignement(): number;
  106847. /** @hidden */
  106848. _unpackFlipY(value: boolean): void;
  106849. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  106850. /**
  106851. * Updates a dynamic vertex buffer.
  106852. * @param vertexBuffer the vertex buffer to update
  106853. * @param data the data used to update the vertex buffer
  106854. * @param byteOffset the byte offset of the data (optional)
  106855. * @param byteLength the byte length of the data (optional)
  106856. */
  106857. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  106858. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  106859. /** @hidden */
  106860. _bindTexture(channel: number, texture: InternalTexture): void;
  106861. /** @hidden */
  106862. _releaseBuffer(buffer: DataBuffer): boolean;
  106863. releaseEffects(): void;
  106864. displayLoadingUI(): void;
  106865. hideLoadingUI(): void;
  106866. /** @hidden */
  106867. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106868. /** @hidden */
  106869. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106870. /** @hidden */
  106871. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106872. /** @hidden */
  106873. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  106874. }
  106875. }
  106876. declare module BABYLON {
  106877. /** @hidden */
  106878. export class _OcclusionDataStorage {
  106879. /** @hidden */
  106880. occlusionInternalRetryCounter: number;
  106881. /** @hidden */
  106882. isOcclusionQueryInProgress: boolean;
  106883. /** @hidden */
  106884. isOccluded: boolean;
  106885. /** @hidden */
  106886. occlusionRetryCount: number;
  106887. /** @hidden */
  106888. occlusionType: number;
  106889. /** @hidden */
  106890. occlusionQueryAlgorithmType: number;
  106891. }
  106892. interface Engine {
  106893. /**
  106894. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  106895. * @return the new query
  106896. */
  106897. createQuery(): WebGLQuery;
  106898. /**
  106899. * Delete and release a webGL query
  106900. * @param query defines the query to delete
  106901. * @return the current engine
  106902. */
  106903. deleteQuery(query: WebGLQuery): Engine;
  106904. /**
  106905. * Check if a given query has resolved and got its value
  106906. * @param query defines the query to check
  106907. * @returns true if the query got its value
  106908. */
  106909. isQueryResultAvailable(query: WebGLQuery): boolean;
  106910. /**
  106911. * Gets the value of a given query
  106912. * @param query defines the query to check
  106913. * @returns the value of the query
  106914. */
  106915. getQueryResult(query: WebGLQuery): number;
  106916. /**
  106917. * Initiates an occlusion query
  106918. * @param algorithmType defines the algorithm to use
  106919. * @param query defines the query to use
  106920. * @returns the current engine
  106921. * @see http://doc.babylonjs.com/features/occlusionquery
  106922. */
  106923. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  106924. /**
  106925. * Ends an occlusion query
  106926. * @see http://doc.babylonjs.com/features/occlusionquery
  106927. * @param algorithmType defines the algorithm to use
  106928. * @returns the current engine
  106929. */
  106930. endOcclusionQuery(algorithmType: number): Engine;
  106931. /**
  106932. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  106933. * Please note that only one query can be issued at a time
  106934. * @returns a time token used to track the time span
  106935. */
  106936. startTimeQuery(): Nullable<_TimeToken>;
  106937. /**
  106938. * Ends a time query
  106939. * @param token defines the token used to measure the time span
  106940. * @returns the time spent (in ns)
  106941. */
  106942. endTimeQuery(token: _TimeToken): int;
  106943. /** @hidden */
  106944. _currentNonTimestampToken: Nullable<_TimeToken>;
  106945. /** @hidden */
  106946. _createTimeQuery(): WebGLQuery;
  106947. /** @hidden */
  106948. _deleteTimeQuery(query: WebGLQuery): void;
  106949. /** @hidden */
  106950. _getGlAlgorithmType(algorithmType: number): number;
  106951. /** @hidden */
  106952. _getTimeQueryResult(query: WebGLQuery): any;
  106953. /** @hidden */
  106954. _getTimeQueryAvailability(query: WebGLQuery): any;
  106955. }
  106956. interface AbstractMesh {
  106957. /**
  106958. * Backing filed
  106959. * @hidden
  106960. */
  106961. __occlusionDataStorage: _OcclusionDataStorage;
  106962. /**
  106963. * Access property
  106964. * @hidden
  106965. */
  106966. _occlusionDataStorage: _OcclusionDataStorage;
  106967. /**
  106968. * 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.
  106969. * The default value is -1 which means don't break the query and wait till the result
  106970. * @see http://doc.babylonjs.com/features/occlusionquery
  106971. */
  106972. occlusionRetryCount: number;
  106973. /**
  106974. * 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:
  106975. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  106976. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  106977. * * 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.
  106978. * @see http://doc.babylonjs.com/features/occlusionquery
  106979. */
  106980. occlusionType: number;
  106981. /**
  106982. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  106983. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  106984. * * 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.
  106985. * @see http://doc.babylonjs.com/features/occlusionquery
  106986. */
  106987. occlusionQueryAlgorithmType: number;
  106988. /**
  106989. * 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
  106990. * @see http://doc.babylonjs.com/features/occlusionquery
  106991. */
  106992. isOccluded: boolean;
  106993. /**
  106994. * Flag to check the progress status of the query
  106995. * @see http://doc.babylonjs.com/features/occlusionquery
  106996. */
  106997. isOcclusionQueryInProgress: boolean;
  106998. }
  106999. }
  107000. declare module BABYLON {
  107001. /** @hidden */
  107002. export var _forceTransformFeedbackToBundle: boolean;
  107003. interface Engine {
  107004. /**
  107005. * Creates a webGL transform feedback object
  107006. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  107007. * @returns the webGL transform feedback object
  107008. */
  107009. createTransformFeedback(): WebGLTransformFeedback;
  107010. /**
  107011. * Delete a webGL transform feedback object
  107012. * @param value defines the webGL transform feedback object to delete
  107013. */
  107014. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  107015. /**
  107016. * Bind a webGL transform feedback object to the webgl context
  107017. * @param value defines the webGL transform feedback object to bind
  107018. */
  107019. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  107020. /**
  107021. * Begins a transform feedback operation
  107022. * @param usePoints defines if points or triangles must be used
  107023. */
  107024. beginTransformFeedback(usePoints: boolean): void;
  107025. /**
  107026. * Ends a transform feedback operation
  107027. */
  107028. endTransformFeedback(): void;
  107029. /**
  107030. * Specify the varyings to use with transform feedback
  107031. * @param program defines the associated webGL program
  107032. * @param value defines the list of strings representing the varying names
  107033. */
  107034. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107035. /**
  107036. * Bind a webGL buffer for a transform feedback operation
  107037. * @param value defines the webGL buffer to bind
  107038. */
  107039. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107040. }
  107041. }
  107042. declare module BABYLON {
  107043. /**
  107044. * Creation options of the multi render target texture.
  107045. */
  107046. export interface IMultiRenderTargetOptions {
  107047. /**
  107048. * Define if the texture needs to create mip maps after render.
  107049. */
  107050. generateMipMaps?: boolean;
  107051. /**
  107052. * Define the types of all the draw buffers we want to create
  107053. */
  107054. types?: number[];
  107055. /**
  107056. * Define the sampling modes of all the draw buffers we want to create
  107057. */
  107058. samplingModes?: number[];
  107059. /**
  107060. * Define if a depth buffer is required
  107061. */
  107062. generateDepthBuffer?: boolean;
  107063. /**
  107064. * Define if a stencil buffer is required
  107065. */
  107066. generateStencilBuffer?: boolean;
  107067. /**
  107068. * Define if a depth texture is required instead of a depth buffer
  107069. */
  107070. generateDepthTexture?: boolean;
  107071. /**
  107072. * Define the number of desired draw buffers
  107073. */
  107074. textureCount?: number;
  107075. /**
  107076. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107077. */
  107078. doNotChangeAspectRatio?: boolean;
  107079. /**
  107080. * Define the default type of the buffers we are creating
  107081. */
  107082. defaultType?: number;
  107083. }
  107084. /**
  107085. * A multi render target, like a render target provides the ability to render to a texture.
  107086. * Unlike the render target, it can render to several draw buffers in one draw.
  107087. * This is specially interesting in deferred rendering or for any effects requiring more than
  107088. * just one color from a single pass.
  107089. */
  107090. export class MultiRenderTarget extends RenderTargetTexture {
  107091. private _internalTextures;
  107092. private _textures;
  107093. private _multiRenderTargetOptions;
  107094. /**
  107095. * Get if draw buffers are currently supported by the used hardware and browser.
  107096. */
  107097. readonly isSupported: boolean;
  107098. /**
  107099. * Get the list of textures generated by the multi render target.
  107100. */
  107101. readonly textures: Texture[];
  107102. /**
  107103. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107104. */
  107105. readonly depthTexture: Texture;
  107106. /**
  107107. * Set the wrapping mode on U of all the textures we are rendering to.
  107108. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107109. */
  107110. wrapU: number;
  107111. /**
  107112. * Set the wrapping mode on V of all the textures we are rendering to.
  107113. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107114. */
  107115. wrapV: number;
  107116. /**
  107117. * Instantiate a new multi render target texture.
  107118. * A multi render target, like a render target provides the ability to render to a texture.
  107119. * Unlike the render target, it can render to several draw buffers in one draw.
  107120. * This is specially interesting in deferred rendering or for any effects requiring more than
  107121. * just one color from a single pass.
  107122. * @param name Define the name of the texture
  107123. * @param size Define the size of the buffers to render to
  107124. * @param count Define the number of target we are rendering into
  107125. * @param scene Define the scene the texture belongs to
  107126. * @param options Define the options used to create the multi render target
  107127. */
  107128. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107129. /** @hidden */
  107130. _rebuild(): void;
  107131. private _createInternalTextures;
  107132. private _createTextures;
  107133. /**
  107134. * Define the number of samples used if MSAA is enabled.
  107135. */
  107136. samples: number;
  107137. /**
  107138. * Resize all the textures in the multi render target.
  107139. * Be carrefull as it will recreate all the data in the new texture.
  107140. * @param size Define the new size
  107141. */
  107142. resize(size: any): void;
  107143. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107144. /**
  107145. * Dispose the render targets and their associated resources
  107146. */
  107147. dispose(): void;
  107148. /**
  107149. * Release all the underlying texture used as draw buffers.
  107150. */
  107151. releaseInternalTextures(): void;
  107152. }
  107153. }
  107154. declare module BABYLON {
  107155. interface Engine {
  107156. /**
  107157. * Unbind a list of render target textures from the webGL context
  107158. * This is used only when drawBuffer extension or webGL2 are active
  107159. * @param textures defines the render target textures to unbind
  107160. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107161. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107162. */
  107163. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107164. /**
  107165. * Create a multi render target texture
  107166. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107167. * @param size defines the size of the texture
  107168. * @param options defines the creation options
  107169. * @returns the cube texture as an InternalTexture
  107170. */
  107171. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107172. /**
  107173. * Update the sample count for a given multiple render target texture
  107174. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107175. * @param textures defines the textures to update
  107176. * @param samples defines the sample count to set
  107177. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107178. */
  107179. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107180. }
  107181. }
  107182. declare module BABYLON {
  107183. /**
  107184. * Gather the list of clipboard event types as constants.
  107185. */
  107186. export class ClipboardEventTypes {
  107187. /**
  107188. * The clipboard event is fired when a copy command is active (pressed).
  107189. */
  107190. static readonly COPY: number;
  107191. /**
  107192. * The clipboard event is fired when a cut command is active (pressed).
  107193. */
  107194. static readonly CUT: number;
  107195. /**
  107196. * The clipboard event is fired when a paste command is active (pressed).
  107197. */
  107198. static readonly PASTE: number;
  107199. }
  107200. /**
  107201. * This class is used to store clipboard related info for the onClipboardObservable event.
  107202. */
  107203. export class ClipboardInfo {
  107204. /**
  107205. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107206. */
  107207. type: number;
  107208. /**
  107209. * Defines the related dom event
  107210. */
  107211. event: ClipboardEvent;
  107212. /**
  107213. *Creates an instance of ClipboardInfo.
  107214. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107215. * @param event Defines the related dom event
  107216. */
  107217. constructor(
  107218. /**
  107219. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107220. */
  107221. type: number,
  107222. /**
  107223. * Defines the related dom event
  107224. */
  107225. event: ClipboardEvent);
  107226. /**
  107227. * Get the clipboard event's type from the keycode.
  107228. * @param keyCode Defines the keyCode for the current keyboard event.
  107229. * @return {number}
  107230. */
  107231. static GetTypeFromCharacter(keyCode: number): number;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * Google Daydream controller
  107237. */
  107238. export class DaydreamController extends WebVRController {
  107239. /**
  107240. * Base Url for the controller model.
  107241. */
  107242. static MODEL_BASE_URL: string;
  107243. /**
  107244. * File name for the controller model.
  107245. */
  107246. static MODEL_FILENAME: string;
  107247. /**
  107248. * Gamepad Id prefix used to identify Daydream Controller.
  107249. */
  107250. static readonly GAMEPAD_ID_PREFIX: string;
  107251. /**
  107252. * Creates a new DaydreamController from a gamepad
  107253. * @param vrGamepad the gamepad that the controller should be created from
  107254. */
  107255. constructor(vrGamepad: any);
  107256. /**
  107257. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107258. * @param scene scene in which to add meshes
  107259. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107260. */
  107261. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107262. /**
  107263. * Called once for each button that changed state since the last frame
  107264. * @param buttonIdx Which button index changed
  107265. * @param state New state of the button
  107266. * @param changes Which properties on the state changed since last frame
  107267. */
  107268. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107269. }
  107270. }
  107271. declare module BABYLON {
  107272. /**
  107273. * Gear VR Controller
  107274. */
  107275. export class GearVRController extends WebVRController {
  107276. /**
  107277. * Base Url for the controller model.
  107278. */
  107279. static MODEL_BASE_URL: string;
  107280. /**
  107281. * File name for the controller model.
  107282. */
  107283. static MODEL_FILENAME: string;
  107284. /**
  107285. * Gamepad Id prefix used to identify this controller.
  107286. */
  107287. static readonly GAMEPAD_ID_PREFIX: string;
  107288. private readonly _buttonIndexToObservableNameMap;
  107289. /**
  107290. * Creates a new GearVRController from a gamepad
  107291. * @param vrGamepad the gamepad that the controller should be created from
  107292. */
  107293. constructor(vrGamepad: any);
  107294. /**
  107295. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107296. * @param scene scene in which to add meshes
  107297. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107298. */
  107299. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107300. /**
  107301. * Called once for each button that changed state since the last frame
  107302. * @param buttonIdx Which button index changed
  107303. * @param state New state of the button
  107304. * @param changes Which properties on the state changed since last frame
  107305. */
  107306. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107307. }
  107308. }
  107309. declare module BABYLON {
  107310. /**
  107311. * Class containing static functions to help procedurally build meshes
  107312. */
  107313. export class PolyhedronBuilder {
  107314. /**
  107315. * Creates a polyhedron mesh
  107316. * * 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
  107317. * * The parameter `size` (positive float, default 1) sets the polygon size
  107318. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107319. * * 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`
  107320. * * 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
  107321. * * 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)`)
  107322. * * 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
  107323. * * 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
  107324. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107325. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107327. * @param name defines the name of the mesh
  107328. * @param options defines the options used to create the mesh
  107329. * @param scene defines the hosting scene
  107330. * @returns the polyhedron mesh
  107331. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107332. */
  107333. static CreatePolyhedron(name: string, options: {
  107334. type?: number;
  107335. size?: number;
  107336. sizeX?: number;
  107337. sizeY?: number;
  107338. sizeZ?: number;
  107339. custom?: any;
  107340. faceUV?: Vector4[];
  107341. faceColors?: Color4[];
  107342. flat?: boolean;
  107343. updatable?: boolean;
  107344. sideOrientation?: number;
  107345. frontUVs?: Vector4;
  107346. backUVs?: Vector4;
  107347. }, scene?: Nullable<Scene>): Mesh;
  107348. }
  107349. }
  107350. declare module BABYLON {
  107351. /**
  107352. * Gizmo that enables scaling a mesh along 3 axis
  107353. */
  107354. export class ScaleGizmo extends Gizmo {
  107355. /**
  107356. * Internal gizmo used for interactions on the x axis
  107357. */
  107358. xGizmo: AxisScaleGizmo;
  107359. /**
  107360. * Internal gizmo used for interactions on the y axis
  107361. */
  107362. yGizmo: AxisScaleGizmo;
  107363. /**
  107364. * Internal gizmo used for interactions on the z axis
  107365. */
  107366. zGizmo: AxisScaleGizmo;
  107367. /**
  107368. * Internal gizmo used to scale all axis equally
  107369. */
  107370. uniformScaleGizmo: AxisScaleGizmo;
  107371. private _meshAttached;
  107372. private _updateGizmoRotationToMatchAttachedMesh;
  107373. private _snapDistance;
  107374. private _scaleRatio;
  107375. private _uniformScalingMesh;
  107376. private _octahedron;
  107377. /** Fires an event when any of it's sub gizmos are dragged */
  107378. onDragStartObservable: Observable<unknown>;
  107379. /** Fires an event when any of it's sub gizmos are released from dragging */
  107380. onDragEndObservable: Observable<unknown>;
  107381. attachedMesh: Nullable<AbstractMesh>;
  107382. /**
  107383. * Creates a ScaleGizmo
  107384. * @param gizmoLayer The utility layer the gizmo will be added to
  107385. */
  107386. constructor(gizmoLayer?: UtilityLayerRenderer);
  107387. updateGizmoRotationToMatchAttachedMesh: boolean;
  107388. /**
  107389. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107390. */
  107391. snapDistance: number;
  107392. /**
  107393. * Ratio for the scale of the gizmo (Default: 1)
  107394. */
  107395. scaleRatio: number;
  107396. /**
  107397. * Disposes of the gizmo
  107398. */
  107399. dispose(): void;
  107400. }
  107401. }
  107402. declare module BABYLON {
  107403. /**
  107404. * Single axis scale gizmo
  107405. */
  107406. export class AxisScaleGizmo extends Gizmo {
  107407. /**
  107408. * Drag behavior responsible for the gizmos dragging interactions
  107409. */
  107410. dragBehavior: PointerDragBehavior;
  107411. private _pointerObserver;
  107412. /**
  107413. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107414. */
  107415. snapDistance: number;
  107416. /**
  107417. * Event that fires each time the gizmo snaps to a new location.
  107418. * * snapDistance is the the change in distance
  107419. */
  107420. onSnapObservable: Observable<{
  107421. snapDistance: number;
  107422. }>;
  107423. /**
  107424. * If the scaling operation should be done on all axis (default: false)
  107425. */
  107426. uniformScaling: boolean;
  107427. private _isEnabled;
  107428. private _parent;
  107429. private _arrow;
  107430. private _coloredMaterial;
  107431. private _hoverMaterial;
  107432. /**
  107433. * Creates an AxisScaleGizmo
  107434. * @param gizmoLayer The utility layer the gizmo will be added to
  107435. * @param dragAxis The axis which the gizmo will be able to scale on
  107436. * @param color The color of the gizmo
  107437. */
  107438. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107439. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107440. /**
  107441. * If the gizmo is enabled
  107442. */
  107443. isEnabled: boolean;
  107444. /**
  107445. * Disposes of the gizmo
  107446. */
  107447. dispose(): void;
  107448. /**
  107449. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107450. * @param mesh The mesh to replace the default mesh of the gizmo
  107451. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107452. */
  107453. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107454. }
  107455. }
  107456. declare module BABYLON {
  107457. /**
  107458. * Bounding box gizmo
  107459. */
  107460. export class BoundingBoxGizmo extends Gizmo {
  107461. private _lineBoundingBox;
  107462. private _rotateSpheresParent;
  107463. private _scaleBoxesParent;
  107464. private _boundingDimensions;
  107465. private _renderObserver;
  107466. private _pointerObserver;
  107467. private _scaleDragSpeed;
  107468. private _tmpQuaternion;
  107469. private _tmpVector;
  107470. private _tmpRotationMatrix;
  107471. /**
  107472. * 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)
  107473. */
  107474. ignoreChildren: boolean;
  107475. /**
  107476. * 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)
  107477. */
  107478. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107479. /**
  107480. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107481. */
  107482. rotationSphereSize: number;
  107483. /**
  107484. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107485. */
  107486. scaleBoxSize: number;
  107487. /**
  107488. * 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)
  107489. */
  107490. fixedDragMeshScreenSize: boolean;
  107491. /**
  107492. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107493. */
  107494. fixedDragMeshScreenSizeDistanceFactor: number;
  107495. /**
  107496. * Fired when a rotation sphere or scale box is dragged
  107497. */
  107498. onDragStartObservable: Observable<{}>;
  107499. /**
  107500. * Fired when a scale box is dragged
  107501. */
  107502. onScaleBoxDragObservable: Observable<{}>;
  107503. /**
  107504. * Fired when a scale box drag is ended
  107505. */
  107506. onScaleBoxDragEndObservable: Observable<{}>;
  107507. /**
  107508. * Fired when a rotation sphere is dragged
  107509. */
  107510. onRotationSphereDragObservable: Observable<{}>;
  107511. /**
  107512. * Fired when a rotation sphere drag is ended
  107513. */
  107514. onRotationSphereDragEndObservable: Observable<{}>;
  107515. /**
  107516. * 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)
  107517. */
  107518. scalePivot: Nullable<Vector3>;
  107519. /**
  107520. * Mesh used as a pivot to rotate the attached mesh
  107521. */
  107522. private _anchorMesh;
  107523. private _existingMeshScale;
  107524. private _dragMesh;
  107525. private pointerDragBehavior;
  107526. private coloredMaterial;
  107527. private hoverColoredMaterial;
  107528. /**
  107529. * Sets the color of the bounding box gizmo
  107530. * @param color the color to set
  107531. */
  107532. setColor(color: Color3): void;
  107533. /**
  107534. * Creates an BoundingBoxGizmo
  107535. * @param gizmoLayer The utility layer the gizmo will be added to
  107536. * @param color The color of the gizmo
  107537. */
  107538. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107540. private _selectNode;
  107541. /**
  107542. * Updates the bounding box information for the Gizmo
  107543. */
  107544. updateBoundingBox(): void;
  107545. private _updateRotationSpheres;
  107546. private _updateScaleBoxes;
  107547. /**
  107548. * Enables rotation on the specified axis and disables rotation on the others
  107549. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107550. */
  107551. setEnabledRotationAxis(axis: string): void;
  107552. /**
  107553. * Enables/disables scaling
  107554. * @param enable if scaling should be enabled
  107555. */
  107556. setEnabledScaling(enable: boolean): void;
  107557. private _updateDummy;
  107558. /**
  107559. * Enables a pointer drag behavior on the bounding box of the gizmo
  107560. */
  107561. enableDragBehavior(): void;
  107562. /**
  107563. * Disposes of the gizmo
  107564. */
  107565. dispose(): void;
  107566. /**
  107567. * 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)
  107568. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107569. * @returns the bounding box mesh with the passed in mesh as a child
  107570. */
  107571. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107572. /**
  107573. * CustomMeshes are not supported by this gizmo
  107574. * @param mesh The mesh to replace the default mesh of the gizmo
  107575. */
  107576. setCustomMesh(mesh: Mesh): void;
  107577. }
  107578. }
  107579. declare module BABYLON {
  107580. /**
  107581. * Single plane rotation gizmo
  107582. */
  107583. export class PlaneRotationGizmo extends Gizmo {
  107584. /**
  107585. * Drag behavior responsible for the gizmos dragging interactions
  107586. */
  107587. dragBehavior: PointerDragBehavior;
  107588. private _pointerObserver;
  107589. /**
  107590. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107591. */
  107592. snapDistance: number;
  107593. /**
  107594. * Event that fires each time the gizmo snaps to a new location.
  107595. * * snapDistance is the the change in distance
  107596. */
  107597. onSnapObservable: Observable<{
  107598. snapDistance: number;
  107599. }>;
  107600. private _isEnabled;
  107601. private _parent;
  107602. /**
  107603. * Creates a PlaneRotationGizmo
  107604. * @param gizmoLayer The utility layer the gizmo will be added to
  107605. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107606. * @param color The color of the gizmo
  107607. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107608. */
  107609. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107610. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107611. /**
  107612. * If the gizmo is enabled
  107613. */
  107614. isEnabled: boolean;
  107615. /**
  107616. * Disposes of the gizmo
  107617. */
  107618. dispose(): void;
  107619. }
  107620. }
  107621. declare module BABYLON {
  107622. /**
  107623. * Gizmo that enables rotating a mesh along 3 axis
  107624. */
  107625. export class RotationGizmo extends Gizmo {
  107626. /**
  107627. * Internal gizmo used for interactions on the x axis
  107628. */
  107629. xGizmo: PlaneRotationGizmo;
  107630. /**
  107631. * Internal gizmo used for interactions on the y axis
  107632. */
  107633. yGizmo: PlaneRotationGizmo;
  107634. /**
  107635. * Internal gizmo used for interactions on the z axis
  107636. */
  107637. zGizmo: PlaneRotationGizmo;
  107638. /** Fires an event when any of it's sub gizmos are dragged */
  107639. onDragStartObservable: Observable<unknown>;
  107640. /** Fires an event when any of it's sub gizmos are released from dragging */
  107641. onDragEndObservable: Observable<unknown>;
  107642. private _meshAttached;
  107643. attachedMesh: Nullable<AbstractMesh>;
  107644. /**
  107645. * Creates a RotationGizmo
  107646. * @param gizmoLayer The utility layer the gizmo will be added to
  107647. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107648. */
  107649. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107650. updateGizmoRotationToMatchAttachedMesh: boolean;
  107651. /**
  107652. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107653. */
  107654. snapDistance: number;
  107655. /**
  107656. * Ratio for the scale of the gizmo (Default: 1)
  107657. */
  107658. scaleRatio: number;
  107659. /**
  107660. * Disposes of the gizmo
  107661. */
  107662. dispose(): void;
  107663. /**
  107664. * CustomMeshes are not supported by this gizmo
  107665. * @param mesh The mesh to replace the default mesh of the gizmo
  107666. */
  107667. setCustomMesh(mesh: Mesh): void;
  107668. }
  107669. }
  107670. declare module BABYLON {
  107671. /**
  107672. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107673. */
  107674. export class GizmoManager implements IDisposable {
  107675. private scene;
  107676. /**
  107677. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107678. */
  107679. gizmos: {
  107680. positionGizmo: Nullable<PositionGizmo>;
  107681. rotationGizmo: Nullable<RotationGizmo>;
  107682. scaleGizmo: Nullable<ScaleGizmo>;
  107683. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107684. };
  107685. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107686. clearGizmoOnEmptyPointerEvent: boolean;
  107687. /** Fires an event when the manager is attached to a mesh */
  107688. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107689. private _gizmosEnabled;
  107690. private _pointerObserver;
  107691. private _attachedMesh;
  107692. private _boundingBoxColor;
  107693. private _defaultUtilityLayer;
  107694. private _defaultKeepDepthUtilityLayer;
  107695. /**
  107696. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107697. */
  107698. boundingBoxDragBehavior: SixDofDragBehavior;
  107699. /**
  107700. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107701. */
  107702. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107703. /**
  107704. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107705. */
  107706. usePointerToAttachGizmos: boolean;
  107707. /**
  107708. * Utility layer that the bounding box gizmo belongs to
  107709. */
  107710. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107711. /**
  107712. * Utility layer that all gizmos besides bounding box belong to
  107713. */
  107714. readonly utilityLayer: UtilityLayerRenderer;
  107715. /**
  107716. * Instatiates a gizmo manager
  107717. * @param scene the scene to overlay the gizmos on top of
  107718. */
  107719. constructor(scene: Scene);
  107720. /**
  107721. * Attaches a set of gizmos to the specified mesh
  107722. * @param mesh The mesh the gizmo's should be attached to
  107723. */
  107724. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107725. /**
  107726. * If the position gizmo is enabled
  107727. */
  107728. positionGizmoEnabled: boolean;
  107729. /**
  107730. * If the rotation gizmo is enabled
  107731. */
  107732. rotationGizmoEnabled: boolean;
  107733. /**
  107734. * If the scale gizmo is enabled
  107735. */
  107736. scaleGizmoEnabled: boolean;
  107737. /**
  107738. * If the boundingBox gizmo is enabled
  107739. */
  107740. boundingBoxGizmoEnabled: boolean;
  107741. /**
  107742. * Disposes of the gizmo manager
  107743. */
  107744. dispose(): void;
  107745. }
  107746. }
  107747. declare module BABYLON {
  107748. /**
  107749. * A directional light is defined by a direction (what a surprise!).
  107750. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107751. * 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.
  107752. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107753. */
  107754. export class DirectionalLight extends ShadowLight {
  107755. private _shadowFrustumSize;
  107756. /**
  107757. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107758. */
  107759. /**
  107760. * Specifies a fix frustum size for the shadow generation.
  107761. */
  107762. shadowFrustumSize: number;
  107763. private _shadowOrthoScale;
  107764. /**
  107765. * Gets the shadow projection scale against the optimal computed one.
  107766. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107767. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107768. */
  107769. /**
  107770. * Sets the shadow projection scale against the optimal computed one.
  107771. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107772. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107773. */
  107774. shadowOrthoScale: number;
  107775. /**
  107776. * Automatically compute the projection matrix to best fit (including all the casters)
  107777. * on each frame.
  107778. */
  107779. autoUpdateExtends: boolean;
  107780. private _orthoLeft;
  107781. private _orthoRight;
  107782. private _orthoTop;
  107783. private _orthoBottom;
  107784. /**
  107785. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107786. * The directional light is emitted from everywhere in the given direction.
  107787. * It can cast shadows.
  107788. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107789. * @param name The friendly name of the light
  107790. * @param direction The direction of the light
  107791. * @param scene The scene the light belongs to
  107792. */
  107793. constructor(name: string, direction: Vector3, scene: Scene);
  107794. /**
  107795. * Returns the string "DirectionalLight".
  107796. * @return The class name
  107797. */
  107798. getClassName(): string;
  107799. /**
  107800. * Returns the integer 1.
  107801. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107802. */
  107803. getTypeID(): number;
  107804. /**
  107805. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107806. * Returns the DirectionalLight Shadow projection matrix.
  107807. */
  107808. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107809. /**
  107810. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  107811. * Returns the DirectionalLight Shadow projection matrix.
  107812. */
  107813. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  107814. /**
  107815. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107816. * Returns the DirectionalLight Shadow projection matrix.
  107817. */
  107818. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107819. protected _buildUniformLayout(): void;
  107820. /**
  107821. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  107822. * @param effect The effect to update
  107823. * @param lightIndex The index of the light in the effect to update
  107824. * @returns The directional light
  107825. */
  107826. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  107827. /**
  107828. * Gets the minZ used for shadow according to both the scene and the light.
  107829. *
  107830. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107831. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107832. * @param activeCamera The camera we are returning the min for
  107833. * @returns the depth min z
  107834. */
  107835. getDepthMinZ(activeCamera: Camera): number;
  107836. /**
  107837. * Gets the maxZ used for shadow according to both the scene and the light.
  107838. *
  107839. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107840. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107841. * @param activeCamera The camera we are returning the max for
  107842. * @returns the depth max z
  107843. */
  107844. getDepthMaxZ(activeCamera: Camera): number;
  107845. /**
  107846. * Prepares the list of defines specific to the light type.
  107847. * @param defines the list of defines
  107848. * @param lightIndex defines the index of the light for the effect
  107849. */
  107850. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107851. }
  107852. }
  107853. declare module BABYLON {
  107854. /**
  107855. * Class containing static functions to help procedurally build meshes
  107856. */
  107857. export class HemisphereBuilder {
  107858. /**
  107859. * Creates a hemisphere mesh
  107860. * @param name defines the name of the mesh
  107861. * @param options defines the options used to create the mesh
  107862. * @param scene defines the hosting scene
  107863. * @returns the hemisphere mesh
  107864. */
  107865. static CreateHemisphere(name: string, options: {
  107866. segments?: number;
  107867. diameter?: number;
  107868. sideOrientation?: number;
  107869. }, scene: any): Mesh;
  107870. }
  107871. }
  107872. declare module BABYLON {
  107873. /**
  107874. * A spot light is defined by a position, a direction, an angle, and an exponent.
  107875. * These values define a cone of light starting from the position, emitting toward the direction.
  107876. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  107877. * and the exponent defines the speed of the decay of the light with distance (reach).
  107878. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107879. */
  107880. export class SpotLight extends ShadowLight {
  107881. private _angle;
  107882. private _innerAngle;
  107883. private _cosHalfAngle;
  107884. private _lightAngleScale;
  107885. private _lightAngleOffset;
  107886. /**
  107887. * Gets the cone angle of the spot light in Radians.
  107888. */
  107889. /**
  107890. * Sets the cone angle of the spot light in Radians.
  107891. */
  107892. angle: number;
  107893. /**
  107894. * Only used in gltf falloff mode, this defines the angle where
  107895. * the directional falloff will start before cutting at angle which could be seen
  107896. * as outer angle.
  107897. */
  107898. /**
  107899. * Only used in gltf falloff mode, this defines the angle where
  107900. * the directional falloff will start before cutting at angle which could be seen
  107901. * as outer angle.
  107902. */
  107903. innerAngle: number;
  107904. private _shadowAngleScale;
  107905. /**
  107906. * Allows scaling the angle of the light for shadow generation only.
  107907. */
  107908. /**
  107909. * Allows scaling the angle of the light for shadow generation only.
  107910. */
  107911. shadowAngleScale: number;
  107912. /**
  107913. * The light decay speed with the distance from the emission spot.
  107914. */
  107915. exponent: number;
  107916. private _projectionTextureMatrix;
  107917. /**
  107918. * Allows reading the projecton texture
  107919. */
  107920. readonly projectionTextureMatrix: Matrix;
  107921. protected _projectionTextureLightNear: number;
  107922. /**
  107923. * Gets the near clip of the Spotlight for texture projection.
  107924. */
  107925. /**
  107926. * Sets the near clip of the Spotlight for texture projection.
  107927. */
  107928. projectionTextureLightNear: number;
  107929. protected _projectionTextureLightFar: number;
  107930. /**
  107931. * Gets the far clip of the Spotlight for texture projection.
  107932. */
  107933. /**
  107934. * Sets the far clip of the Spotlight for texture projection.
  107935. */
  107936. projectionTextureLightFar: number;
  107937. protected _projectionTextureUpDirection: Vector3;
  107938. /**
  107939. * Gets the Up vector of the Spotlight for texture projection.
  107940. */
  107941. /**
  107942. * Sets the Up vector of the Spotlight for texture projection.
  107943. */
  107944. projectionTextureUpDirection: Vector3;
  107945. private _projectionTexture;
  107946. /**
  107947. * Gets the projection texture of the light.
  107948. */
  107949. /**
  107950. * Sets the projection texture of the light.
  107951. */
  107952. projectionTexture: Nullable<BaseTexture>;
  107953. private _projectionTextureViewLightDirty;
  107954. private _projectionTextureProjectionLightDirty;
  107955. private _projectionTextureDirty;
  107956. private _projectionTextureViewTargetVector;
  107957. private _projectionTextureViewLightMatrix;
  107958. private _projectionTextureProjectionLightMatrix;
  107959. private _projectionTextureScalingMatrix;
  107960. /**
  107961. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  107962. * It can cast shadows.
  107963. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107964. * @param name The light friendly name
  107965. * @param position The position of the spot light in the scene
  107966. * @param direction The direction of the light in the scene
  107967. * @param angle The cone angle of the light in Radians
  107968. * @param exponent The light decay speed with the distance from the emission spot
  107969. * @param scene The scene the lights belongs to
  107970. */
  107971. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  107972. /**
  107973. * Returns the string "SpotLight".
  107974. * @returns the class name
  107975. */
  107976. getClassName(): string;
  107977. /**
  107978. * Returns the integer 2.
  107979. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107980. */
  107981. getTypeID(): number;
  107982. /**
  107983. * Overrides the direction setter to recompute the projection texture view light Matrix.
  107984. */
  107985. protected _setDirection(value: Vector3): void;
  107986. /**
  107987. * Overrides the position setter to recompute the projection texture view light Matrix.
  107988. */
  107989. protected _setPosition(value: Vector3): void;
  107990. /**
  107991. * 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.
  107992. * Returns the SpotLight.
  107993. */
  107994. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107995. protected _computeProjectionTextureViewLightMatrix(): void;
  107996. protected _computeProjectionTextureProjectionLightMatrix(): void;
  107997. /**
  107998. * Main function for light texture projection matrix computing.
  107999. */
  108000. protected _computeProjectionTextureMatrix(): void;
  108001. protected _buildUniformLayout(): void;
  108002. private _computeAngleValues;
  108003. /**
  108004. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  108005. * @param effect The effect to update
  108006. * @param lightIndex The index of the light in the effect to update
  108007. * @returns The spot light
  108008. */
  108009. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  108010. /**
  108011. * Disposes the light and the associated resources.
  108012. */
  108013. dispose(): void;
  108014. /**
  108015. * Prepares the list of defines specific to the light type.
  108016. * @param defines the list of defines
  108017. * @param lightIndex defines the index of the light for the effect
  108018. */
  108019. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108020. }
  108021. }
  108022. declare module BABYLON {
  108023. /**
  108024. * Gizmo that enables viewing a light
  108025. */
  108026. export class LightGizmo extends Gizmo {
  108027. private _lightMesh;
  108028. private _material;
  108029. private cachedPosition;
  108030. private cachedForward;
  108031. /**
  108032. * Creates a LightGizmo
  108033. * @param gizmoLayer The utility layer the gizmo will be added to
  108034. */
  108035. constructor(gizmoLayer?: UtilityLayerRenderer);
  108036. private _light;
  108037. /**
  108038. * The light that the gizmo is attached to
  108039. */
  108040. light: Nullable<Light>;
  108041. /**
  108042. * @hidden
  108043. * Updates the gizmo to match the attached mesh's position/rotation
  108044. */
  108045. protected _update(): void;
  108046. private static _Scale;
  108047. /**
  108048. * Creates the lines for a light mesh
  108049. */
  108050. private static _createLightLines;
  108051. /**
  108052. * Disposes of the light gizmo
  108053. */
  108054. dispose(): void;
  108055. private static _CreateHemisphericLightMesh;
  108056. private static _CreatePointLightMesh;
  108057. private static _CreateSpotLightMesh;
  108058. private static _CreateDirectionalLightMesh;
  108059. }
  108060. }
  108061. declare module BABYLON {
  108062. /** @hidden */
  108063. export var backgroundFragmentDeclaration: {
  108064. name: string;
  108065. shader: string;
  108066. };
  108067. }
  108068. declare module BABYLON {
  108069. /** @hidden */
  108070. export var backgroundUboDeclaration: {
  108071. name: string;
  108072. shader: string;
  108073. };
  108074. }
  108075. declare module BABYLON {
  108076. /** @hidden */
  108077. export var backgroundPixelShader: {
  108078. name: string;
  108079. shader: string;
  108080. };
  108081. }
  108082. declare module BABYLON {
  108083. /** @hidden */
  108084. export var backgroundVertexDeclaration: {
  108085. name: string;
  108086. shader: string;
  108087. };
  108088. }
  108089. declare module BABYLON {
  108090. /** @hidden */
  108091. export var backgroundVertexShader: {
  108092. name: string;
  108093. shader: string;
  108094. };
  108095. }
  108096. declare module BABYLON {
  108097. /**
  108098. * Background material used to create an efficient environement around your scene.
  108099. */
  108100. export class BackgroundMaterial extends PushMaterial {
  108101. /**
  108102. * Standard reflectance value at parallel view angle.
  108103. */
  108104. static StandardReflectance0: number;
  108105. /**
  108106. * Standard reflectance value at grazing angle.
  108107. */
  108108. static StandardReflectance90: number;
  108109. protected _primaryColor: Color3;
  108110. /**
  108111. * Key light Color (multiply against the environement texture)
  108112. */
  108113. primaryColor: Color3;
  108114. protected __perceptualColor: Nullable<Color3>;
  108115. /**
  108116. * Experimental Internal Use Only.
  108117. *
  108118. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108119. * This acts as a helper to set the primary color to a more "human friendly" value.
  108120. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108121. * output color as close as possible from the chosen value.
  108122. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108123. * part of lighting setup.)
  108124. */
  108125. _perceptualColor: Nullable<Color3>;
  108126. protected _primaryColorShadowLevel: float;
  108127. /**
  108128. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108129. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108130. */
  108131. primaryColorShadowLevel: float;
  108132. protected _primaryColorHighlightLevel: float;
  108133. /**
  108134. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108135. * The primary color is used at the level chosen to define what the white area would look.
  108136. */
  108137. primaryColorHighlightLevel: float;
  108138. protected _reflectionTexture: Nullable<BaseTexture>;
  108139. /**
  108140. * Reflection Texture used in the material.
  108141. * Should be author in a specific way for the best result (refer to the documentation).
  108142. */
  108143. reflectionTexture: Nullable<BaseTexture>;
  108144. protected _reflectionBlur: float;
  108145. /**
  108146. * Reflection Texture level of blur.
  108147. *
  108148. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108149. * texture twice.
  108150. */
  108151. reflectionBlur: float;
  108152. protected _diffuseTexture: Nullable<BaseTexture>;
  108153. /**
  108154. * Diffuse Texture used in the material.
  108155. * Should be author in a specific way for the best result (refer to the documentation).
  108156. */
  108157. diffuseTexture: Nullable<BaseTexture>;
  108158. protected _shadowLights: Nullable<IShadowLight[]>;
  108159. /**
  108160. * Specify the list of lights casting shadow on the material.
  108161. * All scene shadow lights will be included if null.
  108162. */
  108163. shadowLights: Nullable<IShadowLight[]>;
  108164. protected _shadowLevel: float;
  108165. /**
  108166. * Helps adjusting the shadow to a softer level if required.
  108167. * 0 means black shadows and 1 means no shadows.
  108168. */
  108169. shadowLevel: float;
  108170. protected _sceneCenter: Vector3;
  108171. /**
  108172. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108173. * It is usually zero but might be interesting to modify according to your setup.
  108174. */
  108175. sceneCenter: Vector3;
  108176. protected _opacityFresnel: boolean;
  108177. /**
  108178. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108179. * This helps ensuring a nice transition when the camera goes under the ground.
  108180. */
  108181. opacityFresnel: boolean;
  108182. protected _reflectionFresnel: boolean;
  108183. /**
  108184. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108185. * This helps adding a mirror texture on the ground.
  108186. */
  108187. reflectionFresnel: boolean;
  108188. protected _reflectionFalloffDistance: number;
  108189. /**
  108190. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108191. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108192. */
  108193. reflectionFalloffDistance: number;
  108194. protected _reflectionAmount: number;
  108195. /**
  108196. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108197. */
  108198. reflectionAmount: number;
  108199. protected _reflectionReflectance0: number;
  108200. /**
  108201. * This specifies the weight of the reflection at grazing angle.
  108202. */
  108203. reflectionReflectance0: number;
  108204. protected _reflectionReflectance90: number;
  108205. /**
  108206. * This specifies the weight of the reflection at a perpendicular point of view.
  108207. */
  108208. reflectionReflectance90: number;
  108209. /**
  108210. * Sets the reflection reflectance fresnel values according to the default standard
  108211. * empirically know to work well :-)
  108212. */
  108213. reflectionStandardFresnelWeight: number;
  108214. protected _useRGBColor: boolean;
  108215. /**
  108216. * Helps to directly use the maps channels instead of their level.
  108217. */
  108218. useRGBColor: boolean;
  108219. protected _enableNoise: boolean;
  108220. /**
  108221. * This helps reducing the banding effect that could occur on the background.
  108222. */
  108223. enableNoise: boolean;
  108224. /**
  108225. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108226. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108227. * Recommended to be keep at 1.0 except for special cases.
  108228. */
  108229. fovMultiplier: number;
  108230. private _fovMultiplier;
  108231. /**
  108232. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108233. */
  108234. useEquirectangularFOV: boolean;
  108235. private _maxSimultaneousLights;
  108236. /**
  108237. * Number of Simultaneous lights allowed on the material.
  108238. */
  108239. maxSimultaneousLights: int;
  108240. /**
  108241. * Default configuration related to image processing available in the Background Material.
  108242. */
  108243. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108244. /**
  108245. * Keep track of the image processing observer to allow dispose and replace.
  108246. */
  108247. private _imageProcessingObserver;
  108248. /**
  108249. * Attaches a new image processing configuration to the PBR Material.
  108250. * @param configuration (if null the scene configuration will be use)
  108251. */
  108252. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108253. /**
  108254. * Gets the image processing configuration used either in this material.
  108255. */
  108256. /**
  108257. * Sets the Default image processing configuration used either in the this material.
  108258. *
  108259. * If sets to null, the scene one is in use.
  108260. */
  108261. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108262. /**
  108263. * Gets wether the color curves effect is enabled.
  108264. */
  108265. /**
  108266. * Sets wether the color curves effect is enabled.
  108267. */
  108268. cameraColorCurvesEnabled: boolean;
  108269. /**
  108270. * Gets wether the color grading effect is enabled.
  108271. */
  108272. /**
  108273. * Gets wether the color grading effect is enabled.
  108274. */
  108275. cameraColorGradingEnabled: boolean;
  108276. /**
  108277. * Gets wether tonemapping is enabled or not.
  108278. */
  108279. /**
  108280. * Sets wether tonemapping is enabled or not
  108281. */
  108282. cameraToneMappingEnabled: boolean;
  108283. /**
  108284. * The camera exposure used on this material.
  108285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108286. * This corresponds to a photographic exposure.
  108287. */
  108288. /**
  108289. * The camera exposure used on this material.
  108290. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108291. * This corresponds to a photographic exposure.
  108292. */
  108293. cameraExposure: float;
  108294. /**
  108295. * Gets The camera contrast used on this material.
  108296. */
  108297. /**
  108298. * Sets The camera contrast used on this material.
  108299. */
  108300. cameraContrast: float;
  108301. /**
  108302. * Gets the Color Grading 2D Lookup Texture.
  108303. */
  108304. /**
  108305. * Sets the Color Grading 2D Lookup Texture.
  108306. */
  108307. cameraColorGradingTexture: Nullable<BaseTexture>;
  108308. /**
  108309. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108310. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108311. * 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;
  108312. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108313. */
  108314. /**
  108315. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108316. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108317. * 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;
  108318. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108319. */
  108320. cameraColorCurves: Nullable<ColorCurves>;
  108321. /**
  108322. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108323. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108324. */
  108325. switchToBGR: boolean;
  108326. private _renderTargets;
  108327. private _reflectionControls;
  108328. private _white;
  108329. private _primaryShadowColor;
  108330. private _primaryHighlightColor;
  108331. /**
  108332. * Instantiates a Background Material in the given scene
  108333. * @param name The friendly name of the material
  108334. * @param scene The scene to add the material to
  108335. */
  108336. constructor(name: string, scene: Scene);
  108337. /**
  108338. * Gets a boolean indicating that current material needs to register RTT
  108339. */
  108340. readonly hasRenderTargetTextures: boolean;
  108341. /**
  108342. * The entire material has been created in order to prevent overdraw.
  108343. * @returns false
  108344. */
  108345. needAlphaTesting(): boolean;
  108346. /**
  108347. * The entire material has been created in order to prevent overdraw.
  108348. * @returns true if blending is enable
  108349. */
  108350. needAlphaBlending(): boolean;
  108351. /**
  108352. * Checks wether the material is ready to be rendered for a given mesh.
  108353. * @param mesh The mesh to render
  108354. * @param subMesh The submesh to check against
  108355. * @param useInstances Specify wether or not the material is used with instances
  108356. * @returns true if all the dependencies are ready (Textures, Effects...)
  108357. */
  108358. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108359. /**
  108360. * Compute the primary color according to the chosen perceptual color.
  108361. */
  108362. private _computePrimaryColorFromPerceptualColor;
  108363. /**
  108364. * Compute the highlights and shadow colors according to their chosen levels.
  108365. */
  108366. private _computePrimaryColors;
  108367. /**
  108368. * Build the uniform buffer used in the material.
  108369. */
  108370. buildUniformLayout(): void;
  108371. /**
  108372. * Unbind the material.
  108373. */
  108374. unbind(): void;
  108375. /**
  108376. * Bind only the world matrix to the material.
  108377. * @param world The world matrix to bind.
  108378. */
  108379. bindOnlyWorldMatrix(world: Matrix): void;
  108380. /**
  108381. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108382. * @param world The world matrix to bind.
  108383. * @param subMesh The submesh to bind for.
  108384. */
  108385. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108386. /**
  108387. * Dispose the material.
  108388. * @param forceDisposeEffect Force disposal of the associated effect.
  108389. * @param forceDisposeTextures Force disposal of the associated textures.
  108390. */
  108391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108392. /**
  108393. * Clones the material.
  108394. * @param name The cloned name.
  108395. * @returns The cloned material.
  108396. */
  108397. clone(name: string): BackgroundMaterial;
  108398. /**
  108399. * Serializes the current material to its JSON representation.
  108400. * @returns The JSON representation.
  108401. */
  108402. serialize(): any;
  108403. /**
  108404. * Gets the class name of the material
  108405. * @returns "BackgroundMaterial"
  108406. */
  108407. getClassName(): string;
  108408. /**
  108409. * Parse a JSON input to create back a background material.
  108410. * @param source The JSON data to parse
  108411. * @param scene The scene to create the parsed material in
  108412. * @param rootUrl The root url of the assets the material depends upon
  108413. * @returns the instantiated BackgroundMaterial.
  108414. */
  108415. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108416. }
  108417. }
  108418. declare module BABYLON {
  108419. /**
  108420. * Represents the different options available during the creation of
  108421. * a Environment helper.
  108422. *
  108423. * This can control the default ground, skybox and image processing setup of your scene.
  108424. */
  108425. export interface IEnvironmentHelperOptions {
  108426. /**
  108427. * Specifies wether or not to create a ground.
  108428. * True by default.
  108429. */
  108430. createGround: boolean;
  108431. /**
  108432. * Specifies the ground size.
  108433. * 15 by default.
  108434. */
  108435. groundSize: number;
  108436. /**
  108437. * The texture used on the ground for the main color.
  108438. * Comes from the BabylonJS CDN by default.
  108439. *
  108440. * Remarks: Can be either a texture or a url.
  108441. */
  108442. groundTexture: string | BaseTexture;
  108443. /**
  108444. * The color mixed in the ground texture by default.
  108445. * BabylonJS clearColor by default.
  108446. */
  108447. groundColor: Color3;
  108448. /**
  108449. * Specifies the ground opacity.
  108450. * 1 by default.
  108451. */
  108452. groundOpacity: number;
  108453. /**
  108454. * Enables the ground to receive shadows.
  108455. * True by default.
  108456. */
  108457. enableGroundShadow: boolean;
  108458. /**
  108459. * Helps preventing the shadow to be fully black on the ground.
  108460. * 0.5 by default.
  108461. */
  108462. groundShadowLevel: number;
  108463. /**
  108464. * Creates a mirror texture attach to the ground.
  108465. * false by default.
  108466. */
  108467. enableGroundMirror: boolean;
  108468. /**
  108469. * Specifies the ground mirror size ratio.
  108470. * 0.3 by default as the default kernel is 64.
  108471. */
  108472. groundMirrorSizeRatio: number;
  108473. /**
  108474. * Specifies the ground mirror blur kernel size.
  108475. * 64 by default.
  108476. */
  108477. groundMirrorBlurKernel: number;
  108478. /**
  108479. * Specifies the ground mirror visibility amount.
  108480. * 1 by default
  108481. */
  108482. groundMirrorAmount: number;
  108483. /**
  108484. * Specifies the ground mirror reflectance weight.
  108485. * This uses the standard weight of the background material to setup the fresnel effect
  108486. * of the mirror.
  108487. * 1 by default.
  108488. */
  108489. groundMirrorFresnelWeight: number;
  108490. /**
  108491. * Specifies the ground mirror Falloff distance.
  108492. * This can helps reducing the size of the reflection.
  108493. * 0 by Default.
  108494. */
  108495. groundMirrorFallOffDistance: number;
  108496. /**
  108497. * Specifies the ground mirror texture type.
  108498. * Unsigned Int by Default.
  108499. */
  108500. groundMirrorTextureType: number;
  108501. /**
  108502. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108503. * the shown objects.
  108504. */
  108505. groundYBias: number;
  108506. /**
  108507. * Specifies wether or not to create a skybox.
  108508. * True by default.
  108509. */
  108510. createSkybox: boolean;
  108511. /**
  108512. * Specifies the skybox size.
  108513. * 20 by default.
  108514. */
  108515. skyboxSize: number;
  108516. /**
  108517. * The texture used on the skybox for the main color.
  108518. * Comes from the BabylonJS CDN by default.
  108519. *
  108520. * Remarks: Can be either a texture or a url.
  108521. */
  108522. skyboxTexture: string | BaseTexture;
  108523. /**
  108524. * The color mixed in the skybox texture by default.
  108525. * BabylonJS clearColor by default.
  108526. */
  108527. skyboxColor: Color3;
  108528. /**
  108529. * The background rotation around the Y axis of the scene.
  108530. * This helps aligning the key lights of your scene with the background.
  108531. * 0 by default.
  108532. */
  108533. backgroundYRotation: number;
  108534. /**
  108535. * Compute automatically the size of the elements to best fit with the scene.
  108536. */
  108537. sizeAuto: boolean;
  108538. /**
  108539. * Default position of the rootMesh if autoSize is not true.
  108540. */
  108541. rootPosition: Vector3;
  108542. /**
  108543. * Sets up the image processing in the scene.
  108544. * true by default.
  108545. */
  108546. setupImageProcessing: boolean;
  108547. /**
  108548. * The texture used as your environment texture in the scene.
  108549. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108550. *
  108551. * Remarks: Can be either a texture or a url.
  108552. */
  108553. environmentTexture: string | BaseTexture;
  108554. /**
  108555. * The value of the exposure to apply to the scene.
  108556. * 0.6 by default if setupImageProcessing is true.
  108557. */
  108558. cameraExposure: number;
  108559. /**
  108560. * The value of the contrast to apply to the scene.
  108561. * 1.6 by default if setupImageProcessing is true.
  108562. */
  108563. cameraContrast: number;
  108564. /**
  108565. * Specifies wether or not tonemapping should be enabled in the scene.
  108566. * true by default if setupImageProcessing is true.
  108567. */
  108568. toneMappingEnabled: boolean;
  108569. }
  108570. /**
  108571. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108572. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108573. * It also helps with the default setup of your imageProcessing configuration.
  108574. */
  108575. export class EnvironmentHelper {
  108576. /**
  108577. * Default ground texture URL.
  108578. */
  108579. private static _groundTextureCDNUrl;
  108580. /**
  108581. * Default skybox texture URL.
  108582. */
  108583. private static _skyboxTextureCDNUrl;
  108584. /**
  108585. * Default environment texture URL.
  108586. */
  108587. private static _environmentTextureCDNUrl;
  108588. /**
  108589. * Creates the default options for the helper.
  108590. */
  108591. private static _getDefaultOptions;
  108592. private _rootMesh;
  108593. /**
  108594. * Gets the root mesh created by the helper.
  108595. */
  108596. readonly rootMesh: Mesh;
  108597. private _skybox;
  108598. /**
  108599. * Gets the skybox created by the helper.
  108600. */
  108601. readonly skybox: Nullable<Mesh>;
  108602. private _skyboxTexture;
  108603. /**
  108604. * Gets the skybox texture created by the helper.
  108605. */
  108606. readonly skyboxTexture: Nullable<BaseTexture>;
  108607. private _skyboxMaterial;
  108608. /**
  108609. * Gets the skybox material created by the helper.
  108610. */
  108611. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108612. private _ground;
  108613. /**
  108614. * Gets the ground mesh created by the helper.
  108615. */
  108616. readonly ground: Nullable<Mesh>;
  108617. private _groundTexture;
  108618. /**
  108619. * Gets the ground texture created by the helper.
  108620. */
  108621. readonly groundTexture: Nullable<BaseTexture>;
  108622. private _groundMirror;
  108623. /**
  108624. * Gets the ground mirror created by the helper.
  108625. */
  108626. readonly groundMirror: Nullable<MirrorTexture>;
  108627. /**
  108628. * Gets the ground mirror render list to helps pushing the meshes
  108629. * you wish in the ground reflection.
  108630. */
  108631. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108632. private _groundMaterial;
  108633. /**
  108634. * Gets the ground material created by the helper.
  108635. */
  108636. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108637. /**
  108638. * Stores the creation options.
  108639. */
  108640. private readonly _scene;
  108641. private _options;
  108642. /**
  108643. * This observable will be notified with any error during the creation of the environment,
  108644. * mainly texture creation errors.
  108645. */
  108646. onErrorObservable: Observable<{
  108647. message?: string;
  108648. exception?: any;
  108649. }>;
  108650. /**
  108651. * constructor
  108652. * @param options Defines the options we want to customize the helper
  108653. * @param scene The scene to add the material to
  108654. */
  108655. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108656. /**
  108657. * Updates the background according to the new options
  108658. * @param options
  108659. */
  108660. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108661. /**
  108662. * Sets the primary color of all the available elements.
  108663. * @param color the main color to affect to the ground and the background
  108664. */
  108665. setMainColor(color: Color3): void;
  108666. /**
  108667. * Setup the image processing according to the specified options.
  108668. */
  108669. private _setupImageProcessing;
  108670. /**
  108671. * Setup the environment texture according to the specified options.
  108672. */
  108673. private _setupEnvironmentTexture;
  108674. /**
  108675. * Setup the background according to the specified options.
  108676. */
  108677. private _setupBackground;
  108678. /**
  108679. * Get the scene sizes according to the setup.
  108680. */
  108681. private _getSceneSize;
  108682. /**
  108683. * Setup the ground according to the specified options.
  108684. */
  108685. private _setupGround;
  108686. /**
  108687. * Setup the ground material according to the specified options.
  108688. */
  108689. private _setupGroundMaterial;
  108690. /**
  108691. * Setup the ground diffuse texture according to the specified options.
  108692. */
  108693. private _setupGroundDiffuseTexture;
  108694. /**
  108695. * Setup the ground mirror texture according to the specified options.
  108696. */
  108697. private _setupGroundMirrorTexture;
  108698. /**
  108699. * Setup the ground to receive the mirror texture.
  108700. */
  108701. private _setupMirrorInGroundMaterial;
  108702. /**
  108703. * Setup the skybox according to the specified options.
  108704. */
  108705. private _setupSkybox;
  108706. /**
  108707. * Setup the skybox material according to the specified options.
  108708. */
  108709. private _setupSkyboxMaterial;
  108710. /**
  108711. * Setup the skybox reflection texture according to the specified options.
  108712. */
  108713. private _setupSkyboxReflectionTexture;
  108714. private _errorHandler;
  108715. /**
  108716. * Dispose all the elements created by the Helper.
  108717. */
  108718. dispose(): void;
  108719. }
  108720. }
  108721. declare module BABYLON {
  108722. /**
  108723. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108724. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108725. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108726. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108727. */
  108728. export class PhotoDome extends TransformNode {
  108729. /**
  108730. * Define the image as a Monoscopic panoramic 360 image.
  108731. */
  108732. static readonly MODE_MONOSCOPIC: number;
  108733. /**
  108734. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108735. */
  108736. static readonly MODE_TOPBOTTOM: number;
  108737. /**
  108738. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108739. */
  108740. static readonly MODE_SIDEBYSIDE: number;
  108741. private _useDirectMapping;
  108742. /**
  108743. * The texture being displayed on the sphere
  108744. */
  108745. protected _photoTexture: Texture;
  108746. /**
  108747. * Gets or sets the texture being displayed on the sphere
  108748. */
  108749. photoTexture: Texture;
  108750. /**
  108751. * Observable raised when an error occured while loading the 360 image
  108752. */
  108753. onLoadErrorObservable: Observable<string>;
  108754. /**
  108755. * The skybox material
  108756. */
  108757. protected _material: BackgroundMaterial;
  108758. /**
  108759. * The surface used for the skybox
  108760. */
  108761. protected _mesh: Mesh;
  108762. /**
  108763. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108764. * Also see the options.resolution property.
  108765. */
  108766. fovMultiplier: number;
  108767. private _imageMode;
  108768. /**
  108769. * Gets or set the current video mode for the video. It can be:
  108770. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108771. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108772. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108773. */
  108774. imageMode: number;
  108775. /**
  108776. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108777. * @param name Element's name, child elements will append suffixes for their own names.
  108778. * @param urlsOfPhoto defines the url of the photo to display
  108779. * @param options defines an object containing optional or exposed sub element properties
  108780. * @param onError defines a callback called when an error occured while loading the texture
  108781. */
  108782. constructor(name: string, urlOfPhoto: string, options: {
  108783. resolution?: number;
  108784. size?: number;
  108785. useDirectMapping?: boolean;
  108786. faceForward?: boolean;
  108787. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108788. private _onBeforeCameraRenderObserver;
  108789. private _changeImageMode;
  108790. /**
  108791. * Releases resources associated with this node.
  108792. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108793. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108794. */
  108795. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108796. }
  108797. }
  108798. declare module BABYLON {
  108799. /** @hidden */
  108800. export var rgbdDecodePixelShader: {
  108801. name: string;
  108802. shader: string;
  108803. };
  108804. }
  108805. declare module BABYLON {
  108806. /**
  108807. * Class used to host texture specific utilities
  108808. */
  108809. export class BRDFTextureTools {
  108810. /**
  108811. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108812. * @param texture the texture to expand.
  108813. */
  108814. private static _ExpandDefaultBRDFTexture;
  108815. /**
  108816. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108817. * @param scene defines the hosting scene
  108818. * @returns the environment BRDF texture
  108819. */
  108820. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  108821. private static _environmentBRDFBase64Texture;
  108822. }
  108823. }
  108824. declare module BABYLON {
  108825. /**
  108826. * @hidden
  108827. */
  108828. export interface IMaterialClearCoatDefines {
  108829. CLEARCOAT: boolean;
  108830. CLEARCOAT_DEFAULTIOR: boolean;
  108831. CLEARCOAT_TEXTURE: boolean;
  108832. CLEARCOAT_TEXTUREDIRECTUV: number;
  108833. CLEARCOAT_BUMP: boolean;
  108834. CLEARCOAT_BUMPDIRECTUV: number;
  108835. CLEARCOAT_TINT: boolean;
  108836. CLEARCOAT_TINT_TEXTURE: boolean;
  108837. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108838. /** @hidden */
  108839. _areTexturesDirty: boolean;
  108840. }
  108841. /**
  108842. * Define the code related to the clear coat parameters of the pbr material.
  108843. */
  108844. export class PBRClearCoatConfiguration {
  108845. /**
  108846. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108847. * The default fits with a polyurethane material.
  108848. */
  108849. private static readonly _DefaultIndexOfRefraction;
  108850. private _isEnabled;
  108851. /**
  108852. * Defines if the clear coat is enabled in the material.
  108853. */
  108854. isEnabled: boolean;
  108855. /**
  108856. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  108857. */
  108858. intensity: number;
  108859. /**
  108860. * Defines the clear coat layer roughness.
  108861. */
  108862. roughness: number;
  108863. private _indexOfRefraction;
  108864. /**
  108865. * Defines the index of refraction of the clear coat.
  108866. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108867. * The default fits with a polyurethane material.
  108868. * Changing the default value is more performance intensive.
  108869. */
  108870. indexOfRefraction: number;
  108871. private _texture;
  108872. /**
  108873. * Stores the clear coat values in a texture.
  108874. */
  108875. texture: Nullable<BaseTexture>;
  108876. private _bumpTexture;
  108877. /**
  108878. * Define the clear coat specific bump texture.
  108879. */
  108880. bumpTexture: Nullable<BaseTexture>;
  108881. private _isTintEnabled;
  108882. /**
  108883. * Defines if the clear coat tint is enabled in the material.
  108884. */
  108885. isTintEnabled: boolean;
  108886. /**
  108887. * Defines the clear coat tint of the material.
  108888. * This is only use if tint is enabled
  108889. */
  108890. tintColor: Color3;
  108891. /**
  108892. * Defines the distance at which the tint color should be found in the
  108893. * clear coat media.
  108894. * This is only use if tint is enabled
  108895. */
  108896. tintColorAtDistance: number;
  108897. /**
  108898. * Defines the clear coat layer thickness.
  108899. * This is only use if tint is enabled
  108900. */
  108901. tintThickness: number;
  108902. private _tintTexture;
  108903. /**
  108904. * Stores the clear tint values in a texture.
  108905. * rgb is tint
  108906. * a is a thickness factor
  108907. */
  108908. tintTexture: Nullable<BaseTexture>;
  108909. /** @hidden */
  108910. private _internalMarkAllSubMeshesAsTexturesDirty;
  108911. /** @hidden */
  108912. _markAllSubMeshesAsTexturesDirty(): void;
  108913. /**
  108914. * Instantiate a new istance of clear coat configuration.
  108915. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108916. */
  108917. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108918. /**
  108919. * Gets wehter the submesh is ready to be used or not.
  108920. * @param defines the list of "defines" to update.
  108921. * @param scene defines the scene the material belongs to.
  108922. * @param engine defines the engine the material belongs to.
  108923. * @param disableBumpMap defines wether the material disables bump or not.
  108924. * @returns - boolean indicating that the submesh is ready or not.
  108925. */
  108926. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  108927. /**
  108928. * Checks to see if a texture is used in the material.
  108929. * @param defines the list of "defines" to update.
  108930. * @param scene defines the scene to the material belongs to.
  108931. */
  108932. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  108933. /**
  108934. * Binds the material data.
  108935. * @param uniformBuffer defines the Uniform buffer to fill in.
  108936. * @param scene defines the scene the material belongs to.
  108937. * @param engine defines the engine the material belongs to.
  108938. * @param disableBumpMap defines wether the material disables bump or not.
  108939. * @param isFrozen defines wether the material is frozen or not.
  108940. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108941. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108942. */
  108943. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  108944. /**
  108945. * Checks to see if a texture is used in the material.
  108946. * @param texture - Base texture to use.
  108947. * @returns - Boolean specifying if a texture is used in the material.
  108948. */
  108949. hasTexture(texture: BaseTexture): boolean;
  108950. /**
  108951. * Returns an array of the actively used textures.
  108952. * @param activeTextures Array of BaseTextures
  108953. */
  108954. getActiveTextures(activeTextures: BaseTexture[]): void;
  108955. /**
  108956. * Returns the animatable textures.
  108957. * @param animatables Array of animatable textures.
  108958. */
  108959. getAnimatables(animatables: IAnimatable[]): void;
  108960. /**
  108961. * Disposes the resources of the material.
  108962. * @param forceDisposeTextures - Forces the disposal of all textures.
  108963. */
  108964. dispose(forceDisposeTextures?: boolean): void;
  108965. /**
  108966. * Get the current class name of the texture useful for serialization or dynamic coding.
  108967. * @returns "PBRClearCoatConfiguration"
  108968. */
  108969. getClassName(): string;
  108970. /**
  108971. * Add fallbacks to the effect fallbacks list.
  108972. * @param defines defines the Base texture to use.
  108973. * @param fallbacks defines the current fallback list.
  108974. * @param currentRank defines the current fallback rank.
  108975. * @returns the new fallback rank.
  108976. */
  108977. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108978. /**
  108979. * Add the required uniforms to the current list.
  108980. * @param uniforms defines the current uniform list.
  108981. */
  108982. static AddUniforms(uniforms: string[]): void;
  108983. /**
  108984. * Add the required samplers to the current list.
  108985. * @param samplers defines the current sampler list.
  108986. */
  108987. static AddSamplers(samplers: string[]): void;
  108988. /**
  108989. * Add the required uniforms to the current buffer.
  108990. * @param uniformBuffer defines the current uniform buffer.
  108991. */
  108992. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108993. /**
  108994. * Makes a duplicate of the current configuration into another one.
  108995. * @param clearCoatConfiguration define the config where to copy the info
  108996. */
  108997. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  108998. /**
  108999. * Serializes this clear coat configuration.
  109000. * @returns - An object with the serialized config.
  109001. */
  109002. serialize(): any;
  109003. /**
  109004. * Parses a anisotropy Configuration from a serialized object.
  109005. * @param source - Serialized object.
  109006. * @param scene Defines the scene we are parsing for
  109007. * @param rootUrl Defines the rootUrl to load from
  109008. */
  109009. parse(source: any, scene: Scene, rootUrl: string): void;
  109010. }
  109011. }
  109012. declare module BABYLON {
  109013. /**
  109014. * @hidden
  109015. */
  109016. export interface IMaterialAnisotropicDefines {
  109017. ANISOTROPIC: boolean;
  109018. ANISOTROPIC_TEXTURE: boolean;
  109019. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109020. MAINUV1: boolean;
  109021. _areTexturesDirty: boolean;
  109022. _needUVs: boolean;
  109023. }
  109024. /**
  109025. * Define the code related to the anisotropic parameters of the pbr material.
  109026. */
  109027. export class PBRAnisotropicConfiguration {
  109028. private _isEnabled;
  109029. /**
  109030. * Defines if the anisotropy is enabled in the material.
  109031. */
  109032. isEnabled: boolean;
  109033. /**
  109034. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109035. */
  109036. intensity: number;
  109037. /**
  109038. * Defines if the effect is along the tangents, bitangents or in between.
  109039. * By default, the effect is "strectching" the highlights along the tangents.
  109040. */
  109041. direction: Vector2;
  109042. private _texture;
  109043. /**
  109044. * Stores the anisotropy values in a texture.
  109045. * rg is direction (like normal from -1 to 1)
  109046. * b is a intensity
  109047. */
  109048. texture: Nullable<BaseTexture>;
  109049. /** @hidden */
  109050. private _internalMarkAllSubMeshesAsTexturesDirty;
  109051. /** @hidden */
  109052. _markAllSubMeshesAsTexturesDirty(): void;
  109053. /**
  109054. * Instantiate a new istance of anisotropy configuration.
  109055. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109056. */
  109057. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109058. /**
  109059. * Specifies that the submesh is ready to be used.
  109060. * @param defines the list of "defines" to update.
  109061. * @param scene defines the scene the material belongs to.
  109062. * @returns - boolean indicating that the submesh is ready or not.
  109063. */
  109064. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109065. /**
  109066. * Checks to see if a texture is used in the material.
  109067. * @param defines the list of "defines" to update.
  109068. * @param mesh the mesh we are preparing the defines for.
  109069. * @param scene defines the scene the material belongs to.
  109070. */
  109071. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109072. /**
  109073. * Binds the material data.
  109074. * @param uniformBuffer defines the Uniform buffer to fill in.
  109075. * @param scene defines the scene the material belongs to.
  109076. * @param isFrozen defines wether the material is frozen or not.
  109077. */
  109078. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109079. /**
  109080. * Checks to see if a texture is used in the material.
  109081. * @param texture - Base texture to use.
  109082. * @returns - Boolean specifying if a texture is used in the material.
  109083. */
  109084. hasTexture(texture: BaseTexture): boolean;
  109085. /**
  109086. * Returns an array of the actively used textures.
  109087. * @param activeTextures Array of BaseTextures
  109088. */
  109089. getActiveTextures(activeTextures: BaseTexture[]): void;
  109090. /**
  109091. * Returns the animatable textures.
  109092. * @param animatables Array of animatable textures.
  109093. */
  109094. getAnimatables(animatables: IAnimatable[]): void;
  109095. /**
  109096. * Disposes the resources of the material.
  109097. * @param forceDisposeTextures - Forces the disposal of all textures.
  109098. */
  109099. dispose(forceDisposeTextures?: boolean): void;
  109100. /**
  109101. * Get the current class name of the texture useful for serialization or dynamic coding.
  109102. * @returns "PBRAnisotropicConfiguration"
  109103. */
  109104. getClassName(): string;
  109105. /**
  109106. * Add fallbacks to the effect fallbacks list.
  109107. * @param defines defines the Base texture to use.
  109108. * @param fallbacks defines the current fallback list.
  109109. * @param currentRank defines the current fallback rank.
  109110. * @returns the new fallback rank.
  109111. */
  109112. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109113. /**
  109114. * Add the required uniforms to the current list.
  109115. * @param uniforms defines the current uniform list.
  109116. */
  109117. static AddUniforms(uniforms: string[]): void;
  109118. /**
  109119. * Add the required uniforms to the current buffer.
  109120. * @param uniformBuffer defines the current uniform buffer.
  109121. */
  109122. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109123. /**
  109124. * Add the required samplers to the current list.
  109125. * @param samplers defines the current sampler list.
  109126. */
  109127. static AddSamplers(samplers: string[]): void;
  109128. /**
  109129. * Makes a duplicate of the current configuration into another one.
  109130. * @param anisotropicConfiguration define the config where to copy the info
  109131. */
  109132. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109133. /**
  109134. * Serializes this anisotropy configuration.
  109135. * @returns - An object with the serialized config.
  109136. */
  109137. serialize(): any;
  109138. /**
  109139. * Parses a anisotropy Configuration from a serialized object.
  109140. * @param source - Serialized object.
  109141. * @param scene Defines the scene we are parsing for
  109142. * @param rootUrl Defines the rootUrl to load from
  109143. */
  109144. parse(source: any, scene: Scene, rootUrl: string): void;
  109145. }
  109146. }
  109147. declare module BABYLON {
  109148. /**
  109149. * @hidden
  109150. */
  109151. export interface IMaterialBRDFDefines {
  109152. BRDF_V_HEIGHT_CORRELATED: boolean;
  109153. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109154. SPHERICAL_HARMONICS: boolean;
  109155. /** @hidden */
  109156. _areMiscDirty: boolean;
  109157. }
  109158. /**
  109159. * Define the code related to the BRDF parameters of the pbr material.
  109160. */
  109161. export class PBRBRDFConfiguration {
  109162. /**
  109163. * Default value used for the energy conservation.
  109164. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109165. */
  109166. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109167. /**
  109168. * Default value used for the Smith Visibility Height Correlated mode.
  109169. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109170. */
  109171. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109172. /**
  109173. * Default value used for the IBL diffuse part.
  109174. * This can help switching back to the polynomials mode globally which is a tiny bit
  109175. * less GPU intensive at the drawback of a lower quality.
  109176. */
  109177. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109178. private _useEnergyConservation;
  109179. /**
  109180. * Defines if the material uses energy conservation.
  109181. */
  109182. useEnergyConservation: boolean;
  109183. private _useSmithVisibilityHeightCorrelated;
  109184. /**
  109185. * LEGACY Mode set to false
  109186. * Defines if the material uses height smith correlated visibility term.
  109187. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109188. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109189. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109190. * Not relying on height correlated will also disable energy conservation.
  109191. */
  109192. useSmithVisibilityHeightCorrelated: boolean;
  109193. private _useSphericalHarmonics;
  109194. /**
  109195. * LEGACY Mode set to false
  109196. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109197. * diffuse part of the IBL.
  109198. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109199. * to the ground truth.
  109200. */
  109201. useSphericalHarmonics: boolean;
  109202. /** @hidden */
  109203. private _internalMarkAllSubMeshesAsMiscDirty;
  109204. /** @hidden */
  109205. _markAllSubMeshesAsMiscDirty(): void;
  109206. /**
  109207. * Instantiate a new istance of clear coat configuration.
  109208. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109209. */
  109210. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109211. /**
  109212. * Checks to see if a texture is used in the material.
  109213. * @param defines the list of "defines" to update.
  109214. */
  109215. prepareDefines(defines: IMaterialBRDFDefines): void;
  109216. /**
  109217. * Get the current class name of the texture useful for serialization or dynamic coding.
  109218. * @returns "PBRClearCoatConfiguration"
  109219. */
  109220. getClassName(): string;
  109221. /**
  109222. * Makes a duplicate of the current configuration into another one.
  109223. * @param brdfConfiguration define the config where to copy the info
  109224. */
  109225. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109226. /**
  109227. * Serializes this BRDF configuration.
  109228. * @returns - An object with the serialized config.
  109229. */
  109230. serialize(): any;
  109231. /**
  109232. * Parses a anisotropy Configuration from a serialized object.
  109233. * @param source - Serialized object.
  109234. * @param scene Defines the scene we are parsing for
  109235. * @param rootUrl Defines the rootUrl to load from
  109236. */
  109237. parse(source: any, scene: Scene, rootUrl: string): void;
  109238. }
  109239. }
  109240. declare module BABYLON {
  109241. /**
  109242. * @hidden
  109243. */
  109244. export interface IMaterialSheenDefines {
  109245. SHEEN: boolean;
  109246. SHEEN_TEXTURE: boolean;
  109247. SHEEN_TEXTUREDIRECTUV: number;
  109248. SHEEN_LINKWITHALBEDO: boolean;
  109249. /** @hidden */
  109250. _areTexturesDirty: boolean;
  109251. }
  109252. /**
  109253. * Define the code related to the Sheen parameters of the pbr material.
  109254. */
  109255. export class PBRSheenConfiguration {
  109256. private _isEnabled;
  109257. /**
  109258. * Defines if the material uses sheen.
  109259. */
  109260. isEnabled: boolean;
  109261. private _linkSheenWithAlbedo;
  109262. /**
  109263. * Defines if the sheen is linked to the sheen color.
  109264. */
  109265. linkSheenWithAlbedo: boolean;
  109266. /**
  109267. * Defines the sheen intensity.
  109268. */
  109269. intensity: number;
  109270. /**
  109271. * Defines the sheen color.
  109272. */
  109273. color: Color3;
  109274. private _texture;
  109275. /**
  109276. * Stores the sheen tint values in a texture.
  109277. * rgb is tint
  109278. * a is a intensity
  109279. */
  109280. texture: Nullable<BaseTexture>;
  109281. /** @hidden */
  109282. private _internalMarkAllSubMeshesAsTexturesDirty;
  109283. /** @hidden */
  109284. _markAllSubMeshesAsTexturesDirty(): void;
  109285. /**
  109286. * Instantiate a new istance of clear coat configuration.
  109287. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109288. */
  109289. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109290. /**
  109291. * Specifies that the submesh is ready to be used.
  109292. * @param defines the list of "defines" to update.
  109293. * @param scene defines the scene the material belongs to.
  109294. * @returns - boolean indicating that the submesh is ready or not.
  109295. */
  109296. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109297. /**
  109298. * Checks to see if a texture is used in the material.
  109299. * @param defines the list of "defines" to update.
  109300. * @param scene defines the scene the material belongs to.
  109301. */
  109302. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109303. /**
  109304. * Binds the material data.
  109305. * @param uniformBuffer defines the Uniform buffer to fill in.
  109306. * @param scene defines the scene the material belongs to.
  109307. * @param isFrozen defines wether the material is frozen or not.
  109308. */
  109309. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109310. /**
  109311. * Checks to see if a texture is used in the material.
  109312. * @param texture - Base texture to use.
  109313. * @returns - Boolean specifying if a texture is used in the material.
  109314. */
  109315. hasTexture(texture: BaseTexture): boolean;
  109316. /**
  109317. * Returns an array of the actively used textures.
  109318. * @param activeTextures Array of BaseTextures
  109319. */
  109320. getActiveTextures(activeTextures: BaseTexture[]): void;
  109321. /**
  109322. * Returns the animatable textures.
  109323. * @param animatables Array of animatable textures.
  109324. */
  109325. getAnimatables(animatables: IAnimatable[]): void;
  109326. /**
  109327. * Disposes the resources of the material.
  109328. * @param forceDisposeTextures - Forces the disposal of all textures.
  109329. */
  109330. dispose(forceDisposeTextures?: boolean): void;
  109331. /**
  109332. * Get the current class name of the texture useful for serialization or dynamic coding.
  109333. * @returns "PBRSheenConfiguration"
  109334. */
  109335. getClassName(): string;
  109336. /**
  109337. * Add fallbacks to the effect fallbacks list.
  109338. * @param defines defines the Base texture to use.
  109339. * @param fallbacks defines the current fallback list.
  109340. * @param currentRank defines the current fallback rank.
  109341. * @returns the new fallback rank.
  109342. */
  109343. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109344. /**
  109345. * Add the required uniforms to the current list.
  109346. * @param uniforms defines the current uniform list.
  109347. */
  109348. static AddUniforms(uniforms: string[]): void;
  109349. /**
  109350. * Add the required uniforms to the current buffer.
  109351. * @param uniformBuffer defines the current uniform buffer.
  109352. */
  109353. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109354. /**
  109355. * Add the required samplers to the current list.
  109356. * @param samplers defines the current sampler list.
  109357. */
  109358. static AddSamplers(samplers: string[]): void;
  109359. /**
  109360. * Makes a duplicate of the current configuration into another one.
  109361. * @param sheenConfiguration define the config where to copy the info
  109362. */
  109363. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109364. /**
  109365. * Serializes this BRDF configuration.
  109366. * @returns - An object with the serialized config.
  109367. */
  109368. serialize(): any;
  109369. /**
  109370. * Parses a anisotropy Configuration from a serialized object.
  109371. * @param source - Serialized object.
  109372. * @param scene Defines the scene we are parsing for
  109373. * @param rootUrl Defines the rootUrl to load from
  109374. */
  109375. parse(source: any, scene: Scene, rootUrl: string): void;
  109376. }
  109377. }
  109378. declare module BABYLON {
  109379. /**
  109380. * @hidden
  109381. */
  109382. export interface IMaterialSubSurfaceDefines {
  109383. SUBSURFACE: boolean;
  109384. SS_REFRACTION: boolean;
  109385. SS_TRANSLUCENCY: boolean;
  109386. SS_SCATERRING: boolean;
  109387. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109388. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109389. SS_REFRACTIONMAP_3D: boolean;
  109390. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109391. SS_LODINREFRACTIONALPHA: boolean;
  109392. SS_GAMMAREFRACTION: boolean;
  109393. SS_RGBDREFRACTION: boolean;
  109394. SS_LINEARSPECULARREFRACTION: boolean;
  109395. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109396. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109397. /** @hidden */
  109398. _areTexturesDirty: boolean;
  109399. }
  109400. /**
  109401. * Define the code related to the sub surface parameters of the pbr material.
  109402. */
  109403. export class PBRSubSurfaceConfiguration {
  109404. private _isRefractionEnabled;
  109405. /**
  109406. * Defines if the refraction is enabled in the material.
  109407. */
  109408. isRefractionEnabled: boolean;
  109409. private _isTranslucencyEnabled;
  109410. /**
  109411. * Defines if the translucency is enabled in the material.
  109412. */
  109413. isTranslucencyEnabled: boolean;
  109414. private _isScatteringEnabled;
  109415. /**
  109416. * Defines the refraction intensity of the material.
  109417. * The refraction when enabled replaces the Diffuse part of the material.
  109418. * The intensity helps transitionning between diffuse and refraction.
  109419. */
  109420. refractionIntensity: number;
  109421. /**
  109422. * Defines the translucency intensity of the material.
  109423. * When translucency has been enabled, this defines how much of the "translucency"
  109424. * is addded to the diffuse part of the material.
  109425. */
  109426. translucencyIntensity: number;
  109427. /**
  109428. * Defines the scattering intensity of the material.
  109429. * When scattering has been enabled, this defines how much of the "scattered light"
  109430. * is addded to the diffuse part of the material.
  109431. */
  109432. scatteringIntensity: number;
  109433. private _thicknessTexture;
  109434. /**
  109435. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109436. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109437. * 0 would mean minimumThickness
  109438. * 1 would mean maximumThickness
  109439. * The other channels might be use as a mask to vary the different effects intensity.
  109440. */
  109441. thicknessTexture: Nullable<BaseTexture>;
  109442. private _refractionTexture;
  109443. /**
  109444. * Defines the texture to use for refraction.
  109445. */
  109446. refractionTexture: Nullable<BaseTexture>;
  109447. private _indexOfRefraction;
  109448. /**
  109449. * Defines the index of refraction used in the material.
  109450. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109451. */
  109452. indexOfRefraction: number;
  109453. private _invertRefractionY;
  109454. /**
  109455. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109456. */
  109457. invertRefractionY: boolean;
  109458. private _linkRefractionWithTransparency;
  109459. /**
  109460. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109461. * Materials half opaque for instance using refraction could benefit from this control.
  109462. */
  109463. linkRefractionWithTransparency: boolean;
  109464. /**
  109465. * Defines the minimum thickness stored in the thickness map.
  109466. * If no thickness map is defined, this value will be used to simulate thickness.
  109467. */
  109468. minimumThickness: number;
  109469. /**
  109470. * Defines the maximum thickness stored in the thickness map.
  109471. */
  109472. maximumThickness: number;
  109473. /**
  109474. * Defines the volume tint of the material.
  109475. * This is used for both translucency and scattering.
  109476. */
  109477. tintColor: Color3;
  109478. /**
  109479. * Defines the distance at which the tint color should be found in the media.
  109480. * This is used for refraction only.
  109481. */
  109482. tintColorAtDistance: number;
  109483. /**
  109484. * Defines how far each channel transmit through the media.
  109485. * It is defined as a color to simplify it selection.
  109486. */
  109487. diffusionDistance: Color3;
  109488. private _useMaskFromThicknessTexture;
  109489. /**
  109490. * Stores the intensity of the different subsurface effects in the thickness texture.
  109491. * * the green channel is the translucency intensity.
  109492. * * the blue channel is the scattering intensity.
  109493. * * the alpha channel is the refraction intensity.
  109494. */
  109495. useMaskFromThicknessTexture: boolean;
  109496. /** @hidden */
  109497. private _internalMarkAllSubMeshesAsTexturesDirty;
  109498. /** @hidden */
  109499. _markAllSubMeshesAsTexturesDirty(): void;
  109500. /**
  109501. * Instantiate a new istance of sub surface configuration.
  109502. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109503. */
  109504. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109505. /**
  109506. * Gets wehter the submesh is ready to be used or not.
  109507. * @param defines the list of "defines" to update.
  109508. * @param scene defines the scene the material belongs to.
  109509. * @returns - boolean indicating that the submesh is ready or not.
  109510. */
  109511. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109512. /**
  109513. * Checks to see if a texture is used in the material.
  109514. * @param defines the list of "defines" to update.
  109515. * @param scene defines the scene to the material belongs to.
  109516. */
  109517. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109518. /**
  109519. * Binds the material data.
  109520. * @param uniformBuffer defines the Uniform buffer to fill in.
  109521. * @param scene defines the scene the material belongs to.
  109522. * @param engine defines the engine the material belongs to.
  109523. * @param isFrozen defines wether the material is frozen or not.
  109524. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109525. */
  109526. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109527. /**
  109528. * Unbinds the material from the mesh.
  109529. * @param activeEffect defines the effect that should be unbound from.
  109530. * @returns true if unbound, otherwise false
  109531. */
  109532. unbind(activeEffect: Effect): boolean;
  109533. /**
  109534. * Returns the texture used for refraction or null if none is used.
  109535. * @param scene defines the scene the material belongs to.
  109536. * @returns - Refraction texture if present. If no refraction texture and refraction
  109537. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109538. */
  109539. private _getRefractionTexture;
  109540. /**
  109541. * Returns true if alpha blending should be disabled.
  109542. */
  109543. readonly disableAlphaBlending: boolean;
  109544. /**
  109545. * Fills the list of render target textures.
  109546. * @param renderTargets the list of render targets to update
  109547. */
  109548. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109549. /**
  109550. * Checks to see if a texture is used in the material.
  109551. * @param texture - Base texture to use.
  109552. * @returns - Boolean specifying if a texture is used in the material.
  109553. */
  109554. hasTexture(texture: BaseTexture): boolean;
  109555. /**
  109556. * Gets a boolean indicating that current material needs to register RTT
  109557. * @returns true if this uses a render target otherwise false.
  109558. */
  109559. hasRenderTargetTextures(): boolean;
  109560. /**
  109561. * Returns an array of the actively used textures.
  109562. * @param activeTextures Array of BaseTextures
  109563. */
  109564. getActiveTextures(activeTextures: BaseTexture[]): void;
  109565. /**
  109566. * Returns the animatable textures.
  109567. * @param animatables Array of animatable textures.
  109568. */
  109569. getAnimatables(animatables: IAnimatable[]): void;
  109570. /**
  109571. * Disposes the resources of the material.
  109572. * @param forceDisposeTextures - Forces the disposal of all textures.
  109573. */
  109574. dispose(forceDisposeTextures?: boolean): void;
  109575. /**
  109576. * Get the current class name of the texture useful for serialization or dynamic coding.
  109577. * @returns "PBRSubSurfaceConfiguration"
  109578. */
  109579. getClassName(): string;
  109580. /**
  109581. * Add fallbacks to the effect fallbacks list.
  109582. * @param defines defines the Base texture to use.
  109583. * @param fallbacks defines the current fallback list.
  109584. * @param currentRank defines the current fallback rank.
  109585. * @returns the new fallback rank.
  109586. */
  109587. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109588. /**
  109589. * Add the required uniforms to the current list.
  109590. * @param uniforms defines the current uniform list.
  109591. */
  109592. static AddUniforms(uniforms: string[]): void;
  109593. /**
  109594. * Add the required samplers to the current list.
  109595. * @param samplers defines the current sampler list.
  109596. */
  109597. static AddSamplers(samplers: string[]): void;
  109598. /**
  109599. * Add the required uniforms to the current buffer.
  109600. * @param uniformBuffer defines the current uniform buffer.
  109601. */
  109602. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109603. /**
  109604. * Makes a duplicate of the current configuration into another one.
  109605. * @param configuration define the config where to copy the info
  109606. */
  109607. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109608. /**
  109609. * Serializes this Sub Surface configuration.
  109610. * @returns - An object with the serialized config.
  109611. */
  109612. serialize(): any;
  109613. /**
  109614. * Parses a anisotropy Configuration from a serialized object.
  109615. * @param source - Serialized object.
  109616. * @param scene Defines the scene we are parsing for
  109617. * @param rootUrl Defines the rootUrl to load from
  109618. */
  109619. parse(source: any, scene: Scene, rootUrl: string): void;
  109620. }
  109621. }
  109622. declare module BABYLON {
  109623. /** @hidden */
  109624. export var pbrFragmentDeclaration: {
  109625. name: string;
  109626. shader: string;
  109627. };
  109628. }
  109629. declare module BABYLON {
  109630. /** @hidden */
  109631. export var pbrUboDeclaration: {
  109632. name: string;
  109633. shader: string;
  109634. };
  109635. }
  109636. declare module BABYLON {
  109637. /** @hidden */
  109638. export var pbrFragmentExtraDeclaration: {
  109639. name: string;
  109640. shader: string;
  109641. };
  109642. }
  109643. declare module BABYLON {
  109644. /** @hidden */
  109645. export var pbrFragmentSamplersDeclaration: {
  109646. name: string;
  109647. shader: string;
  109648. };
  109649. }
  109650. declare module BABYLON {
  109651. /** @hidden */
  109652. export var pbrHelperFunctions: {
  109653. name: string;
  109654. shader: string;
  109655. };
  109656. }
  109657. declare module BABYLON {
  109658. /** @hidden */
  109659. export var harmonicsFunctions: {
  109660. name: string;
  109661. shader: string;
  109662. };
  109663. }
  109664. declare module BABYLON {
  109665. /** @hidden */
  109666. export var pbrDirectLightingSetupFunctions: {
  109667. name: string;
  109668. shader: string;
  109669. };
  109670. }
  109671. declare module BABYLON {
  109672. /** @hidden */
  109673. export var pbrDirectLightingFalloffFunctions: {
  109674. name: string;
  109675. shader: string;
  109676. };
  109677. }
  109678. declare module BABYLON {
  109679. /** @hidden */
  109680. export var pbrBRDFFunctions: {
  109681. name: string;
  109682. shader: string;
  109683. };
  109684. }
  109685. declare module BABYLON {
  109686. /** @hidden */
  109687. export var pbrDirectLightingFunctions: {
  109688. name: string;
  109689. shader: string;
  109690. };
  109691. }
  109692. declare module BABYLON {
  109693. /** @hidden */
  109694. export var pbrIBLFunctions: {
  109695. name: string;
  109696. shader: string;
  109697. };
  109698. }
  109699. declare module BABYLON {
  109700. /** @hidden */
  109701. export var pbrDebug: {
  109702. name: string;
  109703. shader: string;
  109704. };
  109705. }
  109706. declare module BABYLON {
  109707. /** @hidden */
  109708. export var pbrPixelShader: {
  109709. name: string;
  109710. shader: string;
  109711. };
  109712. }
  109713. declare module BABYLON {
  109714. /** @hidden */
  109715. export var pbrVertexDeclaration: {
  109716. name: string;
  109717. shader: string;
  109718. };
  109719. }
  109720. declare module BABYLON {
  109721. /** @hidden */
  109722. export var pbrVertexShader: {
  109723. name: string;
  109724. shader: string;
  109725. };
  109726. }
  109727. declare module BABYLON {
  109728. /**
  109729. * Manages the defines for the PBR Material.
  109730. * @hidden
  109731. */
  109732. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109733. PBR: boolean;
  109734. MAINUV1: boolean;
  109735. MAINUV2: boolean;
  109736. UV1: boolean;
  109737. UV2: boolean;
  109738. ALBEDO: boolean;
  109739. ALBEDODIRECTUV: number;
  109740. VERTEXCOLOR: boolean;
  109741. AMBIENT: boolean;
  109742. AMBIENTDIRECTUV: number;
  109743. AMBIENTINGRAYSCALE: boolean;
  109744. OPACITY: boolean;
  109745. VERTEXALPHA: boolean;
  109746. OPACITYDIRECTUV: number;
  109747. OPACITYRGB: boolean;
  109748. ALPHATEST: boolean;
  109749. DEPTHPREPASS: boolean;
  109750. ALPHABLEND: boolean;
  109751. ALPHAFROMALBEDO: boolean;
  109752. ALPHATESTVALUE: string;
  109753. SPECULAROVERALPHA: boolean;
  109754. RADIANCEOVERALPHA: boolean;
  109755. ALPHAFRESNEL: boolean;
  109756. LINEARALPHAFRESNEL: boolean;
  109757. PREMULTIPLYALPHA: boolean;
  109758. EMISSIVE: boolean;
  109759. EMISSIVEDIRECTUV: number;
  109760. REFLECTIVITY: boolean;
  109761. REFLECTIVITYDIRECTUV: number;
  109762. SPECULARTERM: boolean;
  109763. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109764. MICROSURFACEAUTOMATIC: boolean;
  109765. LODBASEDMICROSFURACE: boolean;
  109766. MICROSURFACEMAP: boolean;
  109767. MICROSURFACEMAPDIRECTUV: number;
  109768. METALLICWORKFLOW: boolean;
  109769. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109770. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109771. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109772. AOSTOREINMETALMAPRED: boolean;
  109773. ENVIRONMENTBRDF: boolean;
  109774. ENVIRONMENTBRDF_RGBD: boolean;
  109775. NORMAL: boolean;
  109776. TANGENT: boolean;
  109777. BUMP: boolean;
  109778. BUMPDIRECTUV: number;
  109779. OBJECTSPACE_NORMALMAP: boolean;
  109780. PARALLAX: boolean;
  109781. PARALLAXOCCLUSION: boolean;
  109782. NORMALXYSCALE: boolean;
  109783. LIGHTMAP: boolean;
  109784. LIGHTMAPDIRECTUV: number;
  109785. USELIGHTMAPASSHADOWMAP: boolean;
  109786. GAMMALIGHTMAP: boolean;
  109787. REFLECTION: boolean;
  109788. REFLECTIONMAP_3D: boolean;
  109789. REFLECTIONMAP_SPHERICAL: boolean;
  109790. REFLECTIONMAP_PLANAR: boolean;
  109791. REFLECTIONMAP_CUBIC: boolean;
  109792. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109793. REFLECTIONMAP_PROJECTION: boolean;
  109794. REFLECTIONMAP_SKYBOX: boolean;
  109795. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109796. REFLECTIONMAP_EXPLICIT: boolean;
  109797. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109798. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109799. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109800. INVERTCUBICMAP: boolean;
  109801. USESPHERICALFROMREFLECTIONMAP: boolean;
  109802. USEIRRADIANCEMAP: boolean;
  109803. SPHERICAL_HARMONICS: boolean;
  109804. USESPHERICALINVERTEX: boolean;
  109805. REFLECTIONMAP_OPPOSITEZ: boolean;
  109806. LODINREFLECTIONALPHA: boolean;
  109807. GAMMAREFLECTION: boolean;
  109808. RGBDREFLECTION: boolean;
  109809. LINEARSPECULARREFLECTION: boolean;
  109810. RADIANCEOCCLUSION: boolean;
  109811. HORIZONOCCLUSION: boolean;
  109812. INSTANCES: boolean;
  109813. NUM_BONE_INFLUENCERS: number;
  109814. BonesPerMesh: number;
  109815. BONETEXTURE: boolean;
  109816. NONUNIFORMSCALING: boolean;
  109817. MORPHTARGETS: boolean;
  109818. MORPHTARGETS_NORMAL: boolean;
  109819. MORPHTARGETS_TANGENT: boolean;
  109820. MORPHTARGETS_UV: boolean;
  109821. NUM_MORPH_INFLUENCERS: number;
  109822. IMAGEPROCESSING: boolean;
  109823. VIGNETTE: boolean;
  109824. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109825. VIGNETTEBLENDMODEOPAQUE: boolean;
  109826. TONEMAPPING: boolean;
  109827. TONEMAPPING_ACES: boolean;
  109828. CONTRAST: boolean;
  109829. COLORCURVES: boolean;
  109830. COLORGRADING: boolean;
  109831. COLORGRADING3D: boolean;
  109832. SAMPLER3DGREENDEPTH: boolean;
  109833. SAMPLER3DBGRMAP: boolean;
  109834. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109835. EXPOSURE: boolean;
  109836. MULTIVIEW: boolean;
  109837. USEPHYSICALLIGHTFALLOFF: boolean;
  109838. USEGLTFLIGHTFALLOFF: boolean;
  109839. TWOSIDEDLIGHTING: boolean;
  109840. SHADOWFLOAT: boolean;
  109841. CLIPPLANE: boolean;
  109842. CLIPPLANE2: boolean;
  109843. CLIPPLANE3: boolean;
  109844. CLIPPLANE4: boolean;
  109845. POINTSIZE: boolean;
  109846. FOG: boolean;
  109847. LOGARITHMICDEPTH: boolean;
  109848. FORCENORMALFORWARD: boolean;
  109849. SPECULARAA: boolean;
  109850. CLEARCOAT: boolean;
  109851. CLEARCOAT_DEFAULTIOR: boolean;
  109852. CLEARCOAT_TEXTURE: boolean;
  109853. CLEARCOAT_TEXTUREDIRECTUV: number;
  109854. CLEARCOAT_BUMP: boolean;
  109855. CLEARCOAT_BUMPDIRECTUV: number;
  109856. CLEARCOAT_TINT: boolean;
  109857. CLEARCOAT_TINT_TEXTURE: boolean;
  109858. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109859. ANISOTROPIC: boolean;
  109860. ANISOTROPIC_TEXTURE: boolean;
  109861. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109862. BRDF_V_HEIGHT_CORRELATED: boolean;
  109863. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109864. SHEEN: boolean;
  109865. SHEEN_TEXTURE: boolean;
  109866. SHEEN_TEXTUREDIRECTUV: number;
  109867. SHEEN_LINKWITHALBEDO: boolean;
  109868. SUBSURFACE: boolean;
  109869. SS_REFRACTION: boolean;
  109870. SS_TRANSLUCENCY: boolean;
  109871. SS_SCATERRING: boolean;
  109872. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109873. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109874. SS_REFRACTIONMAP_3D: boolean;
  109875. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109876. SS_LODINREFRACTIONALPHA: boolean;
  109877. SS_GAMMAREFRACTION: boolean;
  109878. SS_RGBDREFRACTION: boolean;
  109879. SS_LINEARSPECULARREFRACTION: boolean;
  109880. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109881. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109882. UNLIT: boolean;
  109883. DEBUGMODE: number;
  109884. /**
  109885. * Initializes the PBR Material defines.
  109886. */
  109887. constructor();
  109888. /**
  109889. * Resets the PBR Material defines.
  109890. */
  109891. reset(): void;
  109892. }
  109893. /**
  109894. * The Physically based material base class of BJS.
  109895. *
  109896. * This offers the main features of a standard PBR material.
  109897. * For more information, please refer to the documentation :
  109898. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109899. */
  109900. export abstract class PBRBaseMaterial extends PushMaterial {
  109901. /**
  109902. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109903. */
  109904. static readonly PBRMATERIAL_OPAQUE: number;
  109905. /**
  109906. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109907. */
  109908. static readonly PBRMATERIAL_ALPHATEST: number;
  109909. /**
  109910. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109911. */
  109912. static readonly PBRMATERIAL_ALPHABLEND: number;
  109913. /**
  109914. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109915. * They are also discarded below the alpha cutoff threshold to improve performances.
  109916. */
  109917. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109918. /**
  109919. * Defines the default value of how much AO map is occluding the analytical lights
  109920. * (point spot...).
  109921. */
  109922. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109923. /**
  109924. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  109925. */
  109926. static readonly LIGHTFALLOFF_PHYSICAL: number;
  109927. /**
  109928. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  109929. * to enhance interoperability with other engines.
  109930. */
  109931. static readonly LIGHTFALLOFF_GLTF: number;
  109932. /**
  109933. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  109934. * to enhance interoperability with other materials.
  109935. */
  109936. static readonly LIGHTFALLOFF_STANDARD: number;
  109937. /**
  109938. * Intensity of the direct lights e.g. the four lights available in your scene.
  109939. * This impacts both the direct diffuse and specular highlights.
  109940. */
  109941. protected _directIntensity: number;
  109942. /**
  109943. * Intensity of the emissive part of the material.
  109944. * This helps controlling the emissive effect without modifying the emissive color.
  109945. */
  109946. protected _emissiveIntensity: number;
  109947. /**
  109948. * Intensity of the environment e.g. how much the environment will light the object
  109949. * either through harmonics for rough material or through the refelction for shiny ones.
  109950. */
  109951. protected _environmentIntensity: number;
  109952. /**
  109953. * This is a special control allowing the reduction of the specular highlights coming from the
  109954. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109955. */
  109956. protected _specularIntensity: number;
  109957. /**
  109958. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  109959. */
  109960. private _lightingInfos;
  109961. /**
  109962. * Debug Control allowing disabling the bump map on this material.
  109963. */
  109964. protected _disableBumpMap: boolean;
  109965. /**
  109966. * AKA Diffuse Texture in standard nomenclature.
  109967. */
  109968. protected _albedoTexture: Nullable<BaseTexture>;
  109969. /**
  109970. * AKA Occlusion Texture in other nomenclature.
  109971. */
  109972. protected _ambientTexture: Nullable<BaseTexture>;
  109973. /**
  109974. * AKA Occlusion Texture Intensity in other nomenclature.
  109975. */
  109976. protected _ambientTextureStrength: number;
  109977. /**
  109978. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109979. * 1 means it completely occludes it
  109980. * 0 mean it has no impact
  109981. */
  109982. protected _ambientTextureImpactOnAnalyticalLights: number;
  109983. /**
  109984. * Stores the alpha values in a texture.
  109985. */
  109986. protected _opacityTexture: Nullable<BaseTexture>;
  109987. /**
  109988. * Stores the reflection values in a texture.
  109989. */
  109990. protected _reflectionTexture: Nullable<BaseTexture>;
  109991. /**
  109992. * Stores the emissive values in a texture.
  109993. */
  109994. protected _emissiveTexture: Nullable<BaseTexture>;
  109995. /**
  109996. * AKA Specular texture in other nomenclature.
  109997. */
  109998. protected _reflectivityTexture: Nullable<BaseTexture>;
  109999. /**
  110000. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110001. */
  110002. protected _metallicTexture: Nullable<BaseTexture>;
  110003. /**
  110004. * Specifies the metallic scalar of the metallic/roughness workflow.
  110005. * Can also be used to scale the metalness values of the metallic texture.
  110006. */
  110007. protected _metallic: Nullable<number>;
  110008. /**
  110009. * Specifies the roughness scalar of the metallic/roughness workflow.
  110010. * Can also be used to scale the roughness values of the metallic texture.
  110011. */
  110012. protected _roughness: Nullable<number>;
  110013. /**
  110014. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110015. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110016. */
  110017. protected _microSurfaceTexture: Nullable<BaseTexture>;
  110018. /**
  110019. * Stores surface normal data used to displace a mesh in a texture.
  110020. */
  110021. protected _bumpTexture: Nullable<BaseTexture>;
  110022. /**
  110023. * Stores the pre-calculated light information of a mesh in a texture.
  110024. */
  110025. protected _lightmapTexture: Nullable<BaseTexture>;
  110026. /**
  110027. * The color of a material in ambient lighting.
  110028. */
  110029. protected _ambientColor: Color3;
  110030. /**
  110031. * AKA Diffuse Color in other nomenclature.
  110032. */
  110033. protected _albedoColor: Color3;
  110034. /**
  110035. * AKA Specular Color in other nomenclature.
  110036. */
  110037. protected _reflectivityColor: Color3;
  110038. /**
  110039. * The color applied when light is reflected from a material.
  110040. */
  110041. protected _reflectionColor: Color3;
  110042. /**
  110043. * The color applied when light is emitted from a material.
  110044. */
  110045. protected _emissiveColor: Color3;
  110046. /**
  110047. * AKA Glossiness in other nomenclature.
  110048. */
  110049. protected _microSurface: number;
  110050. /**
  110051. * Specifies that the material will use the light map as a show map.
  110052. */
  110053. protected _useLightmapAsShadowmap: boolean;
  110054. /**
  110055. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110056. * makes the reflect vector face the model (under horizon).
  110057. */
  110058. protected _useHorizonOcclusion: boolean;
  110059. /**
  110060. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110061. * too much the area relying on ambient texture to define their ambient occlusion.
  110062. */
  110063. protected _useRadianceOcclusion: boolean;
  110064. /**
  110065. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110066. */
  110067. protected _useAlphaFromAlbedoTexture: boolean;
  110068. /**
  110069. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110070. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110071. */
  110072. protected _useSpecularOverAlpha: boolean;
  110073. /**
  110074. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110075. */
  110076. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110077. /**
  110078. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110079. */
  110080. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110081. /**
  110082. * Specifies if the metallic texture contains the roughness information in its green channel.
  110083. */
  110084. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110085. /**
  110086. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110087. */
  110088. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110089. /**
  110090. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110091. */
  110092. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110093. /**
  110094. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110095. */
  110096. protected _useAmbientInGrayScale: boolean;
  110097. /**
  110098. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110099. * The material will try to infer what glossiness each pixel should be.
  110100. */
  110101. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110102. /**
  110103. * Defines the falloff type used in this material.
  110104. * It by default is Physical.
  110105. */
  110106. protected _lightFalloff: number;
  110107. /**
  110108. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110109. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110110. */
  110111. protected _useRadianceOverAlpha: boolean;
  110112. /**
  110113. * Allows using an object space normal map (instead of tangent space).
  110114. */
  110115. protected _useObjectSpaceNormalMap: boolean;
  110116. /**
  110117. * Allows using the bump map in parallax mode.
  110118. */
  110119. protected _useParallax: boolean;
  110120. /**
  110121. * Allows using the bump map in parallax occlusion mode.
  110122. */
  110123. protected _useParallaxOcclusion: boolean;
  110124. /**
  110125. * Controls the scale bias of the parallax mode.
  110126. */
  110127. protected _parallaxScaleBias: number;
  110128. /**
  110129. * If sets to true, disables all the lights affecting the material.
  110130. */
  110131. protected _disableLighting: boolean;
  110132. /**
  110133. * Number of Simultaneous lights allowed on the material.
  110134. */
  110135. protected _maxSimultaneousLights: number;
  110136. /**
  110137. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110138. */
  110139. protected _invertNormalMapX: boolean;
  110140. /**
  110141. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110142. */
  110143. protected _invertNormalMapY: boolean;
  110144. /**
  110145. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110146. */
  110147. protected _twoSidedLighting: boolean;
  110148. /**
  110149. * Defines the alpha limits in alpha test mode.
  110150. */
  110151. protected _alphaCutOff: number;
  110152. /**
  110153. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110154. */
  110155. protected _forceAlphaTest: boolean;
  110156. /**
  110157. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110158. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110159. */
  110160. protected _useAlphaFresnel: boolean;
  110161. /**
  110162. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110163. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110164. */
  110165. protected _useLinearAlphaFresnel: boolean;
  110166. /**
  110167. * The transparency mode of the material.
  110168. */
  110169. protected _transparencyMode: Nullable<number>;
  110170. /**
  110171. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110172. * from cos thetav and roughness:
  110173. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110174. */
  110175. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110176. /**
  110177. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110178. */
  110179. protected _forceIrradianceInFragment: boolean;
  110180. /**
  110181. * Force normal to face away from face.
  110182. */
  110183. protected _forceNormalForward: boolean;
  110184. /**
  110185. * Enables specular anti aliasing in the PBR shader.
  110186. * It will both interacts on the Geometry for analytical and IBL lighting.
  110187. * It also prefilter the roughness map based on the bump values.
  110188. */
  110189. protected _enableSpecularAntiAliasing: boolean;
  110190. /**
  110191. * Default configuration related to image processing available in the PBR Material.
  110192. */
  110193. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110194. /**
  110195. * Keep track of the image processing observer to allow dispose and replace.
  110196. */
  110197. private _imageProcessingObserver;
  110198. /**
  110199. * Attaches a new image processing configuration to the PBR Material.
  110200. * @param configuration
  110201. */
  110202. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110203. /**
  110204. * Stores the available render targets.
  110205. */
  110206. private _renderTargets;
  110207. /**
  110208. * Sets the global ambient color for the material used in lighting calculations.
  110209. */
  110210. private _globalAmbientColor;
  110211. /**
  110212. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110213. */
  110214. private _useLogarithmicDepth;
  110215. /**
  110216. * If set to true, no lighting calculations will be applied.
  110217. */
  110218. private _unlit;
  110219. private _debugMode;
  110220. /**
  110221. * @hidden
  110222. * This is reserved for the inspector.
  110223. * Defines the material debug mode.
  110224. * It helps seeing only some components of the material while troubleshooting.
  110225. */
  110226. debugMode: number;
  110227. /**
  110228. * @hidden
  110229. * This is reserved for the inspector.
  110230. * Specify from where on screen the debug mode should start.
  110231. * The value goes from -1 (full screen) to 1 (not visible)
  110232. * It helps with side by side comparison against the final render
  110233. * This defaults to -1
  110234. */
  110235. private debugLimit;
  110236. /**
  110237. * @hidden
  110238. * This is reserved for the inspector.
  110239. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110240. * You can use the factor to better multiply the final value.
  110241. */
  110242. private debugFactor;
  110243. /**
  110244. * Defines the clear coat layer parameters for the material.
  110245. */
  110246. readonly clearCoat: PBRClearCoatConfiguration;
  110247. /**
  110248. * Defines the anisotropic parameters for the material.
  110249. */
  110250. readonly anisotropy: PBRAnisotropicConfiguration;
  110251. /**
  110252. * Defines the BRDF parameters for the material.
  110253. */
  110254. readonly brdf: PBRBRDFConfiguration;
  110255. /**
  110256. * Defines the Sheen parameters for the material.
  110257. */
  110258. readonly sheen: PBRSheenConfiguration;
  110259. /**
  110260. * Defines the SubSurface parameters for the material.
  110261. */
  110262. readonly subSurface: PBRSubSurfaceConfiguration;
  110263. /**
  110264. * Custom callback helping to override the default shader used in the material.
  110265. */
  110266. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110267. /**
  110268. * Instantiates a new PBRMaterial instance.
  110269. *
  110270. * @param name The material name
  110271. * @param scene The scene the material will be use in.
  110272. */
  110273. constructor(name: string, scene: Scene);
  110274. /**
  110275. * Gets a boolean indicating that current material needs to register RTT
  110276. */
  110277. readonly hasRenderTargetTextures: boolean;
  110278. /**
  110279. * Gets the name of the material class.
  110280. */
  110281. getClassName(): string;
  110282. /**
  110283. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110284. */
  110285. /**
  110286. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110287. */
  110288. useLogarithmicDepth: boolean;
  110289. /**
  110290. * Gets the current transparency mode.
  110291. */
  110292. /**
  110293. * Sets the transparency mode of the material.
  110294. *
  110295. * | Value | Type | Description |
  110296. * | ----- | ----------------------------------- | ----------- |
  110297. * | 0 | OPAQUE | |
  110298. * | 1 | ALPHATEST | |
  110299. * | 2 | ALPHABLEND | |
  110300. * | 3 | ALPHATESTANDBLEND | |
  110301. *
  110302. */
  110303. transparencyMode: Nullable<number>;
  110304. /**
  110305. * Returns true if alpha blending should be disabled.
  110306. */
  110307. private readonly _disableAlphaBlending;
  110308. /**
  110309. * Specifies whether or not this material should be rendered in alpha blend mode.
  110310. */
  110311. needAlphaBlending(): boolean;
  110312. /**
  110313. * Specifies if the mesh will require alpha blending.
  110314. * @param mesh - BJS mesh.
  110315. */
  110316. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110317. /**
  110318. * Specifies whether or not this material should be rendered in alpha test mode.
  110319. */
  110320. needAlphaTesting(): boolean;
  110321. /**
  110322. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110323. */
  110324. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110325. /**
  110326. * Gets the texture used for the alpha test.
  110327. */
  110328. getAlphaTestTexture(): Nullable<BaseTexture>;
  110329. /**
  110330. * Specifies that the submesh is ready to be used.
  110331. * @param mesh - BJS mesh.
  110332. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110333. * @param useInstances - Specifies that instances should be used.
  110334. * @returns - boolean indicating that the submesh is ready or not.
  110335. */
  110336. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110337. /**
  110338. * Specifies if the material uses metallic roughness workflow.
  110339. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110340. */
  110341. isMetallicWorkflow(): boolean;
  110342. private _prepareEffect;
  110343. private _prepareDefines;
  110344. /**
  110345. * Force shader compilation
  110346. */
  110347. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110348. clipPlane: boolean;
  110349. }>): void;
  110350. /**
  110351. * Initializes the uniform buffer layout for the shader.
  110352. */
  110353. buildUniformLayout(): void;
  110354. /**
  110355. * Unbinds the material from the mesh
  110356. */
  110357. unbind(): void;
  110358. /**
  110359. * Binds the submesh data.
  110360. * @param world - The world matrix.
  110361. * @param mesh - The BJS mesh.
  110362. * @param subMesh - A submesh of the BJS mesh.
  110363. */
  110364. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110365. /**
  110366. * Returns the animatable textures.
  110367. * @returns - Array of animatable textures.
  110368. */
  110369. getAnimatables(): IAnimatable[];
  110370. /**
  110371. * Returns the texture used for reflections.
  110372. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110373. */
  110374. private _getReflectionTexture;
  110375. /**
  110376. * Returns an array of the actively used textures.
  110377. * @returns - Array of BaseTextures
  110378. */
  110379. getActiveTextures(): BaseTexture[];
  110380. /**
  110381. * Checks to see if a texture is used in the material.
  110382. * @param texture - Base texture to use.
  110383. * @returns - Boolean specifying if a texture is used in the material.
  110384. */
  110385. hasTexture(texture: BaseTexture): boolean;
  110386. /**
  110387. * Disposes the resources of the material.
  110388. * @param forceDisposeEffect - Forces the disposal of effects.
  110389. * @param forceDisposeTextures - Forces the disposal of all textures.
  110390. */
  110391. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110392. }
  110393. }
  110394. declare module BABYLON {
  110395. /**
  110396. * The Physically based material of BJS.
  110397. *
  110398. * This offers the main features of a standard PBR material.
  110399. * For more information, please refer to the documentation :
  110400. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110401. */
  110402. export class PBRMaterial extends PBRBaseMaterial {
  110403. /**
  110404. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110405. */
  110406. static readonly PBRMATERIAL_OPAQUE: number;
  110407. /**
  110408. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110409. */
  110410. static readonly PBRMATERIAL_ALPHATEST: number;
  110411. /**
  110412. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110413. */
  110414. static readonly PBRMATERIAL_ALPHABLEND: number;
  110415. /**
  110416. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110417. * They are also discarded below the alpha cutoff threshold to improve performances.
  110418. */
  110419. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110420. /**
  110421. * Defines the default value of how much AO map is occluding the analytical lights
  110422. * (point spot...).
  110423. */
  110424. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110425. /**
  110426. * Intensity of the direct lights e.g. the four lights available in your scene.
  110427. * This impacts both the direct diffuse and specular highlights.
  110428. */
  110429. directIntensity: number;
  110430. /**
  110431. * Intensity of the emissive part of the material.
  110432. * This helps controlling the emissive effect without modifying the emissive color.
  110433. */
  110434. emissiveIntensity: number;
  110435. /**
  110436. * Intensity of the environment e.g. how much the environment will light the object
  110437. * either through harmonics for rough material or through the refelction for shiny ones.
  110438. */
  110439. environmentIntensity: number;
  110440. /**
  110441. * This is a special control allowing the reduction of the specular highlights coming from the
  110442. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110443. */
  110444. specularIntensity: number;
  110445. /**
  110446. * Debug Control allowing disabling the bump map on this material.
  110447. */
  110448. disableBumpMap: boolean;
  110449. /**
  110450. * AKA Diffuse Texture in standard nomenclature.
  110451. */
  110452. albedoTexture: BaseTexture;
  110453. /**
  110454. * AKA Occlusion Texture in other nomenclature.
  110455. */
  110456. ambientTexture: BaseTexture;
  110457. /**
  110458. * AKA Occlusion Texture Intensity in other nomenclature.
  110459. */
  110460. ambientTextureStrength: number;
  110461. /**
  110462. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110463. * 1 means it completely occludes it
  110464. * 0 mean it has no impact
  110465. */
  110466. ambientTextureImpactOnAnalyticalLights: number;
  110467. /**
  110468. * Stores the alpha values in a texture.
  110469. */
  110470. opacityTexture: BaseTexture;
  110471. /**
  110472. * Stores the reflection values in a texture.
  110473. */
  110474. reflectionTexture: Nullable<BaseTexture>;
  110475. /**
  110476. * Stores the emissive values in a texture.
  110477. */
  110478. emissiveTexture: BaseTexture;
  110479. /**
  110480. * AKA Specular texture in other nomenclature.
  110481. */
  110482. reflectivityTexture: BaseTexture;
  110483. /**
  110484. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110485. */
  110486. metallicTexture: BaseTexture;
  110487. /**
  110488. * Specifies the metallic scalar of the metallic/roughness workflow.
  110489. * Can also be used to scale the metalness values of the metallic texture.
  110490. */
  110491. metallic: Nullable<number>;
  110492. /**
  110493. * Specifies the roughness scalar of the metallic/roughness workflow.
  110494. * Can also be used to scale the roughness values of the metallic texture.
  110495. */
  110496. roughness: Nullable<number>;
  110497. /**
  110498. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110499. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110500. */
  110501. microSurfaceTexture: BaseTexture;
  110502. /**
  110503. * Stores surface normal data used to displace a mesh in a texture.
  110504. */
  110505. bumpTexture: BaseTexture;
  110506. /**
  110507. * Stores the pre-calculated light information of a mesh in a texture.
  110508. */
  110509. lightmapTexture: BaseTexture;
  110510. /**
  110511. * Stores the refracted light information in a texture.
  110512. */
  110513. refractionTexture: Nullable<BaseTexture>;
  110514. /**
  110515. * The color of a material in ambient lighting.
  110516. */
  110517. ambientColor: Color3;
  110518. /**
  110519. * AKA Diffuse Color in other nomenclature.
  110520. */
  110521. albedoColor: Color3;
  110522. /**
  110523. * AKA Specular Color in other nomenclature.
  110524. */
  110525. reflectivityColor: Color3;
  110526. /**
  110527. * The color reflected from the material.
  110528. */
  110529. reflectionColor: Color3;
  110530. /**
  110531. * The color emitted from the material.
  110532. */
  110533. emissiveColor: Color3;
  110534. /**
  110535. * AKA Glossiness in other nomenclature.
  110536. */
  110537. microSurface: number;
  110538. /**
  110539. * source material index of refraction (IOR)' / 'destination material IOR.
  110540. */
  110541. indexOfRefraction: number;
  110542. /**
  110543. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110544. */
  110545. invertRefractionY: boolean;
  110546. /**
  110547. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110548. * Materials half opaque for instance using refraction could benefit from this control.
  110549. */
  110550. linkRefractionWithTransparency: boolean;
  110551. /**
  110552. * If true, the light map contains occlusion information instead of lighting info.
  110553. */
  110554. useLightmapAsShadowmap: boolean;
  110555. /**
  110556. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110557. */
  110558. useAlphaFromAlbedoTexture: boolean;
  110559. /**
  110560. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110561. */
  110562. forceAlphaTest: boolean;
  110563. /**
  110564. * Defines the alpha limits in alpha test mode.
  110565. */
  110566. alphaCutOff: number;
  110567. /**
  110568. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110569. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110570. */
  110571. useSpecularOverAlpha: boolean;
  110572. /**
  110573. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110574. */
  110575. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110576. /**
  110577. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110578. */
  110579. useRoughnessFromMetallicTextureAlpha: boolean;
  110580. /**
  110581. * Specifies if the metallic texture contains the roughness information in its green channel.
  110582. */
  110583. useRoughnessFromMetallicTextureGreen: boolean;
  110584. /**
  110585. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110586. */
  110587. useMetallnessFromMetallicTextureBlue: boolean;
  110588. /**
  110589. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110590. */
  110591. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110592. /**
  110593. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110594. */
  110595. useAmbientInGrayScale: boolean;
  110596. /**
  110597. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110598. * The material will try to infer what glossiness each pixel should be.
  110599. */
  110600. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110601. /**
  110602. * BJS is using an harcoded light falloff based on a manually sets up range.
  110603. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110604. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110605. */
  110606. /**
  110607. * BJS is using an harcoded light falloff based on a manually sets up range.
  110608. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110609. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110610. */
  110611. usePhysicalLightFalloff: boolean;
  110612. /**
  110613. * In order to support the falloff compatibility with gltf, a special mode has been added
  110614. * to reproduce the gltf light falloff.
  110615. */
  110616. /**
  110617. * In order to support the falloff compatibility with gltf, a special mode has been added
  110618. * to reproduce the gltf light falloff.
  110619. */
  110620. useGLTFLightFalloff: boolean;
  110621. /**
  110622. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110623. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110624. */
  110625. useRadianceOverAlpha: boolean;
  110626. /**
  110627. * Allows using an object space normal map (instead of tangent space).
  110628. */
  110629. useObjectSpaceNormalMap: boolean;
  110630. /**
  110631. * Allows using the bump map in parallax mode.
  110632. */
  110633. useParallax: boolean;
  110634. /**
  110635. * Allows using the bump map in parallax occlusion mode.
  110636. */
  110637. useParallaxOcclusion: boolean;
  110638. /**
  110639. * Controls the scale bias of the parallax mode.
  110640. */
  110641. parallaxScaleBias: number;
  110642. /**
  110643. * If sets to true, disables all the lights affecting the material.
  110644. */
  110645. disableLighting: boolean;
  110646. /**
  110647. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110648. */
  110649. forceIrradianceInFragment: boolean;
  110650. /**
  110651. * Number of Simultaneous lights allowed on the material.
  110652. */
  110653. maxSimultaneousLights: number;
  110654. /**
  110655. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110656. */
  110657. invertNormalMapX: boolean;
  110658. /**
  110659. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110660. */
  110661. invertNormalMapY: boolean;
  110662. /**
  110663. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110664. */
  110665. twoSidedLighting: boolean;
  110666. /**
  110667. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110668. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110669. */
  110670. useAlphaFresnel: boolean;
  110671. /**
  110672. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110673. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110674. */
  110675. useLinearAlphaFresnel: boolean;
  110676. /**
  110677. * Let user defines the brdf lookup texture used for IBL.
  110678. * A default 8bit version is embedded but you could point at :
  110679. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110680. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110681. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110682. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110683. */
  110684. environmentBRDFTexture: Nullable<BaseTexture>;
  110685. /**
  110686. * Force normal to face away from face.
  110687. */
  110688. forceNormalForward: boolean;
  110689. /**
  110690. * Enables specular anti aliasing in the PBR shader.
  110691. * It will both interacts on the Geometry for analytical and IBL lighting.
  110692. * It also prefilter the roughness map based on the bump values.
  110693. */
  110694. enableSpecularAntiAliasing: boolean;
  110695. /**
  110696. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110697. * makes the reflect vector face the model (under horizon).
  110698. */
  110699. useHorizonOcclusion: boolean;
  110700. /**
  110701. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110702. * too much the area relying on ambient texture to define their ambient occlusion.
  110703. */
  110704. useRadianceOcclusion: boolean;
  110705. /**
  110706. * If set to true, no lighting calculations will be applied.
  110707. */
  110708. unlit: boolean;
  110709. /**
  110710. * Gets the image processing configuration used either in this material.
  110711. */
  110712. /**
  110713. * Sets the Default image processing configuration used either in the this material.
  110714. *
  110715. * If sets to null, the scene one is in use.
  110716. */
  110717. imageProcessingConfiguration: ImageProcessingConfiguration;
  110718. /**
  110719. * Gets wether the color curves effect is enabled.
  110720. */
  110721. /**
  110722. * Sets wether the color curves effect is enabled.
  110723. */
  110724. cameraColorCurvesEnabled: boolean;
  110725. /**
  110726. * Gets wether the color grading effect is enabled.
  110727. */
  110728. /**
  110729. * Gets wether the color grading effect is enabled.
  110730. */
  110731. cameraColorGradingEnabled: boolean;
  110732. /**
  110733. * Gets wether tonemapping is enabled or not.
  110734. */
  110735. /**
  110736. * Sets wether tonemapping is enabled or not
  110737. */
  110738. cameraToneMappingEnabled: boolean;
  110739. /**
  110740. * The camera exposure used on this material.
  110741. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110742. * This corresponds to a photographic exposure.
  110743. */
  110744. /**
  110745. * The camera exposure used on this material.
  110746. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110747. * This corresponds to a photographic exposure.
  110748. */
  110749. cameraExposure: number;
  110750. /**
  110751. * Gets The camera contrast used on this material.
  110752. */
  110753. /**
  110754. * Sets The camera contrast used on this material.
  110755. */
  110756. cameraContrast: number;
  110757. /**
  110758. * Gets the Color Grading 2D Lookup Texture.
  110759. */
  110760. /**
  110761. * Sets the Color Grading 2D Lookup Texture.
  110762. */
  110763. cameraColorGradingTexture: Nullable<BaseTexture>;
  110764. /**
  110765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110767. * 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;
  110768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110769. */
  110770. /**
  110771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110773. * 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;
  110774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110775. */
  110776. cameraColorCurves: Nullable<ColorCurves>;
  110777. /**
  110778. * Instantiates a new PBRMaterial instance.
  110779. *
  110780. * @param name The material name
  110781. * @param scene The scene the material will be use in.
  110782. */
  110783. constructor(name: string, scene: Scene);
  110784. /**
  110785. * Returns the name of this material class.
  110786. */
  110787. getClassName(): string;
  110788. /**
  110789. * Makes a duplicate of the current material.
  110790. * @param name - name to use for the new material.
  110791. */
  110792. clone(name: string): PBRMaterial;
  110793. /**
  110794. * Serializes this PBR Material.
  110795. * @returns - An object with the serialized material.
  110796. */
  110797. serialize(): any;
  110798. /**
  110799. * Parses a PBR Material from a serialized object.
  110800. * @param source - Serialized object.
  110801. * @param scene - BJS scene instance.
  110802. * @param rootUrl - url for the scene object
  110803. * @returns - PBRMaterial
  110804. */
  110805. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110806. }
  110807. }
  110808. declare module BABYLON {
  110809. /**
  110810. * Direct draw surface info
  110811. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  110812. */
  110813. export interface DDSInfo {
  110814. /**
  110815. * Width of the texture
  110816. */
  110817. width: number;
  110818. /**
  110819. * Width of the texture
  110820. */
  110821. height: number;
  110822. /**
  110823. * Number of Mipmaps for the texture
  110824. * @see https://en.wikipedia.org/wiki/Mipmap
  110825. */
  110826. mipmapCount: number;
  110827. /**
  110828. * If the textures format is a known fourCC format
  110829. * @see https://www.fourcc.org/
  110830. */
  110831. isFourCC: boolean;
  110832. /**
  110833. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  110834. */
  110835. isRGB: boolean;
  110836. /**
  110837. * If the texture is a lumincance format
  110838. */
  110839. isLuminance: boolean;
  110840. /**
  110841. * If this is a cube texture
  110842. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  110843. */
  110844. isCube: boolean;
  110845. /**
  110846. * If the texture is a compressed format eg. FOURCC_DXT1
  110847. */
  110848. isCompressed: boolean;
  110849. /**
  110850. * The dxgiFormat of the texture
  110851. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  110852. */
  110853. dxgiFormat: number;
  110854. /**
  110855. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  110856. */
  110857. textureType: number;
  110858. /**
  110859. * Sphericle polynomial created for the dds texture
  110860. */
  110861. sphericalPolynomial?: SphericalPolynomial;
  110862. }
  110863. /**
  110864. * Class used to provide DDS decompression tools
  110865. */
  110866. export class DDSTools {
  110867. /**
  110868. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  110869. */
  110870. static StoreLODInAlphaChannel: boolean;
  110871. /**
  110872. * Gets DDS information from an array buffer
  110873. * @param arrayBuffer defines the array buffer to read data from
  110874. * @returns the DDS information
  110875. */
  110876. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  110877. private static _FloatView;
  110878. private static _Int32View;
  110879. private static _ToHalfFloat;
  110880. private static _FromHalfFloat;
  110881. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  110882. private static _GetHalfFloatRGBAArrayBuffer;
  110883. private static _GetFloatRGBAArrayBuffer;
  110884. private static _GetFloatAsUIntRGBAArrayBuffer;
  110885. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  110886. private static _GetRGBAArrayBuffer;
  110887. private static _ExtractLongWordOrder;
  110888. private static _GetRGBArrayBuffer;
  110889. private static _GetLuminanceArrayBuffer;
  110890. /**
  110891. * Uploads DDS Levels to a Babylon Texture
  110892. * @hidden
  110893. */
  110894. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  110895. }
  110896. interface Engine {
  110897. /**
  110898. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  110899. * @param rootUrl defines the url where the file to load is located
  110900. * @param scene defines the current scene
  110901. * @param lodScale defines scale to apply to the mip map selection
  110902. * @param lodOffset defines offset to apply to the mip map selection
  110903. * @param onLoad defines an optional callback raised when the texture is loaded
  110904. * @param onError defines an optional callback raised if there is an issue to load the texture
  110905. * @param format defines the format of the data
  110906. * @param forcedExtension defines the extension to use to pick the right loader
  110907. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  110908. * @returns the cube texture as an InternalTexture
  110909. */
  110910. 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;
  110911. }
  110912. }
  110913. declare module BABYLON {
  110914. /**
  110915. * Implementation of the DDS Texture Loader.
  110916. * @hidden
  110917. */
  110918. export class _DDSTextureLoader implements IInternalTextureLoader {
  110919. /**
  110920. * Defines wether the loader supports cascade loading the different faces.
  110921. */
  110922. readonly supportCascades: boolean;
  110923. /**
  110924. * This returns if the loader support the current file information.
  110925. * @param extension defines the file extension of the file being loaded
  110926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110927. * @param fallback defines the fallback internal texture if any
  110928. * @param isBase64 defines whether the texture is encoded as a base64
  110929. * @param isBuffer defines whether the texture data are stored as a buffer
  110930. * @returns true if the loader can load the specified file
  110931. */
  110932. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110933. /**
  110934. * Transform the url before loading if required.
  110935. * @param rootUrl the url of the texture
  110936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110937. * @returns the transformed texture
  110938. */
  110939. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110940. /**
  110941. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110942. * @param rootUrl the url of the texture
  110943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110944. * @returns the fallback texture
  110945. */
  110946. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110947. /**
  110948. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110949. * @param data contains the texture data
  110950. * @param texture defines the BabylonJS internal texture
  110951. * @param createPolynomials will be true if polynomials have been requested
  110952. * @param onLoad defines the callback to trigger once the texture is ready
  110953. * @param onError defines the callback to trigger in case of error
  110954. */
  110955. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110956. /**
  110957. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110958. * @param data contains the texture data
  110959. * @param texture defines the BabylonJS internal texture
  110960. * @param callback defines the method to call once ready to upload
  110961. */
  110962. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110963. }
  110964. }
  110965. declare module BABYLON {
  110966. /** @hidden */
  110967. export var rgbdEncodePixelShader: {
  110968. name: string;
  110969. shader: string;
  110970. };
  110971. }
  110972. declare module BABYLON {
  110973. /**
  110974. * Raw texture data and descriptor sufficient for WebGL texture upload
  110975. */
  110976. export interface EnvironmentTextureInfo {
  110977. /**
  110978. * Version of the environment map
  110979. */
  110980. version: number;
  110981. /**
  110982. * Width of image
  110983. */
  110984. width: number;
  110985. /**
  110986. * Irradiance information stored in the file.
  110987. */
  110988. irradiance: any;
  110989. /**
  110990. * Specular information stored in the file.
  110991. */
  110992. specular: any;
  110993. }
  110994. /**
  110995. * Sets of helpers addressing the serialization and deserialization of environment texture
  110996. * stored in a BabylonJS env file.
  110997. * Those files are usually stored as .env files.
  110998. */
  110999. export class EnvironmentTextureTools {
  111000. /**
  111001. * Magic number identifying the env file.
  111002. */
  111003. private static _MagicBytes;
  111004. /**
  111005. * Gets the environment info from an env file.
  111006. * @param data The array buffer containing the .env bytes.
  111007. * @returns the environment file info (the json header) if successfully parsed.
  111008. */
  111009. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111010. /**
  111011. * Creates an environment texture from a loaded cube texture.
  111012. * @param texture defines the cube texture to convert in env file
  111013. * @return a promise containing the environment data if succesfull.
  111014. */
  111015. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111016. /**
  111017. * Creates a JSON representation of the spherical data.
  111018. * @param texture defines the texture containing the polynomials
  111019. * @return the JSON representation of the spherical info
  111020. */
  111021. private static _CreateEnvTextureIrradiance;
  111022. /**
  111023. * Uploads the texture info contained in the env file to the GPU.
  111024. * @param texture defines the internal texture to upload to
  111025. * @param arrayBuffer defines the buffer cotaining the data to load
  111026. * @param info defines the texture info retrieved through the GetEnvInfo method
  111027. * @returns a promise
  111028. */
  111029. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111030. /**
  111031. * Uploads the levels of image data to the GPU.
  111032. * @param texture defines the internal texture to upload to
  111033. * @param imageData defines the array buffer views of image data [mipmap][face]
  111034. * @returns a promise
  111035. */
  111036. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111037. /**
  111038. * Uploads spherical polynomials information to the texture.
  111039. * @param texture defines the texture we are trying to upload the information to
  111040. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111041. */
  111042. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111043. /** @hidden */
  111044. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111045. }
  111046. }
  111047. declare module BABYLON {
  111048. /**
  111049. * Implementation of the ENV Texture Loader.
  111050. * @hidden
  111051. */
  111052. export class _ENVTextureLoader implements IInternalTextureLoader {
  111053. /**
  111054. * Defines wether the loader supports cascade loading the different faces.
  111055. */
  111056. readonly supportCascades: boolean;
  111057. /**
  111058. * This returns if the loader support the current file information.
  111059. * @param extension defines the file extension of the file being loaded
  111060. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111061. * @param fallback defines the fallback internal texture if any
  111062. * @param isBase64 defines whether the texture is encoded as a base64
  111063. * @param isBuffer defines whether the texture data are stored as a buffer
  111064. * @returns true if the loader can load the specified file
  111065. */
  111066. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111067. /**
  111068. * Transform the url before loading if required.
  111069. * @param rootUrl the url of the texture
  111070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111071. * @returns the transformed texture
  111072. */
  111073. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111074. /**
  111075. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111076. * @param rootUrl the url of the texture
  111077. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111078. * @returns the fallback texture
  111079. */
  111080. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111081. /**
  111082. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111083. * @param data contains the texture data
  111084. * @param texture defines the BabylonJS internal texture
  111085. * @param createPolynomials will be true if polynomials have been requested
  111086. * @param onLoad defines the callback to trigger once the texture is ready
  111087. * @param onError defines the callback to trigger in case of error
  111088. */
  111089. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111090. /**
  111091. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111092. * @param data contains the texture data
  111093. * @param texture defines the BabylonJS internal texture
  111094. * @param callback defines the method to call once ready to upload
  111095. */
  111096. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111097. }
  111098. }
  111099. declare module BABYLON {
  111100. /**
  111101. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111102. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111103. */
  111104. export class KhronosTextureContainer {
  111105. /** contents of the KTX container file */
  111106. arrayBuffer: any;
  111107. private static HEADER_LEN;
  111108. private static COMPRESSED_2D;
  111109. private static COMPRESSED_3D;
  111110. private static TEX_2D;
  111111. private static TEX_3D;
  111112. /**
  111113. * Gets the openGL type
  111114. */
  111115. glType: number;
  111116. /**
  111117. * Gets the openGL type size
  111118. */
  111119. glTypeSize: number;
  111120. /**
  111121. * Gets the openGL format
  111122. */
  111123. glFormat: number;
  111124. /**
  111125. * Gets the openGL internal format
  111126. */
  111127. glInternalFormat: number;
  111128. /**
  111129. * Gets the base internal format
  111130. */
  111131. glBaseInternalFormat: number;
  111132. /**
  111133. * Gets image width in pixel
  111134. */
  111135. pixelWidth: number;
  111136. /**
  111137. * Gets image height in pixel
  111138. */
  111139. pixelHeight: number;
  111140. /**
  111141. * Gets image depth in pixels
  111142. */
  111143. pixelDepth: number;
  111144. /**
  111145. * Gets the number of array elements
  111146. */
  111147. numberOfArrayElements: number;
  111148. /**
  111149. * Gets the number of faces
  111150. */
  111151. numberOfFaces: number;
  111152. /**
  111153. * Gets the number of mipmap levels
  111154. */
  111155. numberOfMipmapLevels: number;
  111156. /**
  111157. * Gets the bytes of key value data
  111158. */
  111159. bytesOfKeyValueData: number;
  111160. /**
  111161. * Gets the load type
  111162. */
  111163. loadType: number;
  111164. /**
  111165. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111166. */
  111167. isInvalid: boolean;
  111168. /**
  111169. * Creates a new KhronosTextureContainer
  111170. * @param arrayBuffer contents of the KTX container file
  111171. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111172. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111173. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111174. */
  111175. constructor(
  111176. /** contents of the KTX container file */
  111177. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111178. /**
  111179. * Uploads KTX content to a Babylon Texture.
  111180. * It is assumed that the texture has already been created & is currently bound
  111181. * @hidden
  111182. */
  111183. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111184. private _upload2DCompressedLevels;
  111185. }
  111186. }
  111187. declare module BABYLON {
  111188. /**
  111189. * Implementation of the KTX Texture Loader.
  111190. * @hidden
  111191. */
  111192. export class _KTXTextureLoader implements IInternalTextureLoader {
  111193. /**
  111194. * Defines wether the loader supports cascade loading the different faces.
  111195. */
  111196. readonly supportCascades: boolean;
  111197. /**
  111198. * This returns if the loader support the current file information.
  111199. * @param extension defines the file extension of the file being loaded
  111200. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111201. * @param fallback defines the fallback internal texture if any
  111202. * @param isBase64 defines whether the texture is encoded as a base64
  111203. * @param isBuffer defines whether the texture data are stored as a buffer
  111204. * @returns true if the loader can load the specified file
  111205. */
  111206. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111207. /**
  111208. * Transform the url before loading if required.
  111209. * @param rootUrl the url of the texture
  111210. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111211. * @returns the transformed texture
  111212. */
  111213. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111214. /**
  111215. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111216. * @param rootUrl the url of the texture
  111217. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111218. * @returns the fallback texture
  111219. */
  111220. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111221. /**
  111222. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111223. * @param data contains the texture data
  111224. * @param texture defines the BabylonJS internal texture
  111225. * @param createPolynomials will be true if polynomials have been requested
  111226. * @param onLoad defines the callback to trigger once the texture is ready
  111227. * @param onError defines the callback to trigger in case of error
  111228. */
  111229. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111230. /**
  111231. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111232. * @param data contains the texture data
  111233. * @param texture defines the BabylonJS internal texture
  111234. * @param callback defines the method to call once ready to upload
  111235. */
  111236. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111237. }
  111238. }
  111239. declare module BABYLON {
  111240. /**
  111241. * Options for the default xr helper
  111242. */
  111243. export class WebXRDefaultExperienceOptions {
  111244. /**
  111245. * Floor meshes that should be used for teleporting
  111246. */
  111247. floorMeshes: Array<AbstractMesh>;
  111248. }
  111249. /**
  111250. * Default experience which provides a similar setup to the previous webVRExperience
  111251. */
  111252. export class WebXRDefaultExperience {
  111253. /**
  111254. * Base experience
  111255. */
  111256. baseExperience: WebXRExperienceHelper;
  111257. /**
  111258. * Input experience extension
  111259. */
  111260. input: WebXRInput;
  111261. /**
  111262. * Loads the controller models
  111263. */
  111264. controllerModelLoader: WebXRControllerModelLoader;
  111265. /**
  111266. * Enables laser pointer and selection
  111267. */
  111268. pointerSelection: WebXRControllerPointerSelection;
  111269. /**
  111270. * Enables teleportation
  111271. */
  111272. teleportation: WebXRControllerTeleportation;
  111273. /**
  111274. * Enables ui for enetering/exiting xr
  111275. */
  111276. enterExitUI: WebXREnterExitUI;
  111277. /**
  111278. * Default output canvas xr should render to
  111279. */
  111280. outputCanvas: WebXRManagedOutputCanvas;
  111281. /**
  111282. * Creates the default xr experience
  111283. * @param scene scene
  111284. * @param options options for basic configuration
  111285. * @returns resulting WebXRDefaultExperience
  111286. */
  111287. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111288. private constructor();
  111289. /**
  111290. * DIsposes of the experience helper
  111291. */
  111292. dispose(): void;
  111293. }
  111294. }
  111295. declare module BABYLON {
  111296. /** @hidden */
  111297. export var _forceSceneHelpersToBundle: boolean;
  111298. interface Scene {
  111299. /**
  111300. * Creates a default light for the scene.
  111301. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111302. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111303. */
  111304. createDefaultLight(replace?: boolean): void;
  111305. /**
  111306. * Creates a default camera for the scene.
  111307. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111308. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111309. * @param replace has default false, when true replaces the active camera in the scene
  111310. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111311. */
  111312. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111313. /**
  111314. * Creates a default camera and a default light.
  111315. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111316. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111317. * @param replace has the default false, when true replaces the active camera/light in the scene
  111318. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111319. */
  111320. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111321. /**
  111322. * Creates a new sky box
  111323. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111324. * @param environmentTexture defines the texture to use as environment texture
  111325. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111326. * @param scale defines the overall scale of the skybox
  111327. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111328. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111329. * @returns a new mesh holding the sky box
  111330. */
  111331. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111332. /**
  111333. * Creates a new environment
  111334. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111335. * @param options defines the options you can use to configure the environment
  111336. * @returns the new EnvironmentHelper
  111337. */
  111338. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111339. /**
  111340. * Creates a new VREXperienceHelper
  111341. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111342. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111343. * @returns a new VREXperienceHelper
  111344. */
  111345. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111346. /**
  111347. * Creates a new WebXRDefaultExperience
  111348. * @see http://doc.babylonjs.com/how_to/webxr
  111349. * @param options experience options
  111350. * @returns a promise for a new WebXRDefaultExperience
  111351. */
  111352. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111353. }
  111354. }
  111355. declare module BABYLON {
  111356. /**
  111357. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111358. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111359. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111360. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111361. */
  111362. export class VideoDome extends TransformNode {
  111363. /**
  111364. * Define the video source as a Monoscopic panoramic 360 video.
  111365. */
  111366. static readonly MODE_MONOSCOPIC: number;
  111367. /**
  111368. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111369. */
  111370. static readonly MODE_TOPBOTTOM: number;
  111371. /**
  111372. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111373. */
  111374. static readonly MODE_SIDEBYSIDE: number;
  111375. private _useDirectMapping;
  111376. /**
  111377. * The video texture being displayed on the sphere
  111378. */
  111379. protected _videoTexture: VideoTexture;
  111380. /**
  111381. * Gets the video texture being displayed on the sphere
  111382. */
  111383. readonly videoTexture: VideoTexture;
  111384. /**
  111385. * The skybox material
  111386. */
  111387. protected _material: BackgroundMaterial;
  111388. /**
  111389. * The surface used for the skybox
  111390. */
  111391. protected _mesh: Mesh;
  111392. /**
  111393. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111394. * Also see the options.resolution property.
  111395. */
  111396. fovMultiplier: number;
  111397. private _videoMode;
  111398. /**
  111399. * Gets or set the current video mode for the video. It can be:
  111400. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111401. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111402. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111403. */
  111404. videoMode: number;
  111405. /**
  111406. * Oberserver used in Stereoscopic VR Mode.
  111407. */
  111408. private _onBeforeCameraRenderObserver;
  111409. /**
  111410. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111411. * @param name Element's name, child elements will append suffixes for their own names.
  111412. * @param urlsOrVideo defines the url(s) or the video element to use
  111413. * @param options An object containing optional or exposed sub element properties
  111414. */
  111415. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111416. resolution?: number;
  111417. clickToPlay?: boolean;
  111418. autoPlay?: boolean;
  111419. loop?: boolean;
  111420. size?: number;
  111421. poster?: string;
  111422. faceForward?: boolean;
  111423. useDirectMapping?: boolean;
  111424. }, scene: Scene);
  111425. private _changeVideoMode;
  111426. /**
  111427. * Releases resources associated with this node.
  111428. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111429. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111430. */
  111431. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111432. }
  111433. }
  111434. declare module BABYLON {
  111435. /**
  111436. * This class can be used to get instrumentation data from a Babylon engine
  111437. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111438. */
  111439. export class EngineInstrumentation implements IDisposable {
  111440. /**
  111441. * Define the instrumented engine.
  111442. */
  111443. engine: Engine;
  111444. private _captureGPUFrameTime;
  111445. private _gpuFrameTimeToken;
  111446. private _gpuFrameTime;
  111447. private _captureShaderCompilationTime;
  111448. private _shaderCompilationTime;
  111449. private _onBeginFrameObserver;
  111450. private _onEndFrameObserver;
  111451. private _onBeforeShaderCompilationObserver;
  111452. private _onAfterShaderCompilationObserver;
  111453. /**
  111454. * Gets the perf counter used for GPU frame time
  111455. */
  111456. readonly gpuFrameTimeCounter: PerfCounter;
  111457. /**
  111458. * Gets the GPU frame time capture status
  111459. */
  111460. /**
  111461. * Enable or disable the GPU frame time capture
  111462. */
  111463. captureGPUFrameTime: boolean;
  111464. /**
  111465. * Gets the perf counter used for shader compilation time
  111466. */
  111467. readonly shaderCompilationTimeCounter: PerfCounter;
  111468. /**
  111469. * Gets the shader compilation time capture status
  111470. */
  111471. /**
  111472. * Enable or disable the shader compilation time capture
  111473. */
  111474. captureShaderCompilationTime: boolean;
  111475. /**
  111476. * Instantiates a new engine instrumentation.
  111477. * This class can be used to get instrumentation data from a Babylon engine
  111478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111479. * @param engine Defines the engine to instrument
  111480. */
  111481. constructor(
  111482. /**
  111483. * Define the instrumented engine.
  111484. */
  111485. engine: Engine);
  111486. /**
  111487. * Dispose and release associated resources.
  111488. */
  111489. dispose(): void;
  111490. }
  111491. }
  111492. declare module BABYLON {
  111493. /**
  111494. * This class can be used to get instrumentation data from a Babylon engine
  111495. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111496. */
  111497. export class SceneInstrumentation implements IDisposable {
  111498. /**
  111499. * Defines the scene to instrument
  111500. */
  111501. scene: Scene;
  111502. private _captureActiveMeshesEvaluationTime;
  111503. private _activeMeshesEvaluationTime;
  111504. private _captureRenderTargetsRenderTime;
  111505. private _renderTargetsRenderTime;
  111506. private _captureFrameTime;
  111507. private _frameTime;
  111508. private _captureRenderTime;
  111509. private _renderTime;
  111510. private _captureInterFrameTime;
  111511. private _interFrameTime;
  111512. private _captureParticlesRenderTime;
  111513. private _particlesRenderTime;
  111514. private _captureSpritesRenderTime;
  111515. private _spritesRenderTime;
  111516. private _capturePhysicsTime;
  111517. private _physicsTime;
  111518. private _captureAnimationsTime;
  111519. private _animationsTime;
  111520. private _captureCameraRenderTime;
  111521. private _cameraRenderTime;
  111522. private _onBeforeActiveMeshesEvaluationObserver;
  111523. private _onAfterActiveMeshesEvaluationObserver;
  111524. private _onBeforeRenderTargetsRenderObserver;
  111525. private _onAfterRenderTargetsRenderObserver;
  111526. private _onAfterRenderObserver;
  111527. private _onBeforeDrawPhaseObserver;
  111528. private _onAfterDrawPhaseObserver;
  111529. private _onBeforeAnimationsObserver;
  111530. private _onBeforeParticlesRenderingObserver;
  111531. private _onAfterParticlesRenderingObserver;
  111532. private _onBeforeSpritesRenderingObserver;
  111533. private _onAfterSpritesRenderingObserver;
  111534. private _onBeforePhysicsObserver;
  111535. private _onAfterPhysicsObserver;
  111536. private _onAfterAnimationsObserver;
  111537. private _onBeforeCameraRenderObserver;
  111538. private _onAfterCameraRenderObserver;
  111539. /**
  111540. * Gets the perf counter used for active meshes evaluation time
  111541. */
  111542. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111543. /**
  111544. * Gets the active meshes evaluation time capture status
  111545. */
  111546. /**
  111547. * Enable or disable the active meshes evaluation time capture
  111548. */
  111549. captureActiveMeshesEvaluationTime: boolean;
  111550. /**
  111551. * Gets the perf counter used for render targets render time
  111552. */
  111553. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111554. /**
  111555. * Gets the render targets render time capture status
  111556. */
  111557. /**
  111558. * Enable or disable the render targets render time capture
  111559. */
  111560. captureRenderTargetsRenderTime: boolean;
  111561. /**
  111562. * Gets the perf counter used for particles render time
  111563. */
  111564. readonly particlesRenderTimeCounter: PerfCounter;
  111565. /**
  111566. * Gets the particles render time capture status
  111567. */
  111568. /**
  111569. * Enable or disable the particles render time capture
  111570. */
  111571. captureParticlesRenderTime: boolean;
  111572. /**
  111573. * Gets the perf counter used for sprites render time
  111574. */
  111575. readonly spritesRenderTimeCounter: PerfCounter;
  111576. /**
  111577. * Gets the sprites render time capture status
  111578. */
  111579. /**
  111580. * Enable or disable the sprites render time capture
  111581. */
  111582. captureSpritesRenderTime: boolean;
  111583. /**
  111584. * Gets the perf counter used for physics time
  111585. */
  111586. readonly physicsTimeCounter: PerfCounter;
  111587. /**
  111588. * Gets the physics time capture status
  111589. */
  111590. /**
  111591. * Enable or disable the physics time capture
  111592. */
  111593. capturePhysicsTime: boolean;
  111594. /**
  111595. * Gets the perf counter used for animations time
  111596. */
  111597. readonly animationsTimeCounter: PerfCounter;
  111598. /**
  111599. * Gets the animations time capture status
  111600. */
  111601. /**
  111602. * Enable or disable the animations time capture
  111603. */
  111604. captureAnimationsTime: boolean;
  111605. /**
  111606. * Gets the perf counter used for frame time capture
  111607. */
  111608. readonly frameTimeCounter: PerfCounter;
  111609. /**
  111610. * Gets the frame time capture status
  111611. */
  111612. /**
  111613. * Enable or disable the frame time capture
  111614. */
  111615. captureFrameTime: boolean;
  111616. /**
  111617. * Gets the perf counter used for inter-frames time capture
  111618. */
  111619. readonly interFrameTimeCounter: PerfCounter;
  111620. /**
  111621. * Gets the inter-frames time capture status
  111622. */
  111623. /**
  111624. * Enable or disable the inter-frames time capture
  111625. */
  111626. captureInterFrameTime: boolean;
  111627. /**
  111628. * Gets the perf counter used for render time capture
  111629. */
  111630. readonly renderTimeCounter: PerfCounter;
  111631. /**
  111632. * Gets the render time capture status
  111633. */
  111634. /**
  111635. * Enable or disable the render time capture
  111636. */
  111637. captureRenderTime: boolean;
  111638. /**
  111639. * Gets the perf counter used for camera render time capture
  111640. */
  111641. readonly cameraRenderTimeCounter: PerfCounter;
  111642. /**
  111643. * Gets the camera render time capture status
  111644. */
  111645. /**
  111646. * Enable or disable the camera render time capture
  111647. */
  111648. captureCameraRenderTime: boolean;
  111649. /**
  111650. * Gets the perf counter used for draw calls
  111651. */
  111652. readonly drawCallsCounter: PerfCounter;
  111653. /**
  111654. * Instantiates a new scene instrumentation.
  111655. * This class can be used to get instrumentation data from a Babylon engine
  111656. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111657. * @param scene Defines the scene to instrument
  111658. */
  111659. constructor(
  111660. /**
  111661. * Defines the scene to instrument
  111662. */
  111663. scene: Scene);
  111664. /**
  111665. * Dispose and release associated resources.
  111666. */
  111667. dispose(): void;
  111668. }
  111669. }
  111670. declare module BABYLON {
  111671. /** @hidden */
  111672. export var glowMapGenerationPixelShader: {
  111673. name: string;
  111674. shader: string;
  111675. };
  111676. }
  111677. declare module BABYLON {
  111678. /** @hidden */
  111679. export var glowMapGenerationVertexShader: {
  111680. name: string;
  111681. shader: string;
  111682. };
  111683. }
  111684. declare module BABYLON {
  111685. /**
  111686. * Effect layer options. This helps customizing the behaviour
  111687. * of the effect layer.
  111688. */
  111689. export interface IEffectLayerOptions {
  111690. /**
  111691. * Multiplication factor apply to the canvas size to compute the render target size
  111692. * used to generated the objects (the smaller the faster).
  111693. */
  111694. mainTextureRatio: number;
  111695. /**
  111696. * Enforces a fixed size texture to ensure effect stability across devices.
  111697. */
  111698. mainTextureFixedSize?: number;
  111699. /**
  111700. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111701. */
  111702. alphaBlendingMode: number;
  111703. /**
  111704. * The camera attached to the layer.
  111705. */
  111706. camera: Nullable<Camera>;
  111707. /**
  111708. * The rendering group to draw the layer in.
  111709. */
  111710. renderingGroupId: number;
  111711. }
  111712. /**
  111713. * The effect layer Helps adding post process effect blended with the main pass.
  111714. *
  111715. * This can be for instance use to generate glow or higlight effects on the scene.
  111716. *
  111717. * The effect layer class can not be used directly and is intented to inherited from to be
  111718. * customized per effects.
  111719. */
  111720. export abstract class EffectLayer {
  111721. private _vertexBuffers;
  111722. private _indexBuffer;
  111723. private _cachedDefines;
  111724. private _effectLayerMapGenerationEffect;
  111725. private _effectLayerOptions;
  111726. private _mergeEffect;
  111727. protected _scene: Scene;
  111728. protected _engine: Engine;
  111729. protected _maxSize: number;
  111730. protected _mainTextureDesiredSize: ISize;
  111731. protected _mainTexture: RenderTargetTexture;
  111732. protected _shouldRender: boolean;
  111733. protected _postProcesses: PostProcess[];
  111734. protected _textures: BaseTexture[];
  111735. protected _emissiveTextureAndColor: {
  111736. texture: Nullable<BaseTexture>;
  111737. color: Color4;
  111738. };
  111739. /**
  111740. * The name of the layer
  111741. */
  111742. name: string;
  111743. /**
  111744. * The clear color of the texture used to generate the glow map.
  111745. */
  111746. neutralColor: Color4;
  111747. /**
  111748. * Specifies wether the highlight layer is enabled or not.
  111749. */
  111750. isEnabled: boolean;
  111751. /**
  111752. * Gets the camera attached to the layer.
  111753. */
  111754. readonly camera: Nullable<Camera>;
  111755. /**
  111756. * Gets the rendering group id the layer should render in.
  111757. */
  111758. renderingGroupId: number;
  111759. /**
  111760. * An event triggered when the effect layer has been disposed.
  111761. */
  111762. onDisposeObservable: Observable<EffectLayer>;
  111763. /**
  111764. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111765. */
  111766. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111767. /**
  111768. * An event triggered when the generated texture is being merged in the scene.
  111769. */
  111770. onBeforeComposeObservable: Observable<EffectLayer>;
  111771. /**
  111772. * An event triggered when the generated texture has been merged in the scene.
  111773. */
  111774. onAfterComposeObservable: Observable<EffectLayer>;
  111775. /**
  111776. * An event triggered when the efffect layer changes its size.
  111777. */
  111778. onSizeChangedObservable: Observable<EffectLayer>;
  111779. /** @hidden */
  111780. static _SceneComponentInitialization: (scene: Scene) => void;
  111781. /**
  111782. * Instantiates a new effect Layer and references it in the scene.
  111783. * @param name The name of the layer
  111784. * @param scene The scene to use the layer in
  111785. */
  111786. constructor(
  111787. /** The Friendly of the effect in the scene */
  111788. name: string, scene: Scene);
  111789. /**
  111790. * Get the effect name of the layer.
  111791. * @return The effect name
  111792. */
  111793. abstract getEffectName(): string;
  111794. /**
  111795. * Checks for the readiness of the element composing the layer.
  111796. * @param subMesh the mesh to check for
  111797. * @param useInstances specify wether or not to use instances to render the mesh
  111798. * @return true if ready otherwise, false
  111799. */
  111800. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111801. /**
  111802. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111803. * @returns true if the effect requires stencil during the main canvas render pass.
  111804. */
  111805. abstract needStencil(): boolean;
  111806. /**
  111807. * Create the merge effect. This is the shader use to blit the information back
  111808. * to the main canvas at the end of the scene rendering.
  111809. * @returns The effect containing the shader used to merge the effect on the main canvas
  111810. */
  111811. protected abstract _createMergeEffect(): Effect;
  111812. /**
  111813. * Creates the render target textures and post processes used in the effect layer.
  111814. */
  111815. protected abstract _createTextureAndPostProcesses(): void;
  111816. /**
  111817. * Implementation specific of rendering the generating effect on the main canvas.
  111818. * @param effect The effect used to render through
  111819. */
  111820. protected abstract _internalRender(effect: Effect): void;
  111821. /**
  111822. * Sets the required values for both the emissive texture and and the main color.
  111823. */
  111824. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111825. /**
  111826. * Free any resources and references associated to a mesh.
  111827. * Internal use
  111828. * @param mesh The mesh to free.
  111829. */
  111830. abstract _disposeMesh(mesh: Mesh): void;
  111831. /**
  111832. * Serializes this layer (Glow or Highlight for example)
  111833. * @returns a serialized layer object
  111834. */
  111835. abstract serialize?(): any;
  111836. /**
  111837. * Initializes the effect layer with the required options.
  111838. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  111839. */
  111840. protected _init(options: Partial<IEffectLayerOptions>): void;
  111841. /**
  111842. * Generates the index buffer of the full screen quad blending to the main canvas.
  111843. */
  111844. private _generateIndexBuffer;
  111845. /**
  111846. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  111847. */
  111848. private _generateVertexBuffer;
  111849. /**
  111850. * Sets the main texture desired size which is the closest power of two
  111851. * of the engine canvas size.
  111852. */
  111853. private _setMainTextureSize;
  111854. /**
  111855. * Creates the main texture for the effect layer.
  111856. */
  111857. protected _createMainTexture(): void;
  111858. /**
  111859. * Adds specific effects defines.
  111860. * @param defines The defines to add specifics to.
  111861. */
  111862. protected _addCustomEffectDefines(defines: string[]): void;
  111863. /**
  111864. * Checks for the readiness of the element composing the layer.
  111865. * @param subMesh the mesh to check for
  111866. * @param useInstances specify wether or not to use instances to render the mesh
  111867. * @param emissiveTexture the associated emissive texture used to generate the glow
  111868. * @return true if ready otherwise, false
  111869. */
  111870. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  111871. /**
  111872. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  111873. */
  111874. render(): void;
  111875. /**
  111876. * Determine if a given mesh will be used in the current effect.
  111877. * @param mesh mesh to test
  111878. * @returns true if the mesh will be used
  111879. */
  111880. hasMesh(mesh: AbstractMesh): boolean;
  111881. /**
  111882. * Returns true if the layer contains information to display, otherwise false.
  111883. * @returns true if the glow layer should be rendered
  111884. */
  111885. shouldRender(): boolean;
  111886. /**
  111887. * Returns true if the mesh should render, otherwise false.
  111888. * @param mesh The mesh to render
  111889. * @returns true if it should render otherwise false
  111890. */
  111891. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  111892. /**
  111893. * Returns true if the mesh can be rendered, otherwise false.
  111894. * @param mesh The mesh to render
  111895. * @param material The material used on the mesh
  111896. * @returns true if it can be rendered otherwise false
  111897. */
  111898. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111899. /**
  111900. * Returns true if the mesh should render, otherwise false.
  111901. * @param mesh The mesh to render
  111902. * @returns true if it should render otherwise false
  111903. */
  111904. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  111905. /**
  111906. * Renders the submesh passed in parameter to the generation map.
  111907. */
  111908. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  111909. /**
  111910. * Rebuild the required buffers.
  111911. * @hidden Internal use only.
  111912. */
  111913. _rebuild(): void;
  111914. /**
  111915. * Dispose only the render target textures and post process.
  111916. */
  111917. private _disposeTextureAndPostProcesses;
  111918. /**
  111919. * Dispose the highlight layer and free resources.
  111920. */
  111921. dispose(): void;
  111922. /**
  111923. * Gets the class name of the effect layer
  111924. * @returns the string with the class name of the effect layer
  111925. */
  111926. getClassName(): string;
  111927. /**
  111928. * Creates an effect layer from parsed effect layer data
  111929. * @param parsedEffectLayer defines effect layer data
  111930. * @param scene defines the current scene
  111931. * @param rootUrl defines the root URL containing the effect layer information
  111932. * @returns a parsed effect Layer
  111933. */
  111934. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  111935. }
  111936. }
  111937. declare module BABYLON {
  111938. interface AbstractScene {
  111939. /**
  111940. * The list of effect layers (highlights/glow) added to the scene
  111941. * @see http://doc.babylonjs.com/how_to/highlight_layer
  111942. * @see http://doc.babylonjs.com/how_to/glow_layer
  111943. */
  111944. effectLayers: Array<EffectLayer>;
  111945. /**
  111946. * Removes the given effect layer from this scene.
  111947. * @param toRemove defines the effect layer to remove
  111948. * @returns the index of the removed effect layer
  111949. */
  111950. removeEffectLayer(toRemove: EffectLayer): number;
  111951. /**
  111952. * Adds the given effect layer to this scene
  111953. * @param newEffectLayer defines the effect layer to add
  111954. */
  111955. addEffectLayer(newEffectLayer: EffectLayer): void;
  111956. }
  111957. /**
  111958. * Defines the layer scene component responsible to manage any effect layers
  111959. * in a given scene.
  111960. */
  111961. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  111962. /**
  111963. * The component name helpfull to identify the component in the list of scene components.
  111964. */
  111965. readonly name: string;
  111966. /**
  111967. * The scene the component belongs to.
  111968. */
  111969. scene: Scene;
  111970. private _engine;
  111971. private _renderEffects;
  111972. private _needStencil;
  111973. private _previousStencilState;
  111974. /**
  111975. * Creates a new instance of the component for the given scene
  111976. * @param scene Defines the scene to register the component in
  111977. */
  111978. constructor(scene: Scene);
  111979. /**
  111980. * Registers the component in a given scene
  111981. */
  111982. register(): void;
  111983. /**
  111984. * Rebuilds the elements related to this component in case of
  111985. * context lost for instance.
  111986. */
  111987. rebuild(): void;
  111988. /**
  111989. * Serializes the component data to the specified json object
  111990. * @param serializationObject The object to serialize to
  111991. */
  111992. serialize(serializationObject: any): void;
  111993. /**
  111994. * Adds all the elements from the container to the scene
  111995. * @param container the container holding the elements
  111996. */
  111997. addFromContainer(container: AbstractScene): void;
  111998. /**
  111999. * Removes all the elements in the container from the scene
  112000. * @param container contains the elements to remove
  112001. * @param dispose if the removed element should be disposed (default: false)
  112002. */
  112003. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112004. /**
  112005. * Disposes the component and the associated ressources.
  112006. */
  112007. dispose(): void;
  112008. private _isReadyForMesh;
  112009. private _renderMainTexture;
  112010. private _setStencil;
  112011. private _setStencilBack;
  112012. private _draw;
  112013. private _drawCamera;
  112014. private _drawRenderingGroup;
  112015. }
  112016. }
  112017. declare module BABYLON {
  112018. /** @hidden */
  112019. export var glowMapMergePixelShader: {
  112020. name: string;
  112021. shader: string;
  112022. };
  112023. }
  112024. declare module BABYLON {
  112025. /** @hidden */
  112026. export var glowMapMergeVertexShader: {
  112027. name: string;
  112028. shader: string;
  112029. };
  112030. }
  112031. declare module BABYLON {
  112032. interface AbstractScene {
  112033. /**
  112034. * Return a the first highlight layer of the scene with a given name.
  112035. * @param name The name of the highlight layer to look for.
  112036. * @return The highlight layer if found otherwise null.
  112037. */
  112038. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112039. }
  112040. /**
  112041. * Glow layer options. This helps customizing the behaviour
  112042. * of the glow layer.
  112043. */
  112044. export interface IGlowLayerOptions {
  112045. /**
  112046. * Multiplication factor apply to the canvas size to compute the render target size
  112047. * used to generated the glowing objects (the smaller the faster).
  112048. */
  112049. mainTextureRatio: number;
  112050. /**
  112051. * Enforces a fixed size texture to ensure resize independant blur.
  112052. */
  112053. mainTextureFixedSize?: number;
  112054. /**
  112055. * How big is the kernel of the blur texture.
  112056. */
  112057. blurKernelSize: number;
  112058. /**
  112059. * The camera attached to the layer.
  112060. */
  112061. camera: Nullable<Camera>;
  112062. /**
  112063. * Enable MSAA by chosing the number of samples.
  112064. */
  112065. mainTextureSamples?: number;
  112066. /**
  112067. * The rendering group to draw the layer in.
  112068. */
  112069. renderingGroupId: number;
  112070. }
  112071. /**
  112072. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112073. *
  112074. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112075. * glowy meshes to your scene.
  112076. *
  112077. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112078. */
  112079. export class GlowLayer extends EffectLayer {
  112080. /**
  112081. * Effect Name of the layer.
  112082. */
  112083. static readonly EffectName: string;
  112084. /**
  112085. * The default blur kernel size used for the glow.
  112086. */
  112087. static DefaultBlurKernelSize: number;
  112088. /**
  112089. * The default texture size ratio used for the glow.
  112090. */
  112091. static DefaultTextureRatio: number;
  112092. /**
  112093. * Sets the kernel size of the blur.
  112094. */
  112095. /**
  112096. * Gets the kernel size of the blur.
  112097. */
  112098. blurKernelSize: number;
  112099. /**
  112100. * Sets the glow intensity.
  112101. */
  112102. /**
  112103. * Gets the glow intensity.
  112104. */
  112105. intensity: number;
  112106. private _options;
  112107. private _intensity;
  112108. private _horizontalBlurPostprocess1;
  112109. private _verticalBlurPostprocess1;
  112110. private _horizontalBlurPostprocess2;
  112111. private _verticalBlurPostprocess2;
  112112. private _blurTexture1;
  112113. private _blurTexture2;
  112114. private _postProcesses1;
  112115. private _postProcesses2;
  112116. private _includedOnlyMeshes;
  112117. private _excludedMeshes;
  112118. /**
  112119. * Callback used to let the user override the color selection on a per mesh basis
  112120. */
  112121. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112122. /**
  112123. * Callback used to let the user override the texture selection on a per mesh basis
  112124. */
  112125. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112126. /**
  112127. * Instantiates a new glow Layer and references it to the scene.
  112128. * @param name The name of the layer
  112129. * @param scene The scene to use the layer in
  112130. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112131. */
  112132. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112133. /**
  112134. * Get the effect name of the layer.
  112135. * @return The effect name
  112136. */
  112137. getEffectName(): string;
  112138. /**
  112139. * Create the merge effect. This is the shader use to blit the information back
  112140. * to the main canvas at the end of the scene rendering.
  112141. */
  112142. protected _createMergeEffect(): Effect;
  112143. /**
  112144. * Creates the render target textures and post processes used in the glow layer.
  112145. */
  112146. protected _createTextureAndPostProcesses(): void;
  112147. /**
  112148. * Checks for the readiness of the element composing the layer.
  112149. * @param subMesh the mesh to check for
  112150. * @param useInstances specify wether or not to use instances to render the mesh
  112151. * @param emissiveTexture the associated emissive texture used to generate the glow
  112152. * @return true if ready otherwise, false
  112153. */
  112154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112155. /**
  112156. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112157. */
  112158. needStencil(): boolean;
  112159. /**
  112160. * Returns true if the mesh can be rendered, otherwise false.
  112161. * @param mesh The mesh to render
  112162. * @param material The material used on the mesh
  112163. * @returns true if it can be rendered otherwise false
  112164. */
  112165. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112166. /**
  112167. * Implementation specific of rendering the generating effect on the main canvas.
  112168. * @param effect The effect used to render through
  112169. */
  112170. protected _internalRender(effect: Effect): void;
  112171. /**
  112172. * Sets the required values for both the emissive texture and and the main color.
  112173. */
  112174. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112175. /**
  112176. * Returns true if the mesh should render, otherwise false.
  112177. * @param mesh The mesh to render
  112178. * @returns true if it should render otherwise false
  112179. */
  112180. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112181. /**
  112182. * Adds specific effects defines.
  112183. * @param defines The defines to add specifics to.
  112184. */
  112185. protected _addCustomEffectDefines(defines: string[]): void;
  112186. /**
  112187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112188. * @param mesh The mesh to exclude from the glow layer
  112189. */
  112190. addExcludedMesh(mesh: Mesh): void;
  112191. /**
  112192. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112193. * @param mesh The mesh to remove
  112194. */
  112195. removeExcludedMesh(mesh: Mesh): void;
  112196. /**
  112197. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112198. * @param mesh The mesh to include in the glow layer
  112199. */
  112200. addIncludedOnlyMesh(mesh: Mesh): void;
  112201. /**
  112202. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112203. * @param mesh The mesh to remove
  112204. */
  112205. removeIncludedOnlyMesh(mesh: Mesh): void;
  112206. /**
  112207. * Determine if a given mesh will be used in the glow layer
  112208. * @param mesh The mesh to test
  112209. * @returns true if the mesh will be highlighted by the current glow layer
  112210. */
  112211. hasMesh(mesh: AbstractMesh): boolean;
  112212. /**
  112213. * Free any resources and references associated to a mesh.
  112214. * Internal use
  112215. * @param mesh The mesh to free.
  112216. * @hidden
  112217. */
  112218. _disposeMesh(mesh: Mesh): void;
  112219. /**
  112220. * Gets the class name of the effect layer
  112221. * @returns the string with the class name of the effect layer
  112222. */
  112223. getClassName(): string;
  112224. /**
  112225. * Serializes this glow layer
  112226. * @returns a serialized glow layer object
  112227. */
  112228. serialize(): any;
  112229. /**
  112230. * Creates a Glow Layer from parsed glow layer data
  112231. * @param parsedGlowLayer defines glow layer data
  112232. * @param scene defines the current scene
  112233. * @param rootUrl defines the root URL containing the glow layer information
  112234. * @returns a parsed Glow Layer
  112235. */
  112236. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112237. }
  112238. }
  112239. declare module BABYLON {
  112240. /** @hidden */
  112241. export var glowBlurPostProcessPixelShader: {
  112242. name: string;
  112243. shader: string;
  112244. };
  112245. }
  112246. declare module BABYLON {
  112247. interface AbstractScene {
  112248. /**
  112249. * Return a the first highlight layer of the scene with a given name.
  112250. * @param name The name of the highlight layer to look for.
  112251. * @return The highlight layer if found otherwise null.
  112252. */
  112253. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112254. }
  112255. /**
  112256. * Highlight layer options. This helps customizing the behaviour
  112257. * of the highlight layer.
  112258. */
  112259. export interface IHighlightLayerOptions {
  112260. /**
  112261. * Multiplication factor apply to the canvas size to compute the render target size
  112262. * used to generated the glowing objects (the smaller the faster).
  112263. */
  112264. mainTextureRatio: number;
  112265. /**
  112266. * Enforces a fixed size texture to ensure resize independant blur.
  112267. */
  112268. mainTextureFixedSize?: number;
  112269. /**
  112270. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112271. * of the picture to blur (the smaller the faster).
  112272. */
  112273. blurTextureSizeRatio: number;
  112274. /**
  112275. * How big in texel of the blur texture is the vertical blur.
  112276. */
  112277. blurVerticalSize: number;
  112278. /**
  112279. * How big in texel of the blur texture is the horizontal blur.
  112280. */
  112281. blurHorizontalSize: number;
  112282. /**
  112283. * Alpha blending mode used to apply the blur. Default is combine.
  112284. */
  112285. alphaBlendingMode: number;
  112286. /**
  112287. * The camera attached to the layer.
  112288. */
  112289. camera: Nullable<Camera>;
  112290. /**
  112291. * Should we display highlight as a solid stroke?
  112292. */
  112293. isStroke?: boolean;
  112294. /**
  112295. * The rendering group to draw the layer in.
  112296. */
  112297. renderingGroupId: number;
  112298. }
  112299. /**
  112300. * The highlight layer Helps adding a glow effect around a mesh.
  112301. *
  112302. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112303. * glowy meshes to your scene.
  112304. *
  112305. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112306. */
  112307. export class HighlightLayer extends EffectLayer {
  112308. name: string;
  112309. /**
  112310. * Effect Name of the highlight layer.
  112311. */
  112312. static readonly EffectName: string;
  112313. /**
  112314. * The neutral color used during the preparation of the glow effect.
  112315. * This is black by default as the blend operation is a blend operation.
  112316. */
  112317. static NeutralColor: Color4;
  112318. /**
  112319. * Stencil value used for glowing meshes.
  112320. */
  112321. static GlowingMeshStencilReference: number;
  112322. /**
  112323. * Stencil value used for the other meshes in the scene.
  112324. */
  112325. static NormalMeshStencilReference: number;
  112326. /**
  112327. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112328. */
  112329. innerGlow: boolean;
  112330. /**
  112331. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112332. */
  112333. outerGlow: boolean;
  112334. /**
  112335. * Specifies the horizontal size of the blur.
  112336. */
  112337. /**
  112338. * Gets the horizontal size of the blur.
  112339. */
  112340. blurHorizontalSize: number;
  112341. /**
  112342. * Specifies the vertical size of the blur.
  112343. */
  112344. /**
  112345. * Gets the vertical size of the blur.
  112346. */
  112347. blurVerticalSize: number;
  112348. /**
  112349. * An event triggered when the highlight layer is being blurred.
  112350. */
  112351. onBeforeBlurObservable: Observable<HighlightLayer>;
  112352. /**
  112353. * An event triggered when the highlight layer has been blurred.
  112354. */
  112355. onAfterBlurObservable: Observable<HighlightLayer>;
  112356. private _instanceGlowingMeshStencilReference;
  112357. private _options;
  112358. private _downSamplePostprocess;
  112359. private _horizontalBlurPostprocess;
  112360. private _verticalBlurPostprocess;
  112361. private _blurTexture;
  112362. private _meshes;
  112363. private _excludedMeshes;
  112364. /**
  112365. * Instantiates a new highlight Layer and references it to the scene..
  112366. * @param name The name of the layer
  112367. * @param scene The scene to use the layer in
  112368. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112369. */
  112370. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112371. /**
  112372. * Get the effect name of the layer.
  112373. * @return The effect name
  112374. */
  112375. getEffectName(): string;
  112376. /**
  112377. * Create the merge effect. This is the shader use to blit the information back
  112378. * to the main canvas at the end of the scene rendering.
  112379. */
  112380. protected _createMergeEffect(): Effect;
  112381. /**
  112382. * Creates the render target textures and post processes used in the highlight layer.
  112383. */
  112384. protected _createTextureAndPostProcesses(): void;
  112385. /**
  112386. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112387. */
  112388. needStencil(): boolean;
  112389. /**
  112390. * Checks for the readiness of the element composing the layer.
  112391. * @param subMesh the mesh to check for
  112392. * @param useInstances specify wether or not to use instances to render the mesh
  112393. * @param emissiveTexture the associated emissive texture used to generate the glow
  112394. * @return true if ready otherwise, false
  112395. */
  112396. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112397. /**
  112398. * Implementation specific of rendering the generating effect on the main canvas.
  112399. * @param effect The effect used to render through
  112400. */
  112401. protected _internalRender(effect: Effect): void;
  112402. /**
  112403. * Returns true if the layer contains information to display, otherwise false.
  112404. */
  112405. shouldRender(): boolean;
  112406. /**
  112407. * Returns true if the mesh should render, otherwise false.
  112408. * @param mesh The mesh to render
  112409. * @returns true if it should render otherwise false
  112410. */
  112411. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112412. /**
  112413. * Sets the required values for both the emissive texture and and the main color.
  112414. */
  112415. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112416. /**
  112417. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112418. * @param mesh The mesh to exclude from the highlight layer
  112419. */
  112420. addExcludedMesh(mesh: Mesh): void;
  112421. /**
  112422. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112423. * @param mesh The mesh to highlight
  112424. */
  112425. removeExcludedMesh(mesh: Mesh): void;
  112426. /**
  112427. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112428. * @param mesh mesh to test
  112429. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112430. */
  112431. hasMesh(mesh: AbstractMesh): boolean;
  112432. /**
  112433. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112434. * @param mesh The mesh to highlight
  112435. * @param color The color of the highlight
  112436. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112437. */
  112438. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112439. /**
  112440. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112441. * @param mesh The mesh to highlight
  112442. */
  112443. removeMesh(mesh: Mesh): void;
  112444. /**
  112445. * Force the stencil to the normal expected value for none glowing parts
  112446. */
  112447. private _defaultStencilReference;
  112448. /**
  112449. * Free any resources and references associated to a mesh.
  112450. * Internal use
  112451. * @param mesh The mesh to free.
  112452. * @hidden
  112453. */
  112454. _disposeMesh(mesh: Mesh): void;
  112455. /**
  112456. * Dispose the highlight layer and free resources.
  112457. */
  112458. dispose(): void;
  112459. /**
  112460. * Gets the class name of the effect layer
  112461. * @returns the string with the class name of the effect layer
  112462. */
  112463. getClassName(): string;
  112464. /**
  112465. * Serializes this Highlight layer
  112466. * @returns a serialized Highlight layer object
  112467. */
  112468. serialize(): any;
  112469. /**
  112470. * Creates a Highlight layer from parsed Highlight layer data
  112471. * @param parsedHightlightLayer defines the Highlight layer data
  112472. * @param scene defines the current scene
  112473. * @param rootUrl defines the root URL containing the Highlight layer information
  112474. * @returns a parsed Highlight layer
  112475. */
  112476. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112477. }
  112478. }
  112479. declare module BABYLON {
  112480. interface AbstractScene {
  112481. /**
  112482. * The list of layers (background and foreground) of the scene
  112483. */
  112484. layers: Array<Layer>;
  112485. }
  112486. /**
  112487. * Defines the layer scene component responsible to manage any layers
  112488. * in a given scene.
  112489. */
  112490. export class LayerSceneComponent implements ISceneComponent {
  112491. /**
  112492. * The component name helpfull to identify the component in the list of scene components.
  112493. */
  112494. readonly name: string;
  112495. /**
  112496. * The scene the component belongs to.
  112497. */
  112498. scene: Scene;
  112499. private _engine;
  112500. /**
  112501. * Creates a new instance of the component for the given scene
  112502. * @param scene Defines the scene to register the component in
  112503. */
  112504. constructor(scene: Scene);
  112505. /**
  112506. * Registers the component in a given scene
  112507. */
  112508. register(): void;
  112509. /**
  112510. * Rebuilds the elements related to this component in case of
  112511. * context lost for instance.
  112512. */
  112513. rebuild(): void;
  112514. /**
  112515. * Disposes the component and the associated ressources.
  112516. */
  112517. dispose(): void;
  112518. private _draw;
  112519. private _drawCameraPredicate;
  112520. private _drawCameraBackground;
  112521. private _drawCameraForeground;
  112522. private _drawRenderTargetPredicate;
  112523. private _drawRenderTargetBackground;
  112524. private _drawRenderTargetForeground;
  112525. /**
  112526. * Adds all the elements from the container to the scene
  112527. * @param container the container holding the elements
  112528. */
  112529. addFromContainer(container: AbstractScene): void;
  112530. /**
  112531. * Removes all the elements in the container from the scene
  112532. * @param container contains the elements to remove
  112533. * @param dispose if the removed element should be disposed (default: false)
  112534. */
  112535. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112536. }
  112537. }
  112538. declare module BABYLON {
  112539. /** @hidden */
  112540. export var layerPixelShader: {
  112541. name: string;
  112542. shader: string;
  112543. };
  112544. }
  112545. declare module BABYLON {
  112546. /** @hidden */
  112547. export var layerVertexShader: {
  112548. name: string;
  112549. shader: string;
  112550. };
  112551. }
  112552. declare module BABYLON {
  112553. /**
  112554. * This represents a full screen 2d layer.
  112555. * This can be useful to display a picture in the background of your scene for instance.
  112556. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112557. */
  112558. export class Layer {
  112559. /**
  112560. * Define the name of the layer.
  112561. */
  112562. name: string;
  112563. /**
  112564. * Define the texture the layer should display.
  112565. */
  112566. texture: Nullable<Texture>;
  112567. /**
  112568. * Is the layer in background or foreground.
  112569. */
  112570. isBackground: boolean;
  112571. /**
  112572. * Define the color of the layer (instead of texture).
  112573. */
  112574. color: Color4;
  112575. /**
  112576. * Define the scale of the layer in order to zoom in out of the texture.
  112577. */
  112578. scale: Vector2;
  112579. /**
  112580. * Define an offset for the layer in order to shift the texture.
  112581. */
  112582. offset: Vector2;
  112583. /**
  112584. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112585. */
  112586. alphaBlendingMode: number;
  112587. /**
  112588. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112589. * Alpha test will not mix with the background color in case of transparency.
  112590. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112591. */
  112592. alphaTest: boolean;
  112593. /**
  112594. * Define a mask to restrict the layer to only some of the scene cameras.
  112595. */
  112596. layerMask: number;
  112597. /**
  112598. * Define the list of render target the layer is visible into.
  112599. */
  112600. renderTargetTextures: RenderTargetTexture[];
  112601. /**
  112602. * Define if the layer is only used in renderTarget or if it also
  112603. * renders in the main frame buffer of the canvas.
  112604. */
  112605. renderOnlyInRenderTargetTextures: boolean;
  112606. private _scene;
  112607. private _vertexBuffers;
  112608. private _indexBuffer;
  112609. private _effect;
  112610. private _alphaTestEffect;
  112611. /**
  112612. * An event triggered when the layer is disposed.
  112613. */
  112614. onDisposeObservable: Observable<Layer>;
  112615. private _onDisposeObserver;
  112616. /**
  112617. * Back compatibility with callback before the onDisposeObservable existed.
  112618. * The set callback will be triggered when the layer has been disposed.
  112619. */
  112620. onDispose: () => void;
  112621. /**
  112622. * An event triggered before rendering the scene
  112623. */
  112624. onBeforeRenderObservable: Observable<Layer>;
  112625. private _onBeforeRenderObserver;
  112626. /**
  112627. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112628. * The set callback will be triggered just before rendering the layer.
  112629. */
  112630. onBeforeRender: () => void;
  112631. /**
  112632. * An event triggered after rendering the scene
  112633. */
  112634. onAfterRenderObservable: Observable<Layer>;
  112635. private _onAfterRenderObserver;
  112636. /**
  112637. * Back compatibility with callback before the onAfterRenderObservable existed.
  112638. * The set callback will be triggered just after rendering the layer.
  112639. */
  112640. onAfterRender: () => void;
  112641. /**
  112642. * Instantiates a new layer.
  112643. * This represents a full screen 2d layer.
  112644. * This can be useful to display a picture in the background of your scene for instance.
  112645. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112646. * @param name Define the name of the layer in the scene
  112647. * @param imgUrl Define the url of the texture to display in the layer
  112648. * @param scene Define the scene the layer belongs to
  112649. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112650. * @param color Defines a color for the layer
  112651. */
  112652. constructor(
  112653. /**
  112654. * Define the name of the layer.
  112655. */
  112656. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112657. private _createIndexBuffer;
  112658. /** @hidden */
  112659. _rebuild(): void;
  112660. /**
  112661. * Renders the layer in the scene.
  112662. */
  112663. render(): void;
  112664. /**
  112665. * Disposes and releases the associated ressources.
  112666. */
  112667. dispose(): void;
  112668. }
  112669. }
  112670. declare module BABYLON {
  112671. /** @hidden */
  112672. export var lensFlarePixelShader: {
  112673. name: string;
  112674. shader: string;
  112675. };
  112676. }
  112677. declare module BABYLON {
  112678. /** @hidden */
  112679. export var lensFlareVertexShader: {
  112680. name: string;
  112681. shader: string;
  112682. };
  112683. }
  112684. declare module BABYLON {
  112685. /**
  112686. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112687. * It is usually composed of several `lensFlare`.
  112688. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112689. */
  112690. export class LensFlareSystem {
  112691. /**
  112692. * Define the name of the lens flare system
  112693. */
  112694. name: string;
  112695. /**
  112696. * List of lens flares used in this system.
  112697. */
  112698. lensFlares: LensFlare[];
  112699. /**
  112700. * Define a limit from the border the lens flare can be visible.
  112701. */
  112702. borderLimit: number;
  112703. /**
  112704. * Define a viewport border we do not want to see the lens flare in.
  112705. */
  112706. viewportBorder: number;
  112707. /**
  112708. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112709. */
  112710. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112711. /**
  112712. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112713. */
  112714. layerMask: number;
  112715. /**
  112716. * Define the id of the lens flare system in the scene.
  112717. * (equal to name by default)
  112718. */
  112719. id: string;
  112720. private _scene;
  112721. private _emitter;
  112722. private _vertexBuffers;
  112723. private _indexBuffer;
  112724. private _effect;
  112725. private _positionX;
  112726. private _positionY;
  112727. private _isEnabled;
  112728. /** @hidden */
  112729. static _SceneComponentInitialization: (scene: Scene) => void;
  112730. /**
  112731. * Instantiates a lens flare system.
  112732. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112733. * It is usually composed of several `lensFlare`.
  112734. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112735. * @param name Define the name of the lens flare system in the scene
  112736. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112737. * @param scene Define the scene the lens flare system belongs to
  112738. */
  112739. constructor(
  112740. /**
  112741. * Define the name of the lens flare system
  112742. */
  112743. name: string, emitter: any, scene: Scene);
  112744. /**
  112745. * Define if the lens flare system is enabled.
  112746. */
  112747. isEnabled: boolean;
  112748. /**
  112749. * Get the scene the effects belongs to.
  112750. * @returns the scene holding the lens flare system
  112751. */
  112752. getScene(): Scene;
  112753. /**
  112754. * Get the emitter of the lens flare system.
  112755. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112756. * @returns the emitter of the lens flare system
  112757. */
  112758. getEmitter(): any;
  112759. /**
  112760. * Set the emitter of the lens flare system.
  112761. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112762. * @param newEmitter Define the new emitter of the system
  112763. */
  112764. setEmitter(newEmitter: any): void;
  112765. /**
  112766. * Get the lens flare system emitter position.
  112767. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112768. * @returns the position
  112769. */
  112770. getEmitterPosition(): Vector3;
  112771. /**
  112772. * @hidden
  112773. */
  112774. computeEffectivePosition(globalViewport: Viewport): boolean;
  112775. /** @hidden */
  112776. _isVisible(): boolean;
  112777. /**
  112778. * @hidden
  112779. */
  112780. render(): boolean;
  112781. /**
  112782. * Dispose and release the lens flare with its associated resources.
  112783. */
  112784. dispose(): void;
  112785. /**
  112786. * Parse a lens flare system from a JSON repressentation
  112787. * @param parsedLensFlareSystem Define the JSON to parse
  112788. * @param scene Define the scene the parsed system should be instantiated in
  112789. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112790. * @returns the parsed system
  112791. */
  112792. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112793. /**
  112794. * Serialize the current Lens Flare System into a JSON representation.
  112795. * @returns the serialized JSON
  112796. */
  112797. serialize(): any;
  112798. }
  112799. }
  112800. declare module BABYLON {
  112801. /**
  112802. * This represents one of the lens effect in a `lensFlareSystem`.
  112803. * It controls one of the indiviual texture used in the effect.
  112804. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112805. */
  112806. export class LensFlare {
  112807. /**
  112808. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112809. */
  112810. size: number;
  112811. /**
  112812. * 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.
  112813. */
  112814. position: number;
  112815. /**
  112816. * Define the lens color.
  112817. */
  112818. color: Color3;
  112819. /**
  112820. * Define the lens texture.
  112821. */
  112822. texture: Nullable<Texture>;
  112823. /**
  112824. * Define the alpha mode to render this particular lens.
  112825. */
  112826. alphaMode: number;
  112827. private _system;
  112828. /**
  112829. * Creates a new Lens Flare.
  112830. * This represents one of the lens effect in a `lensFlareSystem`.
  112831. * It controls one of the indiviual texture used in the effect.
  112832. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112833. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  112834. * @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.
  112835. * @param color Define the lens color
  112836. * @param imgUrl Define the lens texture url
  112837. * @param system Define the `lensFlareSystem` this flare is part of
  112838. * @returns The newly created Lens Flare
  112839. */
  112840. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  112841. /**
  112842. * Instantiates a new Lens Flare.
  112843. * This represents one of the lens effect in a `lensFlareSystem`.
  112844. * It controls one of the indiviual texture used in the effect.
  112845. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112846. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  112847. * @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.
  112848. * @param color Define the lens color
  112849. * @param imgUrl Define the lens texture url
  112850. * @param system Define the `lensFlareSystem` this flare is part of
  112851. */
  112852. constructor(
  112853. /**
  112854. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112855. */
  112856. size: number,
  112857. /**
  112858. * 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.
  112859. */
  112860. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  112861. /**
  112862. * Dispose and release the lens flare with its associated resources.
  112863. */
  112864. dispose(): void;
  112865. }
  112866. }
  112867. declare module BABYLON {
  112868. interface AbstractScene {
  112869. /**
  112870. * The list of lens flare system added to the scene
  112871. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112872. */
  112873. lensFlareSystems: Array<LensFlareSystem>;
  112874. /**
  112875. * Removes the given lens flare system from this scene.
  112876. * @param toRemove The lens flare system to remove
  112877. * @returns The index of the removed lens flare system
  112878. */
  112879. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  112880. /**
  112881. * Adds the given lens flare system to this scene
  112882. * @param newLensFlareSystem The lens flare system to add
  112883. */
  112884. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  112885. /**
  112886. * Gets a lens flare system using its name
  112887. * @param name defines the name to look for
  112888. * @returns the lens flare system or null if not found
  112889. */
  112890. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  112891. /**
  112892. * Gets a lens flare system using its id
  112893. * @param id defines the id to look for
  112894. * @returns the lens flare system or null if not found
  112895. */
  112896. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  112897. }
  112898. /**
  112899. * Defines the lens flare scene component responsible to manage any lens flares
  112900. * in a given scene.
  112901. */
  112902. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  112903. /**
  112904. * The component name helpfull to identify the component in the list of scene components.
  112905. */
  112906. readonly name: string;
  112907. /**
  112908. * The scene the component belongs to.
  112909. */
  112910. scene: Scene;
  112911. /**
  112912. * Creates a new instance of the component for the given scene
  112913. * @param scene Defines the scene to register the component in
  112914. */
  112915. constructor(scene: Scene);
  112916. /**
  112917. * Registers the component in a given scene
  112918. */
  112919. register(): void;
  112920. /**
  112921. * Rebuilds the elements related to this component in case of
  112922. * context lost for instance.
  112923. */
  112924. rebuild(): void;
  112925. /**
  112926. * Adds all the elements from the container to the scene
  112927. * @param container the container holding the elements
  112928. */
  112929. addFromContainer(container: AbstractScene): void;
  112930. /**
  112931. * Removes all the elements in the container from the scene
  112932. * @param container contains the elements to remove
  112933. * @param dispose if the removed element should be disposed (default: false)
  112934. */
  112935. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112936. /**
  112937. * Serializes the component data to the specified json object
  112938. * @param serializationObject The object to serialize to
  112939. */
  112940. serialize(serializationObject: any): void;
  112941. /**
  112942. * Disposes the component and the associated ressources.
  112943. */
  112944. dispose(): void;
  112945. private _draw;
  112946. }
  112947. }
  112948. declare module BABYLON {
  112949. /**
  112950. * Defines the shadow generator component responsible to manage any shadow generators
  112951. * in a given scene.
  112952. */
  112953. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  112954. /**
  112955. * The component name helpfull to identify the component in the list of scene components.
  112956. */
  112957. readonly name: string;
  112958. /**
  112959. * The scene the component belongs to.
  112960. */
  112961. scene: Scene;
  112962. /**
  112963. * Creates a new instance of the component for the given scene
  112964. * @param scene Defines the scene to register the component in
  112965. */
  112966. constructor(scene: Scene);
  112967. /**
  112968. * Registers the component in a given scene
  112969. */
  112970. register(): void;
  112971. /**
  112972. * Rebuilds the elements related to this component in case of
  112973. * context lost for instance.
  112974. */
  112975. rebuild(): void;
  112976. /**
  112977. * Serializes the component data to the specified json object
  112978. * @param serializationObject The object to serialize to
  112979. */
  112980. serialize(serializationObject: any): void;
  112981. /**
  112982. * Adds all the elements from the container to the scene
  112983. * @param container the container holding the elements
  112984. */
  112985. addFromContainer(container: AbstractScene): void;
  112986. /**
  112987. * Removes all the elements in the container from the scene
  112988. * @param container contains the elements to remove
  112989. * @param dispose if the removed element should be disposed (default: false)
  112990. */
  112991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112992. /**
  112993. * Rebuilds the elements related to this component in case of
  112994. * context lost for instance.
  112995. */
  112996. dispose(): void;
  112997. private _gatherRenderTargets;
  112998. }
  112999. }
  113000. declare module BABYLON {
  113001. /**
  113002. * A point light is a light defined by an unique point in world space.
  113003. * The light is emitted in every direction from this point.
  113004. * A good example of a point light is a standard light bulb.
  113005. * Documentation: https://doc.babylonjs.com/babylon101/lights
  113006. */
  113007. export class PointLight extends ShadowLight {
  113008. private _shadowAngle;
  113009. /**
  113010. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113011. * This specifies what angle the shadow will use to be created.
  113012. *
  113013. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113014. */
  113015. /**
  113016. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113017. * This specifies what angle the shadow will use to be created.
  113018. *
  113019. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  113020. */
  113021. shadowAngle: number;
  113022. /**
  113023. * Gets the direction if it has been set.
  113024. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113025. */
  113026. /**
  113027. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  113028. */
  113029. direction: Vector3;
  113030. /**
  113031. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113032. * A PointLight emits the light in every direction.
  113033. * It can cast shadows.
  113034. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113035. * ```javascript
  113036. * var pointLight = new PointLight("pl", camera.position, scene);
  113037. * ```
  113038. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113039. * @param name The light friendly name
  113040. * @param position The position of the point light in the scene
  113041. * @param scene The scene the lights belongs to
  113042. */
  113043. constructor(name: string, position: Vector3, scene: Scene);
  113044. /**
  113045. * Returns the string "PointLight"
  113046. * @returns the class name
  113047. */
  113048. getClassName(): string;
  113049. /**
  113050. * Returns the integer 0.
  113051. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113052. */
  113053. getTypeID(): number;
  113054. /**
  113055. * Specifies wether or not the shadowmap should be a cube texture.
  113056. * @returns true if the shadowmap needs to be a cube texture.
  113057. */
  113058. needCube(): boolean;
  113059. /**
  113060. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113061. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113062. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113063. */
  113064. getShadowDirection(faceIndex?: number): Vector3;
  113065. /**
  113066. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113067. * - fov = PI / 2
  113068. * - aspect ratio : 1.0
  113069. * - z-near and far equal to the active camera minZ and maxZ.
  113070. * Returns the PointLight.
  113071. */
  113072. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113073. protected _buildUniformLayout(): void;
  113074. /**
  113075. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113076. * @param effect The effect to update
  113077. * @param lightIndex The index of the light in the effect to update
  113078. * @returns The point light
  113079. */
  113080. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113081. /**
  113082. * Prepares the list of defines specific to the light type.
  113083. * @param defines the list of defines
  113084. * @param lightIndex defines the index of the light for the effect
  113085. */
  113086. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113087. }
  113088. }
  113089. declare module BABYLON {
  113090. /**
  113091. * Header information of HDR texture files.
  113092. */
  113093. export interface HDRInfo {
  113094. /**
  113095. * The height of the texture in pixels.
  113096. */
  113097. height: number;
  113098. /**
  113099. * The width of the texture in pixels.
  113100. */
  113101. width: number;
  113102. /**
  113103. * The index of the beginning of the data in the binary file.
  113104. */
  113105. dataPosition: number;
  113106. }
  113107. /**
  113108. * This groups tools to convert HDR texture to native colors array.
  113109. */
  113110. export class HDRTools {
  113111. private static Ldexp;
  113112. private static Rgbe2float;
  113113. private static readStringLine;
  113114. /**
  113115. * Reads header information from an RGBE texture stored in a native array.
  113116. * More information on this format are available here:
  113117. * https://en.wikipedia.org/wiki/RGBE_image_format
  113118. *
  113119. * @param uint8array The binary file stored in native array.
  113120. * @return The header information.
  113121. */
  113122. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113123. /**
  113124. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113125. * This RGBE texture needs to store the information as a panorama.
  113126. *
  113127. * More information on this format are available here:
  113128. * https://en.wikipedia.org/wiki/RGBE_image_format
  113129. *
  113130. * @param buffer The binary file stored in an array buffer.
  113131. * @param size The expected size of the extracted cubemap.
  113132. * @return The Cube Map information.
  113133. */
  113134. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113135. /**
  113136. * Returns the pixels data extracted from an RGBE texture.
  113137. * This pixels will be stored left to right up to down in the R G B order in one array.
  113138. *
  113139. * More information on this format are available here:
  113140. * https://en.wikipedia.org/wiki/RGBE_image_format
  113141. *
  113142. * @param uint8array The binary file stored in an array buffer.
  113143. * @param hdrInfo The header information of the file.
  113144. * @return The pixels data in RGB right to left up to down order.
  113145. */
  113146. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113147. private static RGBE_ReadPixels_RLE;
  113148. }
  113149. }
  113150. declare module BABYLON {
  113151. /**
  113152. * This represents a texture coming from an HDR input.
  113153. *
  113154. * The only supported format is currently panorama picture stored in RGBE format.
  113155. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113156. */
  113157. export class HDRCubeTexture extends BaseTexture {
  113158. private static _facesMapping;
  113159. private _generateHarmonics;
  113160. private _noMipmap;
  113161. private _textureMatrix;
  113162. private _size;
  113163. private _onLoad;
  113164. private _onError;
  113165. /**
  113166. * The texture URL.
  113167. */
  113168. url: string;
  113169. /**
  113170. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113171. */
  113172. coordinatesMode: number;
  113173. protected _isBlocking: boolean;
  113174. /**
  113175. * Sets wether or not the texture is blocking during loading.
  113176. */
  113177. /**
  113178. * Gets wether or not the texture is blocking during loading.
  113179. */
  113180. isBlocking: boolean;
  113181. protected _rotationY: number;
  113182. /**
  113183. * Sets texture matrix rotation angle around Y axis in radians.
  113184. */
  113185. /**
  113186. * Gets texture matrix rotation angle around Y axis radians.
  113187. */
  113188. rotationY: number;
  113189. /**
  113190. * Gets or sets the center of the bounding box associated with the cube texture
  113191. * It must define where the camera used to render the texture was set
  113192. */
  113193. boundingBoxPosition: Vector3;
  113194. private _boundingBoxSize;
  113195. /**
  113196. * Gets or sets the size of the bounding box associated with the cube texture
  113197. * When defined, the cubemap will switch to local mode
  113198. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113199. * @example https://www.babylonjs-playground.com/#RNASML
  113200. */
  113201. boundingBoxSize: Vector3;
  113202. /**
  113203. * Instantiates an HDRTexture from the following parameters.
  113204. *
  113205. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113206. * @param scene The scene the texture will be used in
  113207. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113208. * @param noMipmap Forces to not generate the mipmap if true
  113209. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113210. * @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)
  113211. * @param reserved Reserved flag for internal use.
  113212. */
  113213. 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>);
  113214. /**
  113215. * Get the current class name of the texture useful for serialization or dynamic coding.
  113216. * @returns "HDRCubeTexture"
  113217. */
  113218. getClassName(): string;
  113219. /**
  113220. * Occurs when the file is raw .hdr file.
  113221. */
  113222. private loadTexture;
  113223. clone(): HDRCubeTexture;
  113224. delayLoad(): void;
  113225. /**
  113226. * Get the texture reflection matrix used to rotate/transform the reflection.
  113227. * @returns the reflection matrix
  113228. */
  113229. getReflectionTextureMatrix(): Matrix;
  113230. /**
  113231. * Set the texture reflection matrix used to rotate/transform the reflection.
  113232. * @param value Define the reflection matrix to set
  113233. */
  113234. setReflectionTextureMatrix(value: Matrix): void;
  113235. /**
  113236. * Parses a JSON representation of an HDR Texture in order to create the texture
  113237. * @param parsedTexture Define the JSON representation
  113238. * @param scene Define the scene the texture should be created in
  113239. * @param rootUrl Define the root url in case we need to load relative dependencies
  113240. * @returns the newly created texture after parsing
  113241. */
  113242. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113243. serialize(): any;
  113244. }
  113245. }
  113246. declare module BABYLON {
  113247. /**
  113248. * Class used to control physics engine
  113249. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113250. */
  113251. export class PhysicsEngine implements IPhysicsEngine {
  113252. private _physicsPlugin;
  113253. /**
  113254. * Global value used to control the smallest number supported by the simulation
  113255. */
  113256. static Epsilon: number;
  113257. private _impostors;
  113258. private _joints;
  113259. /**
  113260. * Gets the gravity vector used by the simulation
  113261. */
  113262. gravity: Vector3;
  113263. /**
  113264. * Factory used to create the default physics plugin.
  113265. * @returns The default physics plugin
  113266. */
  113267. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113268. /**
  113269. * Creates a new Physics Engine
  113270. * @param gravity defines the gravity vector used by the simulation
  113271. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113272. */
  113273. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113274. /**
  113275. * Sets the gravity vector used by the simulation
  113276. * @param gravity defines the gravity vector to use
  113277. */
  113278. setGravity(gravity: Vector3): void;
  113279. /**
  113280. * Set the time step of the physics engine.
  113281. * Default is 1/60.
  113282. * To slow it down, enter 1/600 for example.
  113283. * To speed it up, 1/30
  113284. * @param newTimeStep defines the new timestep to apply to this world.
  113285. */
  113286. setTimeStep(newTimeStep?: number): void;
  113287. /**
  113288. * Get the time step of the physics engine.
  113289. * @returns the current time step
  113290. */
  113291. getTimeStep(): number;
  113292. /**
  113293. * Release all resources
  113294. */
  113295. dispose(): void;
  113296. /**
  113297. * Gets the name of the current physics plugin
  113298. * @returns the name of the plugin
  113299. */
  113300. getPhysicsPluginName(): string;
  113301. /**
  113302. * Adding a new impostor for the impostor tracking.
  113303. * This will be done by the impostor itself.
  113304. * @param impostor the impostor to add
  113305. */
  113306. addImpostor(impostor: PhysicsImpostor): void;
  113307. /**
  113308. * Remove an impostor from the engine.
  113309. * This impostor and its mesh will not longer be updated by the physics engine.
  113310. * @param impostor the impostor to remove
  113311. */
  113312. removeImpostor(impostor: PhysicsImpostor): void;
  113313. /**
  113314. * Add a joint to the physics engine
  113315. * @param mainImpostor defines the main impostor to which the joint is added.
  113316. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113317. * @param joint defines the joint that will connect both impostors.
  113318. */
  113319. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113320. /**
  113321. * Removes a joint from the simulation
  113322. * @param mainImpostor defines the impostor used with the joint
  113323. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113324. * @param joint defines the joint to remove
  113325. */
  113326. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113327. /**
  113328. * Called by the scene. No need to call it.
  113329. * @param delta defines the timespam between frames
  113330. */
  113331. _step(delta: number): void;
  113332. /**
  113333. * Gets the current plugin used to run the simulation
  113334. * @returns current plugin
  113335. */
  113336. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113337. /**
  113338. * Gets the list of physic impostors
  113339. * @returns an array of PhysicsImpostor
  113340. */
  113341. getImpostors(): Array<PhysicsImpostor>;
  113342. /**
  113343. * Gets the impostor for a physics enabled object
  113344. * @param object defines the object impersonated by the impostor
  113345. * @returns the PhysicsImpostor or null if not found
  113346. */
  113347. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113348. /**
  113349. * Gets the impostor for a physics body object
  113350. * @param body defines physics body used by the impostor
  113351. * @returns the PhysicsImpostor or null if not found
  113352. */
  113353. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113354. /**
  113355. * Does a raycast in the physics world
  113356. * @param from when should the ray start?
  113357. * @param to when should the ray end?
  113358. * @returns PhysicsRaycastResult
  113359. */
  113360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113361. }
  113362. }
  113363. declare module BABYLON {
  113364. /** @hidden */
  113365. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113366. private _useDeltaForWorldStep;
  113367. world: any;
  113368. name: string;
  113369. private _physicsMaterials;
  113370. private _fixedTimeStep;
  113371. private _cannonRaycastResult;
  113372. private _raycastResult;
  113373. private _physicsBodysToRemoveAfterStep;
  113374. BJSCANNON: any;
  113375. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113376. setGravity(gravity: Vector3): void;
  113377. setTimeStep(timeStep: number): void;
  113378. getTimeStep(): number;
  113379. executeStep(delta: number): void;
  113380. private _removeMarkedPhysicsBodiesFromWorld;
  113381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113382. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113383. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113384. private _processChildMeshes;
  113385. removePhysicsBody(impostor: PhysicsImpostor): void;
  113386. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113387. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113388. private _addMaterial;
  113389. private _checkWithEpsilon;
  113390. private _createShape;
  113391. private _createHeightmap;
  113392. private _minus90X;
  113393. private _plus90X;
  113394. private _tmpPosition;
  113395. private _tmpDeltaPosition;
  113396. private _tmpUnityRotation;
  113397. private _updatePhysicsBodyTransformation;
  113398. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113399. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113400. isSupported(): boolean;
  113401. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113402. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113403. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113404. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113405. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113406. getBodyMass(impostor: PhysicsImpostor): number;
  113407. getBodyFriction(impostor: PhysicsImpostor): number;
  113408. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113409. getBodyRestitution(impostor: PhysicsImpostor): number;
  113410. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113411. sleepBody(impostor: PhysicsImpostor): void;
  113412. wakeUpBody(impostor: PhysicsImpostor): void;
  113413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113414. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113415. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113416. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113417. getRadius(impostor: PhysicsImpostor): number;
  113418. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113419. dispose(): void;
  113420. private _extendNamespace;
  113421. /**
  113422. * Does a raycast in the physics world
  113423. * @param from when should the ray start?
  113424. * @param to when should the ray end?
  113425. * @returns PhysicsRaycastResult
  113426. */
  113427. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113428. }
  113429. }
  113430. declare module BABYLON {
  113431. /** @hidden */
  113432. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113433. world: any;
  113434. name: string;
  113435. BJSOIMO: any;
  113436. private _raycastResult;
  113437. constructor(iterations?: number, oimoInjection?: any);
  113438. setGravity(gravity: Vector3): void;
  113439. setTimeStep(timeStep: number): void;
  113440. getTimeStep(): number;
  113441. private _tmpImpostorsArray;
  113442. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113443. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113444. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113445. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113446. private _tmpPositionVector;
  113447. removePhysicsBody(impostor: PhysicsImpostor): void;
  113448. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113449. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113450. isSupported(): boolean;
  113451. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113452. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113453. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113454. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113455. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113456. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113457. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113458. getBodyMass(impostor: PhysicsImpostor): number;
  113459. getBodyFriction(impostor: PhysicsImpostor): number;
  113460. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113461. getBodyRestitution(impostor: PhysicsImpostor): number;
  113462. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113463. sleepBody(impostor: PhysicsImpostor): void;
  113464. wakeUpBody(impostor: PhysicsImpostor): void;
  113465. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113466. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113468. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113469. getRadius(impostor: PhysicsImpostor): number;
  113470. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113471. dispose(): void;
  113472. /**
  113473. * Does a raycast in the physics world
  113474. * @param from when should the ray start?
  113475. * @param to when should the ray end?
  113476. * @returns PhysicsRaycastResult
  113477. */
  113478. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113479. }
  113480. }
  113481. declare module BABYLON {
  113482. /**
  113483. * Class containing static functions to help procedurally build meshes
  113484. */
  113485. export class RibbonBuilder {
  113486. /**
  113487. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113488. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113489. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113490. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113491. * * 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
  113492. * * 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
  113493. * * 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
  113494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113497. * * 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
  113498. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113499. * * 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
  113500. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113502. * @param name defines the name of the mesh
  113503. * @param options defines the options used to create the mesh
  113504. * @param scene defines the hosting scene
  113505. * @returns the ribbon mesh
  113506. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113507. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113508. */
  113509. static CreateRibbon(name: string, options: {
  113510. pathArray: Vector3[][];
  113511. closeArray?: boolean;
  113512. closePath?: boolean;
  113513. offset?: number;
  113514. updatable?: boolean;
  113515. sideOrientation?: number;
  113516. frontUVs?: Vector4;
  113517. backUVs?: Vector4;
  113518. instance?: Mesh;
  113519. invertUV?: boolean;
  113520. uvs?: Vector2[];
  113521. colors?: Color4[];
  113522. }, scene?: Nullable<Scene>): Mesh;
  113523. }
  113524. }
  113525. declare module BABYLON {
  113526. /**
  113527. * Class containing static functions to help procedurally build meshes
  113528. */
  113529. export class ShapeBuilder {
  113530. /**
  113531. * 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.
  113532. * * 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.
  113533. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113534. * * 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.
  113535. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113536. * * 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
  113537. * * 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
  113538. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113543. * @param name defines the name of the mesh
  113544. * @param options defines the options used to create the mesh
  113545. * @param scene defines the hosting scene
  113546. * @returns the extruded shape mesh
  113547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113549. */
  113550. static ExtrudeShape(name: string, options: {
  113551. shape: Vector3[];
  113552. path: Vector3[];
  113553. scale?: number;
  113554. rotation?: number;
  113555. cap?: number;
  113556. updatable?: boolean;
  113557. sideOrientation?: number;
  113558. frontUVs?: Vector4;
  113559. backUVs?: Vector4;
  113560. instance?: Mesh;
  113561. invertUV?: boolean;
  113562. }, scene?: Nullable<Scene>): Mesh;
  113563. /**
  113564. * Creates an custom extruded shape mesh.
  113565. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113566. * * 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.
  113567. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113568. * * 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
  113569. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113570. * * 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
  113571. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113572. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113573. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113574. * * 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
  113575. * * 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
  113576. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113579. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113581. * @param name defines the name of the mesh
  113582. * @param options defines the options used to create the mesh
  113583. * @param scene defines the hosting scene
  113584. * @returns the custom extruded shape mesh
  113585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113586. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113587. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113588. */
  113589. static ExtrudeShapeCustom(name: string, options: {
  113590. shape: Vector3[];
  113591. path: Vector3[];
  113592. scaleFunction?: any;
  113593. rotationFunction?: any;
  113594. ribbonCloseArray?: boolean;
  113595. ribbonClosePath?: boolean;
  113596. cap?: number;
  113597. updatable?: boolean;
  113598. sideOrientation?: number;
  113599. frontUVs?: Vector4;
  113600. backUVs?: Vector4;
  113601. instance?: Mesh;
  113602. invertUV?: boolean;
  113603. }, scene?: Nullable<Scene>): Mesh;
  113604. private static _ExtrudeShapeGeneric;
  113605. }
  113606. }
  113607. declare module BABYLON {
  113608. /**
  113609. * AmmoJS Physics plugin
  113610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113611. * @see https://github.com/kripken/ammo.js/
  113612. */
  113613. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113614. private _useDeltaForWorldStep;
  113615. /**
  113616. * Reference to the Ammo library
  113617. */
  113618. bjsAMMO: any;
  113619. /**
  113620. * Created ammoJS world which physics bodies are added to
  113621. */
  113622. world: any;
  113623. /**
  113624. * Name of the plugin
  113625. */
  113626. name: string;
  113627. private _timeStep;
  113628. private _fixedTimeStep;
  113629. private _maxSteps;
  113630. private _tmpQuaternion;
  113631. private _tmpAmmoTransform;
  113632. private _tmpAmmoQuaternion;
  113633. private _tmpAmmoConcreteContactResultCallback;
  113634. private _collisionConfiguration;
  113635. private _dispatcher;
  113636. private _overlappingPairCache;
  113637. private _solver;
  113638. private _softBodySolver;
  113639. private _tmpAmmoVectorA;
  113640. private _tmpAmmoVectorB;
  113641. private _tmpAmmoVectorC;
  113642. private _tmpAmmoVectorD;
  113643. private _tmpContactCallbackResult;
  113644. private _tmpAmmoVectorRCA;
  113645. private _tmpAmmoVectorRCB;
  113646. private _raycastResult;
  113647. private static readonly DISABLE_COLLISION_FLAG;
  113648. private static readonly KINEMATIC_FLAG;
  113649. private static readonly DISABLE_DEACTIVATION_FLAG;
  113650. /**
  113651. * Initializes the ammoJS plugin
  113652. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113653. * @param ammoInjection can be used to inject your own ammo reference
  113654. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113655. */
  113656. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113657. /**
  113658. * Sets the gravity of the physics world (m/(s^2))
  113659. * @param gravity Gravity to set
  113660. */
  113661. setGravity(gravity: Vector3): void;
  113662. /**
  113663. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113664. * @param timeStep timestep to use in seconds
  113665. */
  113666. setTimeStep(timeStep: number): void;
  113667. /**
  113668. * 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)
  113669. * @param fixedTimeStep fixedTimeStep to use in seconds
  113670. */
  113671. setFixedTimeStep(fixedTimeStep: number): void;
  113672. /**
  113673. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113674. * @param maxSteps the maximum number of steps by the physics engine per frame
  113675. */
  113676. setMaxSteps(maxSteps: number): void;
  113677. /**
  113678. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113679. * @returns the current timestep in seconds
  113680. */
  113681. getTimeStep(): number;
  113682. private _isImpostorInContact;
  113683. private _isImpostorPairInContact;
  113684. private _stepSimulation;
  113685. /**
  113686. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113687. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113688. * After the step the babylon meshes are set to the position of the physics imposters
  113689. * @param delta amount of time to step forward
  113690. * @param impostors array of imposters to update before/after the step
  113691. */
  113692. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113693. /**
  113694. * Update babylon mesh to match physics world object
  113695. * @param impostor imposter to match
  113696. */
  113697. private _afterSoftStep;
  113698. /**
  113699. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113700. * @param impostor imposter to match
  113701. */
  113702. private _ropeStep;
  113703. /**
  113704. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113705. * @param impostor imposter to match
  113706. */
  113707. private _softbodyOrClothStep;
  113708. private _tmpVector;
  113709. private _tmpMatrix;
  113710. /**
  113711. * Applies an impulse on the imposter
  113712. * @param impostor imposter to apply impulse to
  113713. * @param force amount of force to be applied to the imposter
  113714. * @param contactPoint the location to apply the impulse on the imposter
  113715. */
  113716. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113717. /**
  113718. * Applies a force on the imposter
  113719. * @param impostor imposter to apply force
  113720. * @param force amount of force to be applied to the imposter
  113721. * @param contactPoint the location to apply the force on the imposter
  113722. */
  113723. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113724. /**
  113725. * Creates a physics body using the plugin
  113726. * @param impostor the imposter to create the physics body on
  113727. */
  113728. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113729. /**
  113730. * Removes the physics body from the imposter and disposes of the body's memory
  113731. * @param impostor imposter to remove the physics body from
  113732. */
  113733. removePhysicsBody(impostor: PhysicsImpostor): void;
  113734. /**
  113735. * Generates a joint
  113736. * @param impostorJoint the imposter joint to create the joint with
  113737. */
  113738. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113739. /**
  113740. * Removes a joint
  113741. * @param impostorJoint the imposter joint to remove the joint from
  113742. */
  113743. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113744. private _addMeshVerts;
  113745. /**
  113746. * Initialise the soft body vertices to match its object's (mesh) vertices
  113747. * Softbody vertices (nodes) are in world space and to match this
  113748. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113749. * @param impostor to create the softbody for
  113750. */
  113751. private _softVertexData;
  113752. /**
  113753. * Create an impostor's soft body
  113754. * @param impostor to create the softbody for
  113755. */
  113756. private _createSoftbody;
  113757. /**
  113758. * Create cloth for an impostor
  113759. * @param impostor to create the softbody for
  113760. */
  113761. private _createCloth;
  113762. /**
  113763. * Create rope for an impostor
  113764. * @param impostor to create the softbody for
  113765. */
  113766. private _createRope;
  113767. private _addHullVerts;
  113768. private _createShape;
  113769. /**
  113770. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113771. * @param impostor imposter containing the physics body and babylon object
  113772. */
  113773. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113774. /**
  113775. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113776. * @param impostor imposter containing the physics body and babylon object
  113777. * @param newPosition new position
  113778. * @param newRotation new rotation
  113779. */
  113780. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113781. /**
  113782. * If this plugin is supported
  113783. * @returns true if its supported
  113784. */
  113785. isSupported(): boolean;
  113786. /**
  113787. * Sets the linear velocity of the physics body
  113788. * @param impostor imposter to set the velocity on
  113789. * @param velocity velocity to set
  113790. */
  113791. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113792. /**
  113793. * Sets the angular velocity of the physics body
  113794. * @param impostor imposter to set the velocity on
  113795. * @param velocity velocity to set
  113796. */
  113797. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113798. /**
  113799. * gets the linear velocity
  113800. * @param impostor imposter to get linear velocity from
  113801. * @returns linear velocity
  113802. */
  113803. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113804. /**
  113805. * gets the angular velocity
  113806. * @param impostor imposter to get angular velocity from
  113807. * @returns angular velocity
  113808. */
  113809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113810. /**
  113811. * Sets the mass of physics body
  113812. * @param impostor imposter to set the mass on
  113813. * @param mass mass to set
  113814. */
  113815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113816. /**
  113817. * Gets the mass of the physics body
  113818. * @param impostor imposter to get the mass from
  113819. * @returns mass
  113820. */
  113821. getBodyMass(impostor: PhysicsImpostor): number;
  113822. /**
  113823. * Gets friction of the impostor
  113824. * @param impostor impostor to get friction from
  113825. * @returns friction value
  113826. */
  113827. getBodyFriction(impostor: PhysicsImpostor): number;
  113828. /**
  113829. * Sets friction of the impostor
  113830. * @param impostor impostor to set friction on
  113831. * @param friction friction value
  113832. */
  113833. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113834. /**
  113835. * Gets restitution of the impostor
  113836. * @param impostor impostor to get restitution from
  113837. * @returns restitution value
  113838. */
  113839. getBodyRestitution(impostor: PhysicsImpostor): number;
  113840. /**
  113841. * Sets resitution of the impostor
  113842. * @param impostor impostor to set resitution on
  113843. * @param restitution resitution value
  113844. */
  113845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113846. /**
  113847. * Gets pressure inside the impostor
  113848. * @param impostor impostor to get pressure from
  113849. * @returns pressure value
  113850. */
  113851. getBodyPressure(impostor: PhysicsImpostor): number;
  113852. /**
  113853. * Sets pressure inside a soft body impostor
  113854. * Cloth and rope must remain 0 pressure
  113855. * @param impostor impostor to set pressure on
  113856. * @param pressure pressure value
  113857. */
  113858. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  113859. /**
  113860. * Gets stiffness of the impostor
  113861. * @param impostor impostor to get stiffness from
  113862. * @returns pressure value
  113863. */
  113864. getBodyStiffness(impostor: PhysicsImpostor): number;
  113865. /**
  113866. * Sets stiffness of the impostor
  113867. * @param impostor impostor to set stiffness on
  113868. * @param stiffness stiffness value from 0 to 1
  113869. */
  113870. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  113871. /**
  113872. * Gets velocityIterations of the impostor
  113873. * @param impostor impostor to get velocity iterations from
  113874. * @returns velocityIterations value
  113875. */
  113876. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  113877. /**
  113878. * Sets velocityIterations of the impostor
  113879. * @param impostor impostor to set velocity iterations on
  113880. * @param velocityIterations velocityIterations value
  113881. */
  113882. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  113883. /**
  113884. * Gets positionIterations of the impostor
  113885. * @param impostor impostor to get position iterations from
  113886. * @returns positionIterations value
  113887. */
  113888. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  113889. /**
  113890. * Sets positionIterations of the impostor
  113891. * @param impostor impostor to set position on
  113892. * @param positionIterations positionIterations value
  113893. */
  113894. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  113895. /**
  113896. * Append an anchor to a cloth object
  113897. * @param impostor is the cloth impostor to add anchor to
  113898. * @param otherImpostor is the rigid impostor to anchor to
  113899. * @param width ratio across width from 0 to 1
  113900. * @param height ratio up height from 0 to 1
  113901. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113902. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113903. */
  113904. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113905. /**
  113906. * Append an hook to a rope object
  113907. * @param impostor is the rope impostor to add hook to
  113908. * @param otherImpostor is the rigid impostor to hook to
  113909. * @param length ratio along the rope from 0 to 1
  113910. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113911. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113912. */
  113913. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113914. /**
  113915. * Sleeps the physics body and stops it from being active
  113916. * @param impostor impostor to sleep
  113917. */
  113918. sleepBody(impostor: PhysicsImpostor): void;
  113919. /**
  113920. * Activates the physics body
  113921. * @param impostor impostor to activate
  113922. */
  113923. wakeUpBody(impostor: PhysicsImpostor): void;
  113924. /**
  113925. * Updates the distance parameters of the joint
  113926. * @param joint joint to update
  113927. * @param maxDistance maximum distance of the joint
  113928. * @param minDistance minimum distance of the joint
  113929. */
  113930. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113931. /**
  113932. * Sets a motor on the joint
  113933. * @param joint joint to set motor on
  113934. * @param speed speed of the motor
  113935. * @param maxForce maximum force of the motor
  113936. * @param motorIndex index of the motor
  113937. */
  113938. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113939. /**
  113940. * Sets the motors limit
  113941. * @param joint joint to set limit on
  113942. * @param upperLimit upper limit
  113943. * @param lowerLimit lower limit
  113944. */
  113945. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113946. /**
  113947. * Syncs the position and rotation of a mesh with the impostor
  113948. * @param mesh mesh to sync
  113949. * @param impostor impostor to update the mesh with
  113950. */
  113951. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113952. /**
  113953. * Gets the radius of the impostor
  113954. * @param impostor impostor to get radius from
  113955. * @returns the radius
  113956. */
  113957. getRadius(impostor: PhysicsImpostor): number;
  113958. /**
  113959. * Gets the box size of the impostor
  113960. * @param impostor impostor to get box size from
  113961. * @param result the resulting box size
  113962. */
  113963. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113964. /**
  113965. * Disposes of the impostor
  113966. */
  113967. dispose(): void;
  113968. /**
  113969. * Does a raycast in the physics world
  113970. * @param from when should the ray start?
  113971. * @param to when should the ray end?
  113972. * @returns PhysicsRaycastResult
  113973. */
  113974. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113975. }
  113976. }
  113977. declare module BABYLON {
  113978. interface AbstractScene {
  113979. /**
  113980. * The list of reflection probes added to the scene
  113981. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113982. */
  113983. reflectionProbes: Array<ReflectionProbe>;
  113984. /**
  113985. * Removes the given reflection probe from this scene.
  113986. * @param toRemove The reflection probe to remove
  113987. * @returns The index of the removed reflection probe
  113988. */
  113989. removeReflectionProbe(toRemove: ReflectionProbe): number;
  113990. /**
  113991. * Adds the given reflection probe to this scene.
  113992. * @param newReflectionProbe The reflection probe to add
  113993. */
  113994. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  113995. }
  113996. /**
  113997. * Class used to generate realtime reflection / refraction cube textures
  113998. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113999. */
  114000. export class ReflectionProbe {
  114001. /** defines the name of the probe */
  114002. name: string;
  114003. private _scene;
  114004. private _renderTargetTexture;
  114005. private _projectionMatrix;
  114006. private _viewMatrix;
  114007. private _target;
  114008. private _add;
  114009. private _attachedMesh;
  114010. private _invertYAxis;
  114011. /** Gets or sets probe position (center of the cube map) */
  114012. position: Vector3;
  114013. /**
  114014. * Creates a new reflection probe
  114015. * @param name defines the name of the probe
  114016. * @param size defines the texture resolution (for each face)
  114017. * @param scene defines the hosting scene
  114018. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  114019. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  114020. */
  114021. constructor(
  114022. /** defines the name of the probe */
  114023. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  114024. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  114025. samples: number;
  114026. /** Gets or sets the refresh rate to use (on every frame by default) */
  114027. refreshRate: number;
  114028. /**
  114029. * Gets the hosting scene
  114030. * @returns a Scene
  114031. */
  114032. getScene(): Scene;
  114033. /** Gets the internal CubeTexture used to render to */
  114034. readonly cubeTexture: RenderTargetTexture;
  114035. /** Gets the list of meshes to render */
  114036. readonly renderList: Nullable<AbstractMesh[]>;
  114037. /**
  114038. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114039. * @param mesh defines the mesh to attach to
  114040. */
  114041. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114042. /**
  114043. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114044. * @param renderingGroupId The rendering group id corresponding to its index
  114045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114046. */
  114047. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114048. /**
  114049. * Clean all associated resources
  114050. */
  114051. dispose(): void;
  114052. /**
  114053. * Converts the reflection probe information to a readable string for debug purpose.
  114054. * @param fullDetails Supports for multiple levels of logging within scene loading
  114055. * @returns the human readable reflection probe info
  114056. */
  114057. toString(fullDetails?: boolean): string;
  114058. /**
  114059. * Get the class name of the relfection probe.
  114060. * @returns "ReflectionProbe"
  114061. */
  114062. getClassName(): string;
  114063. /**
  114064. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114065. * @returns The JSON representation of the texture
  114066. */
  114067. serialize(): any;
  114068. /**
  114069. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114070. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114071. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114072. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114073. * @returns The parsed reflection probe if successful
  114074. */
  114075. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114076. }
  114077. }
  114078. declare module BABYLON {
  114079. /** @hidden */
  114080. export var _BabylonLoaderRegistered: boolean;
  114081. }
  114082. declare module BABYLON {
  114083. /**
  114084. * The Physically based simple base material of BJS.
  114085. *
  114086. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114087. * It is used as the base class for both the specGloss and metalRough conventions.
  114088. */
  114089. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114090. /**
  114091. * Number of Simultaneous lights allowed on the material.
  114092. */
  114093. maxSimultaneousLights: number;
  114094. /**
  114095. * If sets to true, disables all the lights affecting the material.
  114096. */
  114097. disableLighting: boolean;
  114098. /**
  114099. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114100. */
  114101. environmentTexture: BaseTexture;
  114102. /**
  114103. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114104. */
  114105. invertNormalMapX: boolean;
  114106. /**
  114107. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114108. */
  114109. invertNormalMapY: boolean;
  114110. /**
  114111. * Normal map used in the model.
  114112. */
  114113. normalTexture: BaseTexture;
  114114. /**
  114115. * Emissivie color used to self-illuminate the model.
  114116. */
  114117. emissiveColor: Color3;
  114118. /**
  114119. * Emissivie texture used to self-illuminate the model.
  114120. */
  114121. emissiveTexture: BaseTexture;
  114122. /**
  114123. * Occlusion Channel Strenght.
  114124. */
  114125. occlusionStrength: number;
  114126. /**
  114127. * Occlusion Texture of the material (adding extra occlusion effects).
  114128. */
  114129. occlusionTexture: BaseTexture;
  114130. /**
  114131. * Defines the alpha limits in alpha test mode.
  114132. */
  114133. alphaCutOff: number;
  114134. /**
  114135. * Gets the current double sided mode.
  114136. */
  114137. /**
  114138. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114139. */
  114140. doubleSided: boolean;
  114141. /**
  114142. * Stores the pre-calculated light information of a mesh in a texture.
  114143. */
  114144. lightmapTexture: BaseTexture;
  114145. /**
  114146. * If true, the light map contains occlusion information instead of lighting info.
  114147. */
  114148. useLightmapAsShadowmap: boolean;
  114149. /**
  114150. * Instantiates a new PBRMaterial instance.
  114151. *
  114152. * @param name The material name
  114153. * @param scene The scene the material will be use in.
  114154. */
  114155. constructor(name: string, scene: Scene);
  114156. getClassName(): string;
  114157. }
  114158. }
  114159. declare module BABYLON {
  114160. /**
  114161. * The PBR material of BJS following the metal roughness convention.
  114162. *
  114163. * This fits to the PBR convention in the GLTF definition:
  114164. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114165. */
  114166. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114167. /**
  114168. * The base color has two different interpretations depending on the value of metalness.
  114169. * When the material is a metal, the base color is the specific measured reflectance value
  114170. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114171. * of the material.
  114172. */
  114173. baseColor: Color3;
  114174. /**
  114175. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114176. * well as opacity information in the alpha channel.
  114177. */
  114178. baseTexture: BaseTexture;
  114179. /**
  114180. * Specifies the metallic scalar value of the material.
  114181. * Can also be used to scale the metalness values of the metallic texture.
  114182. */
  114183. metallic: number;
  114184. /**
  114185. * Specifies the roughness scalar value of the material.
  114186. * Can also be used to scale the roughness values of the metallic texture.
  114187. */
  114188. roughness: number;
  114189. /**
  114190. * Texture containing both the metallic value in the B channel and the
  114191. * roughness value in the G channel to keep better precision.
  114192. */
  114193. metallicRoughnessTexture: BaseTexture;
  114194. /**
  114195. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114196. *
  114197. * @param name The material name
  114198. * @param scene The scene the material will be use in.
  114199. */
  114200. constructor(name: string, scene: Scene);
  114201. /**
  114202. * Return the currrent class name of the material.
  114203. */
  114204. getClassName(): string;
  114205. /**
  114206. * Makes a duplicate of the current material.
  114207. * @param name - name to use for the new material.
  114208. */
  114209. clone(name: string): PBRMetallicRoughnessMaterial;
  114210. /**
  114211. * Serialize the material to a parsable JSON object.
  114212. */
  114213. serialize(): any;
  114214. /**
  114215. * Parses a JSON object correponding to the serialize function.
  114216. */
  114217. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114218. }
  114219. }
  114220. declare module BABYLON {
  114221. /**
  114222. * The PBR material of BJS following the specular glossiness convention.
  114223. *
  114224. * This fits to the PBR convention in the GLTF definition:
  114225. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114226. */
  114227. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114228. /**
  114229. * Specifies the diffuse color of the material.
  114230. */
  114231. diffuseColor: Color3;
  114232. /**
  114233. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114234. * channel.
  114235. */
  114236. diffuseTexture: BaseTexture;
  114237. /**
  114238. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114239. */
  114240. specularColor: Color3;
  114241. /**
  114242. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114243. */
  114244. glossiness: number;
  114245. /**
  114246. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114247. */
  114248. specularGlossinessTexture: BaseTexture;
  114249. /**
  114250. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114251. *
  114252. * @param name The material name
  114253. * @param scene The scene the material will be use in.
  114254. */
  114255. constructor(name: string, scene: Scene);
  114256. /**
  114257. * Return the currrent class name of the material.
  114258. */
  114259. getClassName(): string;
  114260. /**
  114261. * Makes a duplicate of the current material.
  114262. * @param name - name to use for the new material.
  114263. */
  114264. clone(name: string): PBRSpecularGlossinessMaterial;
  114265. /**
  114266. * Serialize the material to a parsable JSON object.
  114267. */
  114268. serialize(): any;
  114269. /**
  114270. * Parses a JSON object correponding to the serialize function.
  114271. */
  114272. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114273. }
  114274. }
  114275. declare module BABYLON {
  114276. /**
  114277. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114278. * It can help converting any input color in a desired output one. This can then be used to create effects
  114279. * from sepia, black and white to sixties or futuristic rendering...
  114280. *
  114281. * The only supported format is currently 3dl.
  114282. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114283. */
  114284. export class ColorGradingTexture extends BaseTexture {
  114285. /**
  114286. * The current texture matrix. (will always be identity in color grading texture)
  114287. */
  114288. private _textureMatrix;
  114289. /**
  114290. * The texture URL.
  114291. */
  114292. url: string;
  114293. /**
  114294. * Empty line regex stored for GC.
  114295. */
  114296. private static _noneEmptyLineRegex;
  114297. private _engine;
  114298. /**
  114299. * Instantiates a ColorGradingTexture from the following parameters.
  114300. *
  114301. * @param url The location of the color gradind data (currently only supporting 3dl)
  114302. * @param scene The scene the texture will be used in
  114303. */
  114304. constructor(url: string, scene: Scene);
  114305. /**
  114306. * Returns the texture matrix used in most of the material.
  114307. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114308. */
  114309. getTextureMatrix(): Matrix;
  114310. /**
  114311. * Occurs when the file being loaded is a .3dl LUT file.
  114312. */
  114313. private load3dlTexture;
  114314. /**
  114315. * Starts the loading process of the texture.
  114316. */
  114317. private loadTexture;
  114318. /**
  114319. * Clones the color gradind texture.
  114320. */
  114321. clone(): ColorGradingTexture;
  114322. /**
  114323. * Called during delayed load for textures.
  114324. */
  114325. delayLoad(): void;
  114326. /**
  114327. * Parses a color grading texture serialized by Babylon.
  114328. * @param parsedTexture The texture information being parsedTexture
  114329. * @param scene The scene to load the texture in
  114330. * @param rootUrl The root url of the data assets to load
  114331. * @return A color gradind texture
  114332. */
  114333. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114334. /**
  114335. * Serializes the LUT texture to json format.
  114336. */
  114337. serialize(): any;
  114338. }
  114339. }
  114340. declare module BABYLON {
  114341. /**
  114342. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114343. */
  114344. export class EquiRectangularCubeTexture extends BaseTexture {
  114345. /** The six faces of the cube. */
  114346. private static _FacesMapping;
  114347. private _noMipmap;
  114348. private _onLoad;
  114349. private _onError;
  114350. /** The size of the cubemap. */
  114351. private _size;
  114352. /** The buffer of the image. */
  114353. private _buffer;
  114354. /** The width of the input image. */
  114355. private _width;
  114356. /** The height of the input image. */
  114357. private _height;
  114358. /** The URL to the image. */
  114359. url: string;
  114360. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114361. coordinatesMode: number;
  114362. /**
  114363. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114364. * @param url The location of the image
  114365. * @param scene The scene the texture will be used in
  114366. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114367. * @param noMipmap Forces to not generate the mipmap if true
  114368. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114369. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114370. * @param onLoad — defines a callback called when texture is loaded
  114371. * @param onError — defines a callback called if there is an error
  114372. */
  114373. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114374. /**
  114375. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114376. */
  114377. private loadImage;
  114378. /**
  114379. * Convert the image buffer into a cubemap and create a CubeTexture.
  114380. */
  114381. private loadTexture;
  114382. /**
  114383. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114384. * @param buffer The ArrayBuffer that should be converted.
  114385. * @returns The buffer as Float32Array.
  114386. */
  114387. private getFloat32ArrayFromArrayBuffer;
  114388. /**
  114389. * Get the current class name of the texture useful for serialization or dynamic coding.
  114390. * @returns "EquiRectangularCubeTexture"
  114391. */
  114392. getClassName(): string;
  114393. /**
  114394. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114395. * @returns A clone of the current EquiRectangularCubeTexture.
  114396. */
  114397. clone(): EquiRectangularCubeTexture;
  114398. }
  114399. }
  114400. declare module BABYLON {
  114401. /**
  114402. * Based on jsTGALoader - Javascript loader for TGA file
  114403. * By Vincent Thibault
  114404. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114405. */
  114406. export class TGATools {
  114407. private static _TYPE_INDEXED;
  114408. private static _TYPE_RGB;
  114409. private static _TYPE_GREY;
  114410. private static _TYPE_RLE_INDEXED;
  114411. private static _TYPE_RLE_RGB;
  114412. private static _TYPE_RLE_GREY;
  114413. private static _ORIGIN_MASK;
  114414. private static _ORIGIN_SHIFT;
  114415. private static _ORIGIN_BL;
  114416. private static _ORIGIN_BR;
  114417. private static _ORIGIN_UL;
  114418. private static _ORIGIN_UR;
  114419. /**
  114420. * Gets the header of a TGA file
  114421. * @param data defines the TGA data
  114422. * @returns the header
  114423. */
  114424. static GetTGAHeader(data: Uint8Array): any;
  114425. /**
  114426. * Uploads TGA content to a Babylon Texture
  114427. * @hidden
  114428. */
  114429. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114430. /** @hidden */
  114431. 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;
  114432. /** @hidden */
  114433. 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;
  114434. /** @hidden */
  114435. 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;
  114436. /** @hidden */
  114437. 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;
  114438. /** @hidden */
  114439. 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;
  114440. /** @hidden */
  114441. 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;
  114442. }
  114443. }
  114444. declare module BABYLON {
  114445. /**
  114446. * Implementation of the TGA Texture Loader.
  114447. * @hidden
  114448. */
  114449. export class _TGATextureLoader implements IInternalTextureLoader {
  114450. /**
  114451. * Defines wether the loader supports cascade loading the different faces.
  114452. */
  114453. readonly supportCascades: boolean;
  114454. /**
  114455. * This returns if the loader support the current file information.
  114456. * @param extension defines the file extension of the file being loaded
  114457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114458. * @param fallback defines the fallback internal texture if any
  114459. * @param isBase64 defines whether the texture is encoded as a base64
  114460. * @param isBuffer defines whether the texture data are stored as a buffer
  114461. * @returns true if the loader can load the specified file
  114462. */
  114463. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114464. /**
  114465. * Transform the url before loading if required.
  114466. * @param rootUrl the url of the texture
  114467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114468. * @returns the transformed texture
  114469. */
  114470. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114471. /**
  114472. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114473. * @param rootUrl the url of the texture
  114474. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114475. * @returns the fallback texture
  114476. */
  114477. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114478. /**
  114479. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114480. * @param data contains the texture data
  114481. * @param texture defines the BabylonJS internal texture
  114482. * @param createPolynomials will be true if polynomials have been requested
  114483. * @param onLoad defines the callback to trigger once the texture is ready
  114484. * @param onError defines the callback to trigger in case of error
  114485. */
  114486. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114487. /**
  114488. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114489. * @param data contains the texture data
  114490. * @param texture defines the BabylonJS internal texture
  114491. * @param callback defines the method to call once ready to upload
  114492. */
  114493. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114494. }
  114495. }
  114496. declare module BABYLON {
  114497. /**
  114498. * Info about the .basis files
  114499. */
  114500. class BasisFileInfo {
  114501. /**
  114502. * If the file has alpha
  114503. */
  114504. hasAlpha: boolean;
  114505. /**
  114506. * Info about each image of the basis file
  114507. */
  114508. images: Array<{
  114509. levels: Array<{
  114510. width: number;
  114511. height: number;
  114512. transcodedPixels: ArrayBufferView;
  114513. }>;
  114514. }>;
  114515. }
  114516. /**
  114517. * Result of transcoding a basis file
  114518. */
  114519. class TranscodeResult {
  114520. /**
  114521. * Info about the .basis file
  114522. */
  114523. fileInfo: BasisFileInfo;
  114524. /**
  114525. * Format to use when loading the file
  114526. */
  114527. format: number;
  114528. }
  114529. /**
  114530. * Configuration options for the Basis transcoder
  114531. */
  114532. export class BasisTranscodeConfiguration {
  114533. /**
  114534. * Supported compression formats used to determine the supported output format of the transcoder
  114535. */
  114536. supportedCompressionFormats?: {
  114537. /**
  114538. * etc1 compression format
  114539. */
  114540. etc1?: boolean;
  114541. /**
  114542. * s3tc compression format
  114543. */
  114544. s3tc?: boolean;
  114545. /**
  114546. * pvrtc compression format
  114547. */
  114548. pvrtc?: boolean;
  114549. /**
  114550. * etc2 compression format
  114551. */
  114552. etc2?: boolean;
  114553. };
  114554. /**
  114555. * If mipmap levels should be loaded for transcoded images (Default: true)
  114556. */
  114557. loadMipmapLevels?: boolean;
  114558. /**
  114559. * Index of a single image to load (Default: all images)
  114560. */
  114561. loadSingleImage?: number;
  114562. }
  114563. /**
  114564. * Used to load .Basis files
  114565. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114566. */
  114567. export class BasisTools {
  114568. private static _IgnoreSupportedFormats;
  114569. /**
  114570. * URL to use when loading the basis transcoder
  114571. */
  114572. static JSModuleURL: string;
  114573. /**
  114574. * URL to use when loading the wasm module for the transcoder
  114575. */
  114576. static WasmModuleURL: string;
  114577. /**
  114578. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114579. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114580. * @returns internal format corresponding to the Basis format
  114581. */
  114582. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114583. private static _WorkerPromise;
  114584. private static _Worker;
  114585. private static _actionId;
  114586. private static _CreateWorkerAsync;
  114587. /**
  114588. * Transcodes a loaded image file to compressed pixel data
  114589. * @param imageData image data to transcode
  114590. * @param config configuration options for the transcoding
  114591. * @returns a promise resulting in the transcoded image
  114592. */
  114593. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114594. /**
  114595. * Loads a texture from the transcode result
  114596. * @param texture texture load to
  114597. * @param transcodeResult the result of transcoding the basis file to load from
  114598. */
  114599. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114600. }
  114601. }
  114602. declare module BABYLON {
  114603. /**
  114604. * Loader for .basis file format
  114605. */
  114606. export class _BasisTextureLoader implements IInternalTextureLoader {
  114607. /**
  114608. * Defines whether the loader supports cascade loading the different faces.
  114609. */
  114610. readonly supportCascades: boolean;
  114611. /**
  114612. * This returns if the loader support the current file information.
  114613. * @param extension defines the file extension of the file being loaded
  114614. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114615. * @param fallback defines the fallback internal texture if any
  114616. * @param isBase64 defines whether the texture is encoded as a base64
  114617. * @param isBuffer defines whether the texture data are stored as a buffer
  114618. * @returns true if the loader can load the specified file
  114619. */
  114620. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114621. /**
  114622. * Transform the url before loading if required.
  114623. * @param rootUrl the url of the texture
  114624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114625. * @returns the transformed texture
  114626. */
  114627. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114628. /**
  114629. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114630. * @param rootUrl the url of the texture
  114631. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114632. * @returns the fallback texture
  114633. */
  114634. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114635. /**
  114636. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114637. * @param data contains the texture data
  114638. * @param texture defines the BabylonJS internal texture
  114639. * @param createPolynomials will be true if polynomials have been requested
  114640. * @param onLoad defines the callback to trigger once the texture is ready
  114641. * @param onError defines the callback to trigger in case of error
  114642. */
  114643. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114644. /**
  114645. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114646. * @param data contains the texture data
  114647. * @param texture defines the BabylonJS internal texture
  114648. * @param callback defines the method to call once ready to upload
  114649. */
  114650. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114651. }
  114652. }
  114653. declare module BABYLON {
  114654. /**
  114655. * 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.
  114656. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114657. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114658. */
  114659. export class CustomProceduralTexture extends ProceduralTexture {
  114660. private _animate;
  114661. private _time;
  114662. private _config;
  114663. private _texturePath;
  114664. /**
  114665. * Instantiates a new Custom Procedural Texture.
  114666. * 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.
  114667. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114668. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114669. * @param name Define the name of the texture
  114670. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114671. * @param size Define the size of the texture to create
  114672. * @param scene Define the scene the texture belongs to
  114673. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114674. * @param generateMipMaps Define if the texture should creates mip maps or not
  114675. */
  114676. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114677. private _loadJson;
  114678. /**
  114679. * Is the texture ready to be used ? (rendered at least once)
  114680. * @returns true if ready, otherwise, false.
  114681. */
  114682. isReady(): boolean;
  114683. /**
  114684. * Render the texture to its associated render target.
  114685. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114686. */
  114687. render(useCameraPostProcess?: boolean): void;
  114688. /**
  114689. * Update the list of dependant textures samplers in the shader.
  114690. */
  114691. updateTextures(): void;
  114692. /**
  114693. * Update the uniform values of the procedural texture in the shader.
  114694. */
  114695. updateShaderUniforms(): void;
  114696. /**
  114697. * Define if the texture animates or not.
  114698. */
  114699. animate: boolean;
  114700. }
  114701. }
  114702. declare module BABYLON {
  114703. /** @hidden */
  114704. export var noisePixelShader: {
  114705. name: string;
  114706. shader: string;
  114707. };
  114708. }
  114709. declare module BABYLON {
  114710. /**
  114711. * Class used to generate noise procedural textures
  114712. */
  114713. export class NoiseProceduralTexture extends ProceduralTexture {
  114714. private _time;
  114715. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114716. brightness: number;
  114717. /** Defines the number of octaves to process */
  114718. octaves: number;
  114719. /** Defines the level of persistence (0.8 by default) */
  114720. persistence: number;
  114721. /** Gets or sets animation speed factor (default is 1) */
  114722. animationSpeedFactor: number;
  114723. /**
  114724. * Creates a new NoiseProceduralTexture
  114725. * @param name defines the name fo the texture
  114726. * @param size defines the size of the texture (default is 256)
  114727. * @param scene defines the hosting scene
  114728. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114729. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114730. */
  114731. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114732. private _updateShaderUniforms;
  114733. protected _getDefines(): string;
  114734. /** Generate the current state of the procedural texture */
  114735. render(useCameraPostProcess?: boolean): void;
  114736. /**
  114737. * Serializes this noise procedural texture
  114738. * @returns a serialized noise procedural texture object
  114739. */
  114740. serialize(): any;
  114741. /**
  114742. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114743. * @param parsedTexture defines parsed texture data
  114744. * @param scene defines the current scene
  114745. * @param rootUrl defines the root URL containing noise procedural texture information
  114746. * @returns a parsed NoiseProceduralTexture
  114747. */
  114748. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114749. }
  114750. }
  114751. declare module BABYLON {
  114752. /**
  114753. * Raw cube texture where the raw buffers are passed in
  114754. */
  114755. export class RawCubeTexture extends CubeTexture {
  114756. /**
  114757. * Creates a cube texture where the raw buffers are passed in.
  114758. * @param scene defines the scene the texture is attached to
  114759. * @param data defines the array of data to use to create each face
  114760. * @param size defines the size of the textures
  114761. * @param format defines the format of the data
  114762. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114763. * @param generateMipMaps defines if the engine should generate the mip levels
  114764. * @param invertY defines if data must be stored with Y axis inverted
  114765. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114766. * @param compression defines the compression used (null by default)
  114767. */
  114768. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114769. /**
  114770. * Updates the raw cube texture.
  114771. * @param data defines the data to store
  114772. * @param format defines the data format
  114773. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114774. * @param invertY defines if data must be stored with Y axis inverted
  114775. * @param compression defines the compression used (null by default)
  114776. * @param level defines which level of the texture to update
  114777. */
  114778. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114779. /**
  114780. * Updates a raw cube texture with RGBD encoded data.
  114781. * @param data defines the array of data [mipmap][face] to use to create each face
  114782. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114783. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114784. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114785. * @returns a promsie that resolves when the operation is complete
  114786. */
  114787. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114788. /**
  114789. * Clones the raw cube texture.
  114790. * @return a new cube texture
  114791. */
  114792. clone(): CubeTexture;
  114793. /** @hidden */
  114794. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114795. }
  114796. }
  114797. declare module BABYLON {
  114798. /**
  114799. * Class used to store 3D textures containing user data
  114800. */
  114801. export class RawTexture3D extends Texture {
  114802. /** Gets or sets the texture format to use */
  114803. format: number;
  114804. private _engine;
  114805. /**
  114806. * Create a new RawTexture3D
  114807. * @param data defines the data of the texture
  114808. * @param width defines the width of the texture
  114809. * @param height defines the height of the texture
  114810. * @param depth defines the depth of the texture
  114811. * @param format defines the texture format to use
  114812. * @param scene defines the hosting scene
  114813. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  114814. * @param invertY defines if texture must be stored with Y axis inverted
  114815. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114816. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  114817. */
  114818. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  114819. /** Gets or sets the texture format to use */
  114820. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  114821. /**
  114822. * Update the texture with new data
  114823. * @param data defines the data to store in the texture
  114824. */
  114825. update(data: ArrayBufferView): void;
  114826. }
  114827. }
  114828. declare module BABYLON {
  114829. /**
  114830. * Creates a refraction texture used by refraction channel of the standard material.
  114831. * It is like a mirror but to see through a material.
  114832. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114833. */
  114834. export class RefractionTexture extends RenderTargetTexture {
  114835. /**
  114836. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  114837. * 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.
  114838. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114839. */
  114840. refractionPlane: Plane;
  114841. /**
  114842. * Define how deep under the surface we should see.
  114843. */
  114844. depth: number;
  114845. /**
  114846. * Creates a refraction texture used by refraction channel of the standard material.
  114847. * It is like a mirror but to see through a material.
  114848. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114849. * @param name Define the texture name
  114850. * @param size Define the size of the underlying texture
  114851. * @param scene Define the scene the refraction belongs to
  114852. * @param generateMipMaps Define if we need to generate mips level for the refraction
  114853. */
  114854. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  114855. /**
  114856. * Clone the refraction texture.
  114857. * @returns the cloned texture
  114858. */
  114859. clone(): RefractionTexture;
  114860. /**
  114861. * Serialize the texture to a JSON representation you could use in Parse later on
  114862. * @returns the serialized JSON representation
  114863. */
  114864. serialize(): any;
  114865. }
  114866. }
  114867. declare module BABYLON {
  114868. /**
  114869. * Defines the options related to the creation of an HtmlElementTexture
  114870. */
  114871. export interface IHtmlElementTextureOptions {
  114872. /**
  114873. * Defines wether mip maps should be created or not.
  114874. */
  114875. generateMipMaps?: boolean;
  114876. /**
  114877. * Defines the sampling mode of the texture.
  114878. */
  114879. samplingMode?: number;
  114880. /**
  114881. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  114882. */
  114883. engine: Nullable<Engine>;
  114884. /**
  114885. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  114886. */
  114887. scene: Nullable<Scene>;
  114888. }
  114889. /**
  114890. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  114891. * To be as efficient as possible depending on your constraints nothing aside the first upload
  114892. * is automatically managed.
  114893. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  114894. * in your application.
  114895. *
  114896. * As the update is not automatic, you need to call them manually.
  114897. */
  114898. export class HtmlElementTexture extends BaseTexture {
  114899. /**
  114900. * The texture URL.
  114901. */
  114902. element: HTMLVideoElement | HTMLCanvasElement;
  114903. private static readonly DefaultOptions;
  114904. private _textureMatrix;
  114905. private _engine;
  114906. private _isVideo;
  114907. private _generateMipMaps;
  114908. private _samplingMode;
  114909. /**
  114910. * Instantiates a HtmlElementTexture from the following parameters.
  114911. *
  114912. * @param name Defines the name of the texture
  114913. * @param element Defines the video or canvas the texture is filled with
  114914. * @param options Defines the other none mandatory texture creation options
  114915. */
  114916. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  114917. private _createInternalTexture;
  114918. /**
  114919. * Returns the texture matrix used in most of the material.
  114920. */
  114921. getTextureMatrix(): Matrix;
  114922. /**
  114923. * Updates the content of the texture.
  114924. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  114925. */
  114926. update(invertY?: Nullable<boolean>): void;
  114927. }
  114928. }
  114929. declare module BABYLON {
  114930. /**
  114931. * Enum used to define the target of a block
  114932. */
  114933. export enum NodeMaterialBlockTargets {
  114934. /** Vertex shader */
  114935. Vertex = 1,
  114936. /** Fragment shader */
  114937. Fragment = 2,
  114938. /** Neutral */
  114939. Neutral = 4,
  114940. /** Vertex and Fragment */
  114941. VertexAndFragment = 3
  114942. }
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * Defines the kind of connection point for node based material
  114947. */
  114948. export enum NodeMaterialBlockConnectionPointTypes {
  114949. /** Float */
  114950. Float = 1,
  114951. /** Int */
  114952. Int = 2,
  114953. /** Vector2 */
  114954. Vector2 = 4,
  114955. /** Vector3 */
  114956. Vector3 = 8,
  114957. /** Vector4 */
  114958. Vector4 = 16,
  114959. /** Color3 */
  114960. Color3 = 32,
  114961. /** Color4 */
  114962. Color4 = 64,
  114963. /** Matrix */
  114964. Matrix = 128,
  114965. /** Vector3 or Color3 */
  114966. Vector3OrColor3 = 40,
  114967. /** Vector3 or Vector4 */
  114968. Vector3OrVector4 = 24,
  114969. /** Vector4 or Color4 */
  114970. Vector4OrColor4 = 80,
  114971. /** Color3 or Color4 */
  114972. Color3OrColor4 = 96,
  114973. /** Vector2 or Color3 or Color4 */
  114974. Vector2OrColor3OrColor4 = 100,
  114975. /** Vector3 or Color3 or Color4 or Vector4 */
  114976. Vector3OrColor3OrVector4OrColor4 = 120,
  114977. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  114978. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  114979. /** Detect type based on connection */
  114980. AutoDetect = 1024,
  114981. /** Output type that will be defined by input type */
  114982. BasedOnInput = 2048
  114983. }
  114984. }
  114985. declare module BABYLON {
  114986. /**
  114987. * Root class for all node material optimizers
  114988. */
  114989. export class NodeMaterialOptimizer {
  114990. /**
  114991. * Function used to optimize a NodeMaterial graph
  114992. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  114993. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  114994. */
  114995. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  114996. }
  114997. }
  114998. declare module BABYLON {
  114999. /**
  115000. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  115001. */
  115002. export class TransformBlock extends NodeMaterialBlock {
  115003. /**
  115004. * Defines the value to use to complement W value to transform it to a Vector4
  115005. */
  115006. complementW: number;
  115007. /**
  115008. * Defines the value to use to complement z value to transform it to a Vector4
  115009. */
  115010. complementZ: number;
  115011. /**
  115012. * Creates a new TransformBlock
  115013. * @param name defines the block name
  115014. */
  115015. constructor(name: string);
  115016. /**
  115017. * Gets the current class name
  115018. * @returns the class name
  115019. */
  115020. getClassName(): string;
  115021. /**
  115022. * Gets the vector input
  115023. */
  115024. readonly vector: NodeMaterialConnectionPoint;
  115025. /**
  115026. * Gets the output component
  115027. */
  115028. readonly output: NodeMaterialConnectionPoint;
  115029. /**
  115030. * Gets the matrix transform input
  115031. */
  115032. readonly transform: NodeMaterialConnectionPoint;
  115033. protected _buildBlock(state: NodeMaterialBuildState): this;
  115034. }
  115035. }
  115036. declare module BABYLON {
  115037. /**
  115038. * Block used to output the vertex position
  115039. */
  115040. export class VertexOutputBlock extends NodeMaterialBlock {
  115041. /**
  115042. * Creates a new VertexOutputBlock
  115043. * @param name defines the block name
  115044. */
  115045. constructor(name: string);
  115046. /**
  115047. * Gets the current class name
  115048. * @returns the class name
  115049. */
  115050. getClassName(): string;
  115051. /**
  115052. * Gets the vector input component
  115053. */
  115054. readonly vector: NodeMaterialConnectionPoint;
  115055. protected _buildBlock(state: NodeMaterialBuildState): this;
  115056. }
  115057. }
  115058. declare module BABYLON {
  115059. /**
  115060. * Block used to output the final color
  115061. */
  115062. export class FragmentOutputBlock extends NodeMaterialBlock {
  115063. /**
  115064. * Create a new FragmentOutputBlock
  115065. * @param name defines the block name
  115066. */
  115067. constructor(name: string);
  115068. /**
  115069. * Gets the current class name
  115070. * @returns the class name
  115071. */
  115072. getClassName(): string;
  115073. /**
  115074. * Gets the rgba input component
  115075. */
  115076. readonly rgba: NodeMaterialConnectionPoint;
  115077. /**
  115078. * Gets the rgb input component
  115079. */
  115080. readonly rgb: NodeMaterialConnectionPoint;
  115081. /**
  115082. * Gets the a input component
  115083. */
  115084. readonly a: NodeMaterialConnectionPoint;
  115085. protected _buildBlock(state: NodeMaterialBuildState): this;
  115086. }
  115087. }
  115088. declare module BABYLON {
  115089. /**
  115090. * Interface used to configure the node material editor
  115091. */
  115092. export interface INodeMaterialEditorOptions {
  115093. /** Define the URl to load node editor script */
  115094. editorURL?: string;
  115095. }
  115096. /** @hidden */
  115097. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115098. /** BONES */
  115099. NUM_BONE_INFLUENCERS: number;
  115100. BonesPerMesh: number;
  115101. BONETEXTURE: boolean;
  115102. /** MORPH TARGETS */
  115103. MORPHTARGETS: boolean;
  115104. MORPHTARGETS_NORMAL: boolean;
  115105. MORPHTARGETS_TANGENT: boolean;
  115106. MORPHTARGETS_UV: boolean;
  115107. NUM_MORPH_INFLUENCERS: number;
  115108. /** IMAGE PROCESSING */
  115109. IMAGEPROCESSING: boolean;
  115110. VIGNETTE: boolean;
  115111. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115112. VIGNETTEBLENDMODEOPAQUE: boolean;
  115113. TONEMAPPING: boolean;
  115114. TONEMAPPING_ACES: boolean;
  115115. CONTRAST: boolean;
  115116. EXPOSURE: boolean;
  115117. COLORCURVES: boolean;
  115118. COLORGRADING: boolean;
  115119. COLORGRADING3D: boolean;
  115120. SAMPLER3DGREENDEPTH: boolean;
  115121. SAMPLER3DBGRMAP: boolean;
  115122. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115123. constructor();
  115124. setValue(name: string, value: boolean): void;
  115125. }
  115126. /**
  115127. * Class used to configure NodeMaterial
  115128. */
  115129. export interface INodeMaterialOptions {
  115130. /**
  115131. * Defines if blocks should emit comments
  115132. */
  115133. emitComments: boolean;
  115134. }
  115135. /**
  115136. * Class used to create a node based material built by assembling shader blocks
  115137. */
  115138. export class NodeMaterial extends PushMaterial {
  115139. private _options;
  115140. private _vertexCompilationState;
  115141. private _fragmentCompilationState;
  115142. private _sharedData;
  115143. private _buildId;
  115144. private _buildWasSuccessful;
  115145. private _cachedWorldViewMatrix;
  115146. private _cachedWorldViewProjectionMatrix;
  115147. private _optimizers;
  115148. /** Define the URl to load node editor script */
  115149. static EditorURL: string;
  115150. private BJSNODEMATERIALEDITOR;
  115151. /** Get the inspector from bundle or global */
  115152. private _getGlobalNodeMaterialEditor;
  115153. /**
  115154. * 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)
  115155. */
  115156. ignoreAlpha: boolean;
  115157. /**
  115158. * Defines the maximum number of lights that can be used in the material
  115159. */
  115160. maxSimultaneousLights: number;
  115161. /**
  115162. * Observable raised when the material is built
  115163. */
  115164. onBuildObservable: Observable<NodeMaterial>;
  115165. /**
  115166. * Gets or sets the root nodes of the material vertex shader
  115167. */
  115168. _vertexOutputNodes: NodeMaterialBlock[];
  115169. /**
  115170. * Gets or sets the root nodes of the material fragment (pixel) shader
  115171. */
  115172. _fragmentOutputNodes: NodeMaterialBlock[];
  115173. /** Gets or sets options to control the node material overall behavior */
  115174. options: INodeMaterialOptions;
  115175. /**
  115176. * Default configuration related to image processing available in the standard Material.
  115177. */
  115178. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115179. /**
  115180. * Gets the image processing configuration used either in this material.
  115181. */
  115182. /**
  115183. * Sets the Default image processing configuration used either in the this material.
  115184. *
  115185. * If sets to null, the scene one is in use.
  115186. */
  115187. imageProcessingConfiguration: ImageProcessingConfiguration;
  115188. /**
  115189. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  115190. */
  115191. attachedBlocks: NodeMaterialBlock[];
  115192. /**
  115193. * Create a new node based material
  115194. * @param name defines the material name
  115195. * @param scene defines the hosting scene
  115196. * @param options defines creation option
  115197. */
  115198. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115199. /**
  115200. * Gets the current class name of the material e.g. "NodeMaterial"
  115201. * @returns the class name
  115202. */
  115203. getClassName(): string;
  115204. /**
  115205. * Keep track of the image processing observer to allow dispose and replace.
  115206. */
  115207. private _imageProcessingObserver;
  115208. /**
  115209. * Attaches a new image processing configuration to the Standard Material.
  115210. * @param configuration
  115211. */
  115212. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115213. /**
  115214. * Adds a new optimizer to the list of optimizers
  115215. * @param optimizer defines the optimizers to add
  115216. * @returns the current material
  115217. */
  115218. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115219. /**
  115220. * Remove an optimizer from the list of optimizers
  115221. * @param optimizer defines the optimizers to remove
  115222. * @returns the current material
  115223. */
  115224. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115225. /**
  115226. * Add a new block to the list of output nodes
  115227. * @param node defines the node to add
  115228. * @returns the current material
  115229. */
  115230. addOutputNode(node: NodeMaterialBlock): this;
  115231. /**
  115232. * Remove a block from the list of root nodes
  115233. * @param node defines the node to remove
  115234. * @returns the current material
  115235. */
  115236. removeOutputNode(node: NodeMaterialBlock): this;
  115237. private _addVertexOutputNode;
  115238. private _removeVertexOutputNode;
  115239. private _addFragmentOutputNode;
  115240. private _removeFragmentOutputNode;
  115241. /**
  115242. * Specifies if the material will require alpha blending
  115243. * @returns a boolean specifying if alpha blending is needed
  115244. */
  115245. needAlphaBlending(): boolean;
  115246. /**
  115247. * Specifies if this material should be rendered in alpha test mode
  115248. * @returns a boolean specifying if an alpha test is needed.
  115249. */
  115250. needAlphaTesting(): boolean;
  115251. private _initializeBlock;
  115252. private _resetDualBlocks;
  115253. /**
  115254. * Build the material and generates the inner effect
  115255. * @param verbose defines if the build should log activity
  115256. */
  115257. build(verbose?: boolean): void;
  115258. /**
  115259. * Runs an otpimization phase to try to improve the shader code
  115260. */
  115261. optimize(): void;
  115262. private _prepareDefinesForAttributes;
  115263. /**
  115264. * Get if the submesh is ready to be used and all its information available.
  115265. * Child classes can use it to update shaders
  115266. * @param mesh defines the mesh to check
  115267. * @param subMesh defines which submesh to check
  115268. * @param useInstances specifies that instances should be used
  115269. * @returns a boolean indicating that the submesh is ready or not
  115270. */
  115271. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115272. /**
  115273. * Get a string representing the shaders built by the current node graph
  115274. */
  115275. readonly compiledShaders: string;
  115276. /**
  115277. * Binds the world matrix to the material
  115278. * @param world defines the world transformation matrix
  115279. */
  115280. bindOnlyWorldMatrix(world: Matrix): void;
  115281. /**
  115282. * Binds the submesh to this material by preparing the effect and shader to draw
  115283. * @param world defines the world transformation matrix
  115284. * @param mesh defines the mesh containing the submesh
  115285. * @param subMesh defines the submesh to bind the material to
  115286. */
  115287. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115288. /**
  115289. * Gets the active textures from the material
  115290. * @returns an array of textures
  115291. */
  115292. getActiveTextures(): BaseTexture[];
  115293. /**
  115294. * Specifies if the material uses a texture
  115295. * @param texture defines the texture to check against the material
  115296. * @returns a boolean specifying if the material uses the texture
  115297. */
  115298. hasTexture(texture: BaseTexture): boolean;
  115299. /**
  115300. * Disposes the material
  115301. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115302. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115303. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115304. */
  115305. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115306. /** Creates the node editor window. */
  115307. private _createNodeEditor;
  115308. /**
  115309. * Launch the node material editor
  115310. * @param config Define the configuration of the editor
  115311. * @return a promise fulfilled when the node editor is visible
  115312. */
  115313. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115314. /**
  115315. * Clear the current material
  115316. */
  115317. clear(): void;
  115318. /**
  115319. * Clear the current material and set it to a default state
  115320. */
  115321. setToDefault(): void;
  115322. private _gatherBlocks;
  115323. /**
  115324. * Serializes this material in a JSON representation
  115325. * @returns the serialized material object
  115326. */
  115327. serialize(): any;
  115328. /**
  115329. * Clear the current graph and load a new one from a serialization object
  115330. * @param source defines the JSON representation of the material
  115331. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115332. */
  115333. loadFromSerialization(source: any, rootUrl?: string): void;
  115334. /**
  115335. * Creates a node material from parsed material data
  115336. * @param source defines the JSON representation of the material
  115337. * @param scene defines the hosting scene
  115338. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115339. * @returns a new node material
  115340. */
  115341. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115342. }
  115343. }
  115344. declare module BABYLON {
  115345. /**
  115346. * Block used to read a texture from a sampler
  115347. */
  115348. export class TextureBlock extends NodeMaterialBlock {
  115349. private _defineName;
  115350. private _samplerName;
  115351. private _transformedUVName;
  115352. private _textureTransformName;
  115353. private _textureInfoName;
  115354. private _mainUVName;
  115355. private _mainUVDefineName;
  115356. /**
  115357. * Gets or sets the texture associated with the node
  115358. */
  115359. texture: Nullable<BaseTexture>;
  115360. /**
  115361. * Create a new TextureBlock
  115362. * @param name defines the block name
  115363. */
  115364. constructor(name: string);
  115365. /**
  115366. * Gets the current class name
  115367. * @returns the class name
  115368. */
  115369. getClassName(): string;
  115370. /**
  115371. * Gets the uv input component
  115372. */
  115373. readonly uv: NodeMaterialConnectionPoint;
  115374. /**
  115375. * Gets the output component
  115376. */
  115377. readonly output: NodeMaterialConnectionPoint;
  115378. autoConfigure(): void;
  115379. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115381. isReady(): boolean;
  115382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115383. private _injectVertexCode;
  115384. private _writeOutput;
  115385. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115386. serialize(): any;
  115387. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115388. }
  115389. }
  115390. declare module BABYLON {
  115391. /**
  115392. * Class used to store shared data between 2 NodeMaterialBuildState
  115393. */
  115394. export class NodeMaterialBuildStateSharedData {
  115395. /**
  115396. * Gets the list of emitted varyings
  115397. */
  115398. varyings: string[];
  115399. /**
  115400. * Gets the varying declaration string
  115401. */
  115402. varyingDeclaration: string;
  115403. /**
  115404. * Input blocks
  115405. */
  115406. inputBlocks: InputBlock[];
  115407. /**
  115408. * Input blocks
  115409. */
  115410. textureBlocks: TextureBlock[];
  115411. /**
  115412. * Bindable blocks (Blocks that need to set data to the effect)
  115413. */
  115414. bindableBlocks: NodeMaterialBlock[];
  115415. /**
  115416. * List of blocks that can provide a compilation fallback
  115417. */
  115418. blocksWithFallbacks: NodeMaterialBlock[];
  115419. /**
  115420. * List of blocks that can provide a define update
  115421. */
  115422. blocksWithDefines: NodeMaterialBlock[];
  115423. /**
  115424. * List of blocks that can provide a repeatable content
  115425. */
  115426. repeatableContentBlocks: NodeMaterialBlock[];
  115427. /**
  115428. * List of blocks that can provide a dynamic list of uniforms
  115429. */
  115430. dynamicUniformBlocks: NodeMaterialBlock[];
  115431. /**
  115432. * List of blocks that can block the isReady function for the material
  115433. */
  115434. blockingBlocks: NodeMaterialBlock[];
  115435. /**
  115436. * Build Id used to avoid multiple recompilations
  115437. */
  115438. buildId: number;
  115439. /** List of emitted variables */
  115440. variableNames: {
  115441. [key: string]: number;
  115442. };
  115443. /** List of emitted defines */
  115444. defineNames: {
  115445. [key: string]: number;
  115446. };
  115447. /** Should emit comments? */
  115448. emitComments: boolean;
  115449. /** Emit build activity */
  115450. verbose: boolean;
  115451. /**
  115452. * Gets the compilation hints emitted at compilation time
  115453. */
  115454. hints: {
  115455. needWorldViewMatrix: boolean;
  115456. needWorldViewProjectionMatrix: boolean;
  115457. needAlphaBlending: boolean;
  115458. needAlphaTesting: boolean;
  115459. };
  115460. /**
  115461. * List of compilation checks
  115462. */
  115463. checks: {
  115464. emitVertex: boolean;
  115465. emitFragment: boolean;
  115466. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115467. };
  115468. /** Creates a new shared data */
  115469. constructor();
  115470. /**
  115471. * Emits console errors and exceptions if there is a failing check
  115472. */
  115473. emitErrors(): void;
  115474. }
  115475. }
  115476. declare module BABYLON {
  115477. /**
  115478. * Class used to store node based material build state
  115479. */
  115480. export class NodeMaterialBuildState {
  115481. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115482. supportUniformBuffers: boolean;
  115483. /**
  115484. * Gets the list of emitted attributes
  115485. */
  115486. attributes: string[];
  115487. /**
  115488. * Gets the list of emitted uniforms
  115489. */
  115490. uniforms: string[];
  115491. /**
  115492. * Gets the list of emitted uniform buffers
  115493. */
  115494. uniformBuffers: string[];
  115495. /**
  115496. * Gets the list of emitted samplers
  115497. */
  115498. samplers: string[];
  115499. /**
  115500. * Gets the list of emitted functions
  115501. */
  115502. functions: {
  115503. [key: string]: string;
  115504. };
  115505. /**
  115506. * Gets the target of the compilation state
  115507. */
  115508. target: NodeMaterialBlockTargets;
  115509. /**
  115510. * Gets the list of emitted counters
  115511. */
  115512. counters: {
  115513. [key: string]: number;
  115514. };
  115515. /**
  115516. * Shared data between multiple NodeMaterialBuildState instances
  115517. */
  115518. sharedData: NodeMaterialBuildStateSharedData;
  115519. /** @hidden */
  115520. _vertexState: NodeMaterialBuildState;
  115521. /** @hidden */
  115522. _attributeDeclaration: string;
  115523. /** @hidden */
  115524. _uniformDeclaration: string;
  115525. /** @hidden */
  115526. _samplerDeclaration: string;
  115527. /** @hidden */
  115528. _varyingTransfer: string;
  115529. private _repeatableContentAnchorIndex;
  115530. /** @hidden */
  115531. _builtCompilationString: string;
  115532. /**
  115533. * Gets the emitted compilation strings
  115534. */
  115535. compilationString: string;
  115536. /**
  115537. * Finalize the compilation strings
  115538. * @param state defines the current compilation state
  115539. */
  115540. finalize(state: NodeMaterialBuildState): void;
  115541. /** @hidden */
  115542. readonly _repeatableContentAnchor: string;
  115543. /** @hidden */
  115544. _getFreeVariableName(prefix: string): string;
  115545. /** @hidden */
  115546. _getFreeDefineName(prefix: string): string;
  115547. /** @hidden */
  115548. _excludeVariableName(name: string): void;
  115549. /** @hidden */
  115550. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115551. /** @hidden */
  115552. _emitFunction(name: string, code: string, comments: string): void;
  115553. /** @hidden */
  115554. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115555. replaceStrings?: {
  115556. search: RegExp;
  115557. replace: string;
  115558. }[];
  115559. repeatKey?: string;
  115560. }): string;
  115561. /** @hidden */
  115562. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115563. repeatKey?: string;
  115564. removeAttributes?: boolean;
  115565. removeUniforms?: boolean;
  115566. removeVaryings?: boolean;
  115567. removeIfDef?: boolean;
  115568. replaceStrings?: {
  115569. search: RegExp;
  115570. replace: string;
  115571. }[];
  115572. }, storeKey?: string): void;
  115573. /** @hidden */
  115574. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115575. /** @hidden */
  115576. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115577. }
  115578. }
  115579. declare module BABYLON {
  115580. /**
  115581. * Defines a block that can be used inside a node based material
  115582. */
  115583. export class NodeMaterialBlock {
  115584. private _buildId;
  115585. private _buildTarget;
  115586. private _target;
  115587. private _isFinalMerger;
  115588. private _isInput;
  115589. /** @hidden */
  115590. _inputs: NodeMaterialConnectionPoint[];
  115591. /** @hidden */
  115592. _outputs: NodeMaterialConnectionPoint[];
  115593. /**
  115594. * Gets or sets the name of the block
  115595. */
  115596. name: string;
  115597. /**
  115598. * Gets or sets the unique id of the node
  115599. */
  115600. uniqueId: number;
  115601. /**
  115602. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115603. */
  115604. readonly isFinalMerger: boolean;
  115605. /**
  115606. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115607. */
  115608. readonly isInput: boolean;
  115609. /**
  115610. * Gets or sets the build Id
  115611. */
  115612. buildId: number;
  115613. /**
  115614. * Gets or sets the target of the block
  115615. */
  115616. target: NodeMaterialBlockTargets;
  115617. /**
  115618. * Gets the list of input points
  115619. */
  115620. readonly inputs: NodeMaterialConnectionPoint[];
  115621. /** Gets the list of output points */
  115622. readonly outputs: NodeMaterialConnectionPoint[];
  115623. /**
  115624. * Find an input by its name
  115625. * @param name defines the name of the input to look for
  115626. * @returns the input or null if not found
  115627. */
  115628. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115629. /**
  115630. * Find an output by its name
  115631. * @param name defines the name of the outputto look for
  115632. * @returns the output or null if not found
  115633. */
  115634. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115635. /**
  115636. * Creates a new NodeMaterialBlock
  115637. * @param name defines the block name
  115638. * @param target defines the target of that block (Vertex by default)
  115639. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115640. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115641. */
  115642. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115643. /**
  115644. * Initialize the block and prepare the context for build
  115645. * @param state defines the state that will be used for the build
  115646. */
  115647. initialize(state: NodeMaterialBuildState): void;
  115648. /**
  115649. * Bind data to effect. Will only be called for blocks with isBindable === true
  115650. * @param effect defines the effect to bind data to
  115651. * @param nodeMaterial defines the hosting NodeMaterial
  115652. * @param mesh defines the mesh that will be rendered
  115653. */
  115654. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115655. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115656. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115657. protected _writeFloat(value: number): string;
  115658. /**
  115659. * Gets the current class name e.g. "NodeMaterialBlock"
  115660. * @returns the class name
  115661. */
  115662. getClassName(): string;
  115663. /**
  115664. * Register a new input. Must be called inside a block constructor
  115665. * @param name defines the connection point name
  115666. * @param type defines the connection point type
  115667. * @param isOptional defines a boolean indicating that this input can be omitted
  115668. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115669. * @returns the current block
  115670. */
  115671. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115672. /**
  115673. * Register a new output. Must be called inside a block constructor
  115674. * @param name defines the connection point name
  115675. * @param type defines the connection point type
  115676. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115677. * @returns the current block
  115678. */
  115679. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115680. /**
  115681. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115682. * @param forOutput defines an optional connection point to check compatibility with
  115683. * @returns the first available input or null
  115684. */
  115685. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115686. /**
  115687. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115688. * @param forBlock defines an optional block to check compatibility with
  115689. * @returns the first available input or null
  115690. */
  115691. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115692. /**
  115693. * Connect current block with another block
  115694. * @param other defines the block to connect with
  115695. * @param options define the various options to help pick the right connections
  115696. * @returns the current block
  115697. */
  115698. connectTo(other: NodeMaterialBlock, options?: {
  115699. input?: string;
  115700. output?: string;
  115701. outputSwizzle?: string;
  115702. }): this | undefined;
  115703. protected _buildBlock(state: NodeMaterialBuildState): void;
  115704. /**
  115705. * Add uniforms, samplers and uniform buffers at compilation time
  115706. * @param state defines the state to update
  115707. * @param nodeMaterial defines the node material requesting the update
  115708. * @param defines defines the material defines to update
  115709. */
  115710. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115711. /**
  115712. * Add potential fallbacks if shader compilation fails
  115713. * @param mesh defines the mesh to be rendered
  115714. * @param fallbacks defines the current prioritized list of fallbacks
  115715. */
  115716. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115717. /**
  115718. * Update defines for shader compilation
  115719. * @param mesh defines the mesh to be rendered
  115720. * @param nodeMaterial defines the node material requesting the update
  115721. * @param defines defines the material defines to update
  115722. * @param useInstances specifies that instances should be used
  115723. */
  115724. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115725. /**
  115726. * Initialize defines for shader compilation
  115727. * @param mesh defines the mesh to be rendered
  115728. * @param nodeMaterial defines the node material requesting the update
  115729. * @param defines defines the material defines to be prepared
  115730. * @param useInstances specifies that instances should be used
  115731. */
  115732. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115733. /**
  115734. * Lets the block try to connect some inputs automatically
  115735. */
  115736. autoConfigure(): void;
  115737. /**
  115738. * Function called when a block is declared as repeatable content generator
  115739. * @param vertexShaderState defines the current compilation state for the vertex shader
  115740. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115741. * @param mesh defines the mesh to be rendered
  115742. * @param defines defines the material defines to update
  115743. */
  115744. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115745. /**
  115746. * Checks if the block is ready
  115747. * @param mesh defines the mesh to be rendered
  115748. * @param nodeMaterial defines the node material requesting the update
  115749. * @param defines defines the material defines to update
  115750. * @param useInstances specifies that instances should be used
  115751. * @returns true if the block is ready
  115752. */
  115753. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115754. private _processBuild;
  115755. /**
  115756. * Compile the current node and generate the shader code
  115757. * @param state defines the current compilation state (uniforms, samplers, current string)
  115758. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115759. * @returns true if already built
  115760. */
  115761. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115762. /**
  115763. * Serializes this block in a JSON representation
  115764. * @returns the serialized block object
  115765. */
  115766. serialize(): any;
  115767. /** @hidden */
  115768. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115769. }
  115770. }
  115771. declare module BABYLON {
  115772. /**
  115773. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115774. */
  115775. export enum NodeMaterialBlockConnectionPointMode {
  115776. /** Value is an uniform */
  115777. Uniform = 0,
  115778. /** Value is a mesh attribute */
  115779. Attribute = 1,
  115780. /** Value is a varying between vertex and fragment shaders */
  115781. Varying = 2,
  115782. /** Mode is undefined */
  115783. Undefined = 3
  115784. }
  115785. }
  115786. declare module BABYLON {
  115787. /**
  115788. * Enum used to define well known values e.g. values automatically provided by the system
  115789. */
  115790. export enum NodeMaterialWellKnownValues {
  115791. /** World */
  115792. World = 1,
  115793. /** View */
  115794. View = 2,
  115795. /** Projection */
  115796. Projection = 3,
  115797. /** ViewProjection */
  115798. ViewProjection = 4,
  115799. /** WorldView */
  115800. WorldView = 5,
  115801. /** WorldViewProjection */
  115802. WorldViewProjection = 6,
  115803. /** CameraPosition */
  115804. CameraPosition = 7,
  115805. /** Fog Color */
  115806. FogColor = 8
  115807. }
  115808. }
  115809. declare module BABYLON {
  115810. /**
  115811. * Contains position and normal vectors for a vertex
  115812. */
  115813. export class PositionNormalVertex {
  115814. /** the position of the vertex (defaut: 0,0,0) */
  115815. position: Vector3;
  115816. /** the normal of the vertex (defaut: 0,1,0) */
  115817. normal: Vector3;
  115818. /**
  115819. * Creates a PositionNormalVertex
  115820. * @param position the position of the vertex (defaut: 0,0,0)
  115821. * @param normal the normal of the vertex (defaut: 0,1,0)
  115822. */
  115823. constructor(
  115824. /** the position of the vertex (defaut: 0,0,0) */
  115825. position?: Vector3,
  115826. /** the normal of the vertex (defaut: 0,1,0) */
  115827. normal?: Vector3);
  115828. /**
  115829. * Clones the PositionNormalVertex
  115830. * @returns the cloned PositionNormalVertex
  115831. */
  115832. clone(): PositionNormalVertex;
  115833. }
  115834. /**
  115835. * Contains position, normal and uv vectors for a vertex
  115836. */
  115837. export class PositionNormalTextureVertex {
  115838. /** the position of the vertex (defaut: 0,0,0) */
  115839. position: Vector3;
  115840. /** the normal of the vertex (defaut: 0,1,0) */
  115841. normal: Vector3;
  115842. /** the uv of the vertex (default: 0,0) */
  115843. uv: Vector2;
  115844. /**
  115845. * Creates a PositionNormalTextureVertex
  115846. * @param position the position of the vertex (defaut: 0,0,0)
  115847. * @param normal the normal of the vertex (defaut: 0,1,0)
  115848. * @param uv the uv of the vertex (default: 0,0)
  115849. */
  115850. constructor(
  115851. /** the position of the vertex (defaut: 0,0,0) */
  115852. position?: Vector3,
  115853. /** the normal of the vertex (defaut: 0,1,0) */
  115854. normal?: Vector3,
  115855. /** the uv of the vertex (default: 0,0) */
  115856. uv?: Vector2);
  115857. /**
  115858. * Clones the PositionNormalTextureVertex
  115859. * @returns the cloned PositionNormalTextureVertex
  115860. */
  115861. clone(): PositionNormalTextureVertex;
  115862. }
  115863. }
  115864. declare module BABYLON {
  115865. /**
  115866. * Block used to expose an input value
  115867. */
  115868. export class InputBlock extends NodeMaterialBlock {
  115869. private _mode;
  115870. private _associatedVariableName;
  115871. private _storedValue;
  115872. private _valueCallback;
  115873. private _type;
  115874. /** @hidden */
  115875. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115876. /**
  115877. * Gets or sets the connection point type (default is float)
  115878. */
  115879. readonly type: NodeMaterialBlockConnectionPointTypes;
  115880. /**
  115881. * Creates a new InputBlock
  115882. * @param name defines the block name
  115883. * @param target defines the target of that block (Vertex by default)
  115884. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  115885. */
  115886. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  115887. /**
  115888. * Gets the output component
  115889. */
  115890. readonly output: NodeMaterialConnectionPoint;
  115891. /**
  115892. * Set the source of this connection point to a vertex attribute
  115893. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  115894. * @returns the current connection point
  115895. */
  115896. setAsAttribute(attributeName?: string): InputBlock;
  115897. /**
  115898. * Set the source of this connection point to a well known value
  115899. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  115900. * @returns the current connection point
  115901. */
  115902. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  115903. /**
  115904. * Gets or sets the value of that point.
  115905. * Please note that this value will be ignored if valueCallback is defined
  115906. */
  115907. value: any;
  115908. /**
  115909. * Gets or sets a callback used to get the value of that point.
  115910. * Please note that setting this value will force the connection point to ignore the value property
  115911. */
  115912. valueCallback: () => any;
  115913. /**
  115914. * Gets or sets the associated variable name in the shader
  115915. */
  115916. associatedVariableName: string;
  115917. /**
  115918. * Gets a boolean indicating that this connection point not defined yet
  115919. */
  115920. readonly isUndefined: boolean;
  115921. /**
  115922. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  115923. * In this case the connection point name must be the name of the uniform to use.
  115924. * Can only be set on inputs
  115925. */
  115926. isUniform: boolean;
  115927. /**
  115928. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  115929. * In this case the connection point name must be the name of the attribute to use
  115930. * Can only be set on inputs
  115931. */
  115932. isAttribute: boolean;
  115933. /**
  115934. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  115935. * Can only be set on exit points
  115936. */
  115937. isVarying: boolean;
  115938. /**
  115939. * Gets a boolean indicating that the current connection point is a well known value
  115940. */
  115941. readonly isWellKnownValue: boolean;
  115942. /**
  115943. * Gets or sets the current well known value or null if not defined as well know value
  115944. */
  115945. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115946. /**
  115947. * Gets the current class name
  115948. * @returns the class name
  115949. */
  115950. getClassName(): string;
  115951. private _emitDefine;
  115952. /**
  115953. * Set the input block to its default value (based on its type)
  115954. */
  115955. setDefaultValue(): void;
  115956. private _emit;
  115957. /** @hidden */
  115958. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  115959. /** @hidden */
  115960. _transmit(effect: Effect, scene: Scene): void;
  115961. protected _buildBlock(state: NodeMaterialBuildState): void;
  115962. serialize(): any;
  115963. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115964. }
  115965. }
  115966. declare module BABYLON {
  115967. /**
  115968. * Defines a connection point for a block
  115969. */
  115970. export class NodeMaterialConnectionPoint {
  115971. /** @hidden */
  115972. _ownerBlock: NodeMaterialBlock;
  115973. /** @hidden */
  115974. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115975. private _endpoints;
  115976. private _associatedVariableName;
  115977. /** @hidden */
  115978. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  115979. private _type;
  115980. /** @hidden */
  115981. _enforceAssociatedVariableName: boolean;
  115982. /**
  115983. * Gets or sets the associated variable name in the shader
  115984. */
  115985. associatedVariableName: string;
  115986. /**
  115987. * Gets or sets the connection point type (default is float)
  115988. */
  115989. type: NodeMaterialBlockConnectionPointTypes;
  115990. /**
  115991. * Gets or sets the connection point name
  115992. */
  115993. name: string;
  115994. /**
  115995. * Gets or sets the swizzle to apply to this connection point when reading or writing
  115996. */
  115997. swizzle: string;
  115998. /**
  115999. * Gets or sets a boolean indicating that this connection point can be omitted
  116000. */
  116001. isOptional: boolean;
  116002. /**
  116003. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  116004. */
  116005. define: string;
  116006. /** Gets or sets the target of that connection point */
  116007. target: NodeMaterialBlockTargets;
  116008. /**
  116009. * Gets a boolean indicating that the current point is connected
  116010. */
  116011. readonly isConnected: boolean;
  116012. /**
  116013. * Gets a boolean indicating that the current point is connected to an input block
  116014. */
  116015. readonly isConnectedToInput: boolean;
  116016. /**
  116017. * Gets a the connected input block (if any)
  116018. */
  116019. readonly connectInputBlock: Nullable<InputBlock>;
  116020. /** Get the other side of the connection (if any) */
  116021. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  116022. /** Get the block that owns this connection point */
  116023. readonly ownerBlock: NodeMaterialBlock;
  116024. /** Get the block connected on the other side of this connection (if any) */
  116025. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  116026. /** Get the block connected on the endpoints of this connection (if any) */
  116027. readonly connectedBlocks: Array<NodeMaterialBlock>;
  116028. /** Gets the list of connected endpoints */
  116029. readonly endpoints: NodeMaterialConnectionPoint[];
  116030. /**
  116031. * Creates a new connection point
  116032. * @param name defines the connection point name
  116033. * @param ownerBlock defines the block hosting this connection point
  116034. */
  116035. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116036. /**
  116037. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116038. * @returns the class name
  116039. */
  116040. getClassName(): string;
  116041. /**
  116042. * Gets an boolean indicating if the current point can be connected to another point
  116043. * @param connectionPoint defines the other connection point
  116044. * @returns true if the connection is possible
  116045. */
  116046. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116047. /**
  116048. * Connect this point to another connection point
  116049. * @param connectionPoint defines the other connection point
  116050. * @returns the current connection point
  116051. */
  116052. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116053. /**
  116054. * Disconnect this point from one of his endpoint
  116055. * @param endpoint defines the other connection point
  116056. * @returns the current connection point
  116057. */
  116058. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116059. /**
  116060. * Serializes this point in a JSON representation
  116061. * @returns the serialized point object
  116062. */
  116063. serialize(): any;
  116064. private static _GetTypeLength;
  116065. }
  116066. }
  116067. declare module BABYLON {
  116068. /**
  116069. * Block used to add support for vertex skinning (bones)
  116070. */
  116071. export class BonesBlock extends NodeMaterialBlock {
  116072. /**
  116073. * Creates a new BonesBlock
  116074. * @param name defines the block name
  116075. */
  116076. constructor(name: string);
  116077. /**
  116078. * Initialize the block and prepare the context for build
  116079. * @param state defines the state that will be used for the build
  116080. */
  116081. initialize(state: NodeMaterialBuildState): void;
  116082. /**
  116083. * Gets the current class name
  116084. * @returns the class name
  116085. */
  116086. getClassName(): string;
  116087. /**
  116088. * Gets the matrix indices input component
  116089. */
  116090. readonly matricesIndices: NodeMaterialConnectionPoint;
  116091. /**
  116092. * Gets the matrix weights input component
  116093. */
  116094. readonly matricesWeights: NodeMaterialConnectionPoint;
  116095. /**
  116096. * Gets the extra matrix indices input component
  116097. */
  116098. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116099. /**
  116100. * Gets the extra matrix weights input component
  116101. */
  116102. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116103. /**
  116104. * Gets the world input component
  116105. */
  116106. readonly world: NodeMaterialConnectionPoint;
  116107. /**
  116108. * Gets the output component
  116109. */
  116110. readonly output: NodeMaterialConnectionPoint;
  116111. autoConfigure(): void;
  116112. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116113. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116115. protected _buildBlock(state: NodeMaterialBuildState): this;
  116116. }
  116117. }
  116118. declare module BABYLON {
  116119. /**
  116120. * Block used to add support for instances
  116121. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116122. */
  116123. export class InstancesBlock extends NodeMaterialBlock {
  116124. /**
  116125. * Creates a new InstancesBlock
  116126. * @param name defines the block name
  116127. */
  116128. constructor(name: string);
  116129. /**
  116130. * Gets the current class name
  116131. * @returns the class name
  116132. */
  116133. getClassName(): string;
  116134. /**
  116135. * Gets the first world row input component
  116136. */
  116137. readonly world0: NodeMaterialConnectionPoint;
  116138. /**
  116139. * Gets the second world row input component
  116140. */
  116141. readonly world1: NodeMaterialConnectionPoint;
  116142. /**
  116143. * Gets the third world row input component
  116144. */
  116145. readonly world2: NodeMaterialConnectionPoint;
  116146. /**
  116147. * Gets the forth world row input component
  116148. */
  116149. readonly world3: NodeMaterialConnectionPoint;
  116150. /**
  116151. * Gets the world input component
  116152. */
  116153. readonly world: NodeMaterialConnectionPoint;
  116154. /**
  116155. * Gets the output component
  116156. */
  116157. readonly output: NodeMaterialConnectionPoint;
  116158. autoConfigure(): void;
  116159. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116160. protected _buildBlock(state: NodeMaterialBuildState): this;
  116161. }
  116162. }
  116163. declare module BABYLON {
  116164. /**
  116165. * Block used to add morph targets support to vertex shader
  116166. */
  116167. export class MorphTargetsBlock extends NodeMaterialBlock {
  116168. private _repeatableContentAnchor;
  116169. private _repeatebleContentGenerated;
  116170. /**
  116171. * Create a new MorphTargetsBlock
  116172. * @param name defines the block name
  116173. */
  116174. constructor(name: string);
  116175. /**
  116176. * Gets the current class name
  116177. * @returns the class name
  116178. */
  116179. getClassName(): string;
  116180. /**
  116181. * Gets the position input component
  116182. */
  116183. readonly position: NodeMaterialConnectionPoint;
  116184. /**
  116185. * Gets the normal input component
  116186. */
  116187. readonly normal: NodeMaterialConnectionPoint;
  116188. /**
  116189. * Gets the tangent input component
  116190. */
  116191. readonly tangent: NodeMaterialConnectionPoint;
  116192. /**
  116193. * Gets the tangent input component
  116194. */
  116195. readonly uv: NodeMaterialConnectionPoint;
  116196. /**
  116197. * Gets the position output component
  116198. */
  116199. readonly positionOutput: NodeMaterialConnectionPoint;
  116200. /**
  116201. * Gets the normal output component
  116202. */
  116203. readonly normalOutput: NodeMaterialConnectionPoint;
  116204. /**
  116205. * Gets the tangent output component
  116206. */
  116207. readonly tangentOutput: NodeMaterialConnectionPoint;
  116208. /**
  116209. * Gets the tangent output component
  116210. */
  116211. readonly uvOutput: NodeMaterialConnectionPoint;
  116212. initialize(state: NodeMaterialBuildState): void;
  116213. autoConfigure(): void;
  116214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116216. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116217. protected _buildBlock(state: NodeMaterialBuildState): this;
  116218. }
  116219. }
  116220. declare module BABYLON {
  116221. /**
  116222. * Block used to add an alpha test in the fragment shader
  116223. */
  116224. export class AlphaTestBlock extends NodeMaterialBlock {
  116225. /**
  116226. * Gets or sets the alpha value where alpha testing happens
  116227. */
  116228. alphaCutOff: number;
  116229. /**
  116230. * Create a new AlphaTestBlock
  116231. * @param name defines the block name
  116232. */
  116233. constructor(name: string);
  116234. /**
  116235. * Gets the current class name
  116236. * @returns the class name
  116237. */
  116238. getClassName(): string;
  116239. /**
  116240. * Gets the color input component
  116241. */
  116242. readonly color: NodeMaterialConnectionPoint;
  116243. protected _buildBlock(state: NodeMaterialBuildState): this;
  116244. }
  116245. }
  116246. declare module BABYLON {
  116247. /**
  116248. * Block used to create a Color3/4 out of individual inputs (one for each component)
  116249. */
  116250. export class ColorMergerBlock extends NodeMaterialBlock {
  116251. /**
  116252. * Create a new ColorMergerBlock
  116253. * @param name defines the block name
  116254. */
  116255. constructor(name: string);
  116256. /**
  116257. * Gets the current class name
  116258. * @returns the class name
  116259. */
  116260. getClassName(): string;
  116261. /**
  116262. * Gets the r component input
  116263. */
  116264. readonly r: NodeMaterialConnectionPoint;
  116265. /**
  116266. * Gets the g component input
  116267. */
  116268. readonly g: NodeMaterialConnectionPoint;
  116269. /**
  116270. * Gets the b component input
  116271. */
  116272. readonly b: NodeMaterialConnectionPoint;
  116273. /**
  116274. * Gets the a component input
  116275. */
  116276. readonly a: NodeMaterialConnectionPoint;
  116277. protected _buildBlock(state: NodeMaterialBuildState): this;
  116278. }
  116279. }
  116280. declare module BABYLON {
  116281. /**
  116282. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  116283. */
  116284. export class VectorMergerBlock extends NodeMaterialBlock {
  116285. /**
  116286. * Create a new VectorMergerBlock
  116287. * @param name defines the block name
  116288. */
  116289. constructor(name: string);
  116290. /**
  116291. * Gets the current class name
  116292. * @returns the class name
  116293. */
  116294. getClassName(): string;
  116295. /**
  116296. * Gets the x component input
  116297. */
  116298. readonly x: NodeMaterialConnectionPoint;
  116299. /**
  116300. * Gets the y component input
  116301. */
  116302. readonly y: NodeMaterialConnectionPoint;
  116303. /**
  116304. * Gets the z component input
  116305. */
  116306. readonly z: NodeMaterialConnectionPoint;
  116307. /**
  116308. * Gets the w component input
  116309. */
  116310. readonly w: NodeMaterialConnectionPoint;
  116311. protected _buildBlock(state: NodeMaterialBuildState): this;
  116312. }
  116313. }
  116314. declare module BABYLON {
  116315. /**
  116316. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  116317. */
  116318. export class ColorSplitterBlock extends NodeMaterialBlock {
  116319. /**
  116320. * Create a new ColorSplitterBlock
  116321. * @param name defines the block name
  116322. */
  116323. constructor(name: string);
  116324. /**
  116325. * Gets the current class name
  116326. * @returns the class name
  116327. */
  116328. getClassName(): string;
  116329. /**
  116330. * Gets the rgba input component
  116331. */
  116332. readonly rgba: NodeMaterialConnectionPoint;
  116333. /**
  116334. * Gets the rgb input component
  116335. */
  116336. readonly rgb: NodeMaterialConnectionPoint;
  116337. protected _buildBlock(state: NodeMaterialBuildState): this;
  116338. }
  116339. }
  116340. declare module BABYLON {
  116341. /**
  116342. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  116343. */
  116344. export class VectorSplitterBlock extends NodeMaterialBlock {
  116345. /**
  116346. * Create a new VectorSplitterBlock
  116347. * @param name defines the block name
  116348. */
  116349. constructor(name: string);
  116350. /**
  116351. * Gets the current class name
  116352. * @returns the class name
  116353. */
  116354. getClassName(): string;
  116355. /**
  116356. * Gets the rgba input component
  116357. */
  116358. readonly xyzw: NodeMaterialConnectionPoint;
  116359. /**
  116360. * Gets the rgb input component
  116361. */
  116362. readonly xyz: NodeMaterialConnectionPoint;
  116363. protected _buildBlock(state: NodeMaterialBuildState): this;
  116364. }
  116365. }
  116366. declare module BABYLON {
  116367. /**
  116368. * Block used to add image processing support to fragment shader
  116369. */
  116370. export class ImageProcessingBlock extends NodeMaterialBlock {
  116371. /**
  116372. * Create a new ImageProcessingBlock
  116373. * @param name defines the block name
  116374. */
  116375. constructor(name: string);
  116376. /**
  116377. * Gets the current class name
  116378. * @returns the class name
  116379. */
  116380. getClassName(): string;
  116381. /**
  116382. * Gets the color input component
  116383. */
  116384. readonly color: NodeMaterialConnectionPoint;
  116385. /**
  116386. * Gets the output component
  116387. */
  116388. readonly output: NodeMaterialConnectionPoint;
  116389. /**
  116390. * Initialize the block and prepare the context for build
  116391. * @param state defines the state that will be used for the build
  116392. */
  116393. initialize(state: NodeMaterialBuildState): void;
  116394. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116396. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116397. protected _buildBlock(state: NodeMaterialBuildState): this;
  116398. }
  116399. }
  116400. declare module BABYLON {
  116401. /**
  116402. * Block used to add support for scene fog
  116403. */
  116404. export class FogBlock extends NodeMaterialBlock {
  116405. private _fogDistanceName;
  116406. private _fogParameters;
  116407. /**
  116408. * Create a new FogBlock
  116409. * @param name defines the block name
  116410. */
  116411. constructor(name: string);
  116412. /**
  116413. * Gets the current class name
  116414. * @returns the class name
  116415. */
  116416. getClassName(): string;
  116417. /**
  116418. * Gets the world position input component
  116419. */
  116420. readonly worldPosition: NodeMaterialConnectionPoint;
  116421. /**
  116422. * Gets the view input component
  116423. */
  116424. readonly view: NodeMaterialConnectionPoint;
  116425. /**
  116426. * Gets the color input component
  116427. */
  116428. readonly color: NodeMaterialConnectionPoint;
  116429. /**
  116430. * Gets the fog color input component
  116431. */
  116432. readonly fogColor: NodeMaterialConnectionPoint;
  116433. /**
  116434. * Gets the output component
  116435. */
  116436. readonly output: NodeMaterialConnectionPoint;
  116437. autoConfigure(): void;
  116438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116439. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116440. protected _buildBlock(state: NodeMaterialBuildState): this;
  116441. }
  116442. }
  116443. declare module BABYLON {
  116444. /**
  116445. * Block used to add light in the fragment shader
  116446. */
  116447. export class LightBlock extends NodeMaterialBlock {
  116448. private _lightId;
  116449. /**
  116450. * Gets or sets the light associated with this block
  116451. */
  116452. light: Nullable<Light>;
  116453. /**
  116454. * Create a new LightBlock
  116455. * @param name defines the block name
  116456. */
  116457. constructor(name: string);
  116458. /**
  116459. * Gets the current class name
  116460. * @returns the class name
  116461. */
  116462. getClassName(): string;
  116463. /**
  116464. * Gets the world position input component
  116465. */
  116466. readonly worldPosition: NodeMaterialConnectionPoint;
  116467. /**
  116468. * Gets the world normal input component
  116469. */
  116470. readonly worldNormal: NodeMaterialConnectionPoint;
  116471. /**
  116472. * Gets the camera (or eye) position component
  116473. */
  116474. readonly cameraPosition: NodeMaterialConnectionPoint;
  116475. /**
  116476. * Gets the diffuse output component
  116477. */
  116478. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116479. /**
  116480. * Gets the specular output component
  116481. */
  116482. readonly specularOutput: NodeMaterialConnectionPoint;
  116483. autoConfigure(): void;
  116484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116485. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116486. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116487. private _injectVertexCode;
  116488. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116489. serialize(): any;
  116490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116491. }
  116492. }
  116493. declare module BABYLON {
  116494. /**
  116495. * Block used to multiply 2 values
  116496. */
  116497. export class MultiplyBlock extends NodeMaterialBlock {
  116498. /**
  116499. * Creates a new MultiplyBlock
  116500. * @param name defines the block name
  116501. */
  116502. constructor(name: string);
  116503. /**
  116504. * Gets the current class name
  116505. * @returns the class name
  116506. */
  116507. getClassName(): string;
  116508. /**
  116509. * Gets the left operand input component
  116510. */
  116511. readonly left: NodeMaterialConnectionPoint;
  116512. /**
  116513. * Gets the right operand input component
  116514. */
  116515. readonly right: NodeMaterialConnectionPoint;
  116516. /**
  116517. * Gets the output component
  116518. */
  116519. readonly output: NodeMaterialConnectionPoint;
  116520. protected _buildBlock(state: NodeMaterialBuildState): this;
  116521. }
  116522. }
  116523. declare module BABYLON {
  116524. /**
  116525. * Block used to add 2 vectors
  116526. */
  116527. export class AddBlock extends NodeMaterialBlock {
  116528. /**
  116529. * Creates a new AddBlock
  116530. * @param name defines the block name
  116531. */
  116532. constructor(name: string);
  116533. /**
  116534. * Gets the current class name
  116535. * @returns the class name
  116536. */
  116537. getClassName(): string;
  116538. /**
  116539. * Gets the left operand input component
  116540. */
  116541. readonly left: NodeMaterialConnectionPoint;
  116542. /**
  116543. * Gets the right operand input component
  116544. */
  116545. readonly right: NodeMaterialConnectionPoint;
  116546. /**
  116547. * Gets the output component
  116548. */
  116549. readonly output: NodeMaterialConnectionPoint;
  116550. protected _buildBlock(state: NodeMaterialBuildState): this;
  116551. }
  116552. }
  116553. declare module BABYLON {
  116554. /**
  116555. * Block used to clamp a float
  116556. */
  116557. export class ClampBlock extends NodeMaterialBlock {
  116558. /** Gets or sets the minimum range */
  116559. minimum: number;
  116560. /** Gets or sets the maximum range */
  116561. maximum: number;
  116562. /**
  116563. * Creates a new ClampBlock
  116564. * @param name defines the block name
  116565. */
  116566. constructor(name: string);
  116567. /**
  116568. * Gets the current class name
  116569. * @returns the class name
  116570. */
  116571. getClassName(): string;
  116572. /**
  116573. * Gets the value input component
  116574. */
  116575. readonly value: NodeMaterialConnectionPoint;
  116576. /**
  116577. * Gets the output component
  116578. */
  116579. readonly output: NodeMaterialConnectionPoint;
  116580. protected _buildBlock(state: NodeMaterialBuildState): this;
  116581. }
  116582. }
  116583. declare module BABYLON {
  116584. /**
  116585. * Block used to apply a cross product between 2 vectors
  116586. */
  116587. export class CrossBlock extends NodeMaterialBlock {
  116588. /**
  116589. * Creates a new CrossBlock
  116590. * @param name defines the block name
  116591. */
  116592. constructor(name: string);
  116593. /**
  116594. * Gets the current class name
  116595. * @returns the class name
  116596. */
  116597. getClassName(): string;
  116598. /**
  116599. * Gets the left operand input component
  116600. */
  116601. readonly left: NodeMaterialConnectionPoint;
  116602. /**
  116603. * Gets the right operand input component
  116604. */
  116605. readonly right: NodeMaterialConnectionPoint;
  116606. /**
  116607. * Gets the output component
  116608. */
  116609. readonly output: NodeMaterialConnectionPoint;
  116610. protected _buildBlock(state: NodeMaterialBuildState): this;
  116611. }
  116612. }
  116613. declare module BABYLON {
  116614. /**
  116615. * Block used to apply a dot product between 2 vectors
  116616. */
  116617. export class DotBlock extends NodeMaterialBlock {
  116618. /**
  116619. * Creates a new DotBlock
  116620. * @param name defines the block name
  116621. */
  116622. constructor(name: string);
  116623. /**
  116624. * Gets the current class name
  116625. * @returns the class name
  116626. */
  116627. getClassName(): string;
  116628. /**
  116629. * Gets the left operand input component
  116630. */
  116631. readonly left: NodeMaterialConnectionPoint;
  116632. /**
  116633. * Gets the right operand input component
  116634. */
  116635. readonly right: NodeMaterialConnectionPoint;
  116636. /**
  116637. * Gets the output component
  116638. */
  116639. readonly output: NodeMaterialConnectionPoint;
  116640. protected _buildBlock(state: NodeMaterialBuildState): this;
  116641. }
  116642. }
  116643. declare module BABYLON {
  116644. /**
  116645. * Effect Render Options
  116646. */
  116647. export interface IEffectRendererOptions {
  116648. /**
  116649. * Defines the vertices positions.
  116650. */
  116651. positions?: number[];
  116652. /**
  116653. * Defines the indices.
  116654. */
  116655. indices?: number[];
  116656. }
  116657. /**
  116658. * Helper class to render one or more effects
  116659. */
  116660. export class EffectRenderer {
  116661. private engine;
  116662. private static _DefaultOptions;
  116663. private _vertexBuffers;
  116664. private _indexBuffer;
  116665. private _ringBufferIndex;
  116666. private _ringScreenBuffer;
  116667. private _fullscreenViewport;
  116668. private _getNextFrameBuffer;
  116669. /**
  116670. * Creates an effect renderer
  116671. * @param engine the engine to use for rendering
  116672. * @param options defines the options of the effect renderer
  116673. */
  116674. constructor(engine: Engine, options?: IEffectRendererOptions);
  116675. /**
  116676. * Sets the current viewport in normalized coordinates 0-1
  116677. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  116678. */
  116679. setViewport(viewport?: Viewport): void;
  116680. /**
  116681. * Sets the current effect wrapper to use during draw.
  116682. * The effect needs to be ready before calling this api.
  116683. * This also sets the default full screen position attribute.
  116684. * @param effectWrapper Defines the effect to draw with
  116685. */
  116686. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  116687. /**
  116688. * Draws a full screen quad.
  116689. */
  116690. draw(): void;
  116691. /**
  116692. * renders one or more effects to a specified texture
  116693. * @param effectWrappers list of effects to renderer
  116694. * @param outputTexture texture to draw to, if null it will render to the screen
  116695. */
  116696. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  116697. /**
  116698. * Disposes of the effect renderer
  116699. */
  116700. dispose(): void;
  116701. }
  116702. /**
  116703. * Options to create an EffectWrapper
  116704. */
  116705. interface EffectWrapperCreationOptions {
  116706. /**
  116707. * Engine to use to create the effect
  116708. */
  116709. engine: Engine;
  116710. /**
  116711. * Fragment shader for the effect
  116712. */
  116713. fragmentShader: string;
  116714. /**
  116715. * Vertex shader for the effect
  116716. */
  116717. vertexShader: string;
  116718. /**
  116719. * Attributes to use in the shader
  116720. */
  116721. attributeNames?: Array<string>;
  116722. /**
  116723. * Uniforms to use in the shader
  116724. */
  116725. uniformNames?: Array<string>;
  116726. /**
  116727. * Texture sampler names to use in the shader
  116728. */
  116729. samplerNames?: Array<string>;
  116730. /**
  116731. * The friendly name of the effect displayed in Spector.
  116732. */
  116733. name?: string;
  116734. }
  116735. /**
  116736. * Wraps an effect to be used for rendering
  116737. */
  116738. export class EffectWrapper {
  116739. /**
  116740. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  116741. */
  116742. onApplyObservable: Observable<{}>;
  116743. /**
  116744. * The underlying effect
  116745. */
  116746. effect: Effect;
  116747. /**
  116748. * Creates an effect to be renderer
  116749. * @param creationOptions options to create the effect
  116750. */
  116751. constructor(creationOptions: EffectWrapperCreationOptions);
  116752. /**
  116753. * Disposes of the effect wrapper
  116754. */
  116755. dispose(): void;
  116756. }
  116757. }
  116758. declare module BABYLON {
  116759. /**
  116760. * Helper class to push actions to a pool of workers.
  116761. */
  116762. export class WorkerPool implements IDisposable {
  116763. private _workerInfos;
  116764. private _pendingActions;
  116765. /**
  116766. * Constructor
  116767. * @param workers Array of workers to use for actions
  116768. */
  116769. constructor(workers: Array<Worker>);
  116770. /**
  116771. * Terminates all workers and clears any pending actions.
  116772. */
  116773. dispose(): void;
  116774. /**
  116775. * Pushes an action to the worker pool. If all the workers are active, the action will be
  116776. * pended until a worker has completed its action.
  116777. * @param action The action to perform. Call onComplete when the action is complete.
  116778. */
  116779. push(action: (worker: Worker, onComplete: () => void) => void): void;
  116780. private _execute;
  116781. }
  116782. }
  116783. declare module BABYLON {
  116784. /**
  116785. * Configuration for Draco compression
  116786. */
  116787. export interface IDracoCompressionConfiguration {
  116788. /**
  116789. * Configuration for the decoder.
  116790. */
  116791. decoder: {
  116792. /**
  116793. * The url to the WebAssembly module.
  116794. */
  116795. wasmUrl?: string;
  116796. /**
  116797. * The url to the WebAssembly binary.
  116798. */
  116799. wasmBinaryUrl?: string;
  116800. /**
  116801. * The url to the fallback JavaScript module.
  116802. */
  116803. fallbackUrl?: string;
  116804. };
  116805. }
  116806. /**
  116807. * Draco compression (https://google.github.io/draco/)
  116808. *
  116809. * This class wraps the Draco module.
  116810. *
  116811. * **Encoder**
  116812. *
  116813. * The encoder is not currently implemented.
  116814. *
  116815. * **Decoder**
  116816. *
  116817. * 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.
  116818. *
  116819. * To update the configuration, use the following code:
  116820. * ```javascript
  116821. * DracoCompression.Configuration = {
  116822. * decoder: {
  116823. * wasmUrl: "<url to the WebAssembly library>",
  116824. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  116825. * fallbackUrl: "<url to the fallback JavaScript library>",
  116826. * }
  116827. * };
  116828. * ```
  116829. *
  116830. * 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.
  116831. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  116832. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  116833. *
  116834. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  116835. * ```javascript
  116836. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  116837. * ```
  116838. *
  116839. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  116840. */
  116841. export class DracoCompression implements IDisposable {
  116842. private _workerPoolPromise?;
  116843. private _decoderModulePromise?;
  116844. /**
  116845. * The configuration. Defaults to the following urls:
  116846. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  116847. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  116848. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  116849. */
  116850. static Configuration: IDracoCompressionConfiguration;
  116851. /**
  116852. * Returns true if the decoder configuration is available.
  116853. */
  116854. static readonly DecoderAvailable: boolean;
  116855. /**
  116856. * Default number of workers to create when creating the draco compression object.
  116857. */
  116858. static DefaultNumWorkers: number;
  116859. private static GetDefaultNumWorkers;
  116860. private static _Default;
  116861. /**
  116862. * Default instance for the draco compression object.
  116863. */
  116864. static readonly Default: DracoCompression;
  116865. /**
  116866. * Constructor
  116867. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  116868. */
  116869. constructor(numWorkers?: number);
  116870. /**
  116871. * Stop all async operations and release resources.
  116872. */
  116873. dispose(): void;
  116874. /**
  116875. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  116876. * @returns a promise that resolves when ready
  116877. */
  116878. whenReadyAsync(): Promise<void>;
  116879. /**
  116880. * Decode Draco compressed mesh data to vertex data.
  116881. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  116882. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  116883. * @returns A promise that resolves with the decoded vertex data
  116884. */
  116885. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  116886. [kind: string]: number;
  116887. }): Promise<VertexData>;
  116888. }
  116889. }
  116890. declare module BABYLON {
  116891. /**
  116892. * Class for building Constructive Solid Geometry
  116893. */
  116894. export class CSG {
  116895. private polygons;
  116896. /**
  116897. * The world matrix
  116898. */
  116899. matrix: Matrix;
  116900. /**
  116901. * Stores the position
  116902. */
  116903. position: Vector3;
  116904. /**
  116905. * Stores the rotation
  116906. */
  116907. rotation: Vector3;
  116908. /**
  116909. * Stores the rotation quaternion
  116910. */
  116911. rotationQuaternion: Nullable<Quaternion>;
  116912. /**
  116913. * Stores the scaling vector
  116914. */
  116915. scaling: Vector3;
  116916. /**
  116917. * Convert the Mesh to CSG
  116918. * @param mesh The Mesh to convert to CSG
  116919. * @returns A new CSG from the Mesh
  116920. */
  116921. static FromMesh(mesh: Mesh): CSG;
  116922. /**
  116923. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  116924. * @param polygons Polygons used to construct a CSG solid
  116925. */
  116926. private static FromPolygons;
  116927. /**
  116928. * Clones, or makes a deep copy, of the CSG
  116929. * @returns A new CSG
  116930. */
  116931. clone(): CSG;
  116932. /**
  116933. * Unions this CSG with another CSG
  116934. * @param csg The CSG to union against this CSG
  116935. * @returns The unioned CSG
  116936. */
  116937. union(csg: CSG): CSG;
  116938. /**
  116939. * Unions this CSG with another CSG in place
  116940. * @param csg The CSG to union against this CSG
  116941. */
  116942. unionInPlace(csg: CSG): void;
  116943. /**
  116944. * Subtracts this CSG with another CSG
  116945. * @param csg The CSG to subtract against this CSG
  116946. * @returns A new CSG
  116947. */
  116948. subtract(csg: CSG): CSG;
  116949. /**
  116950. * Subtracts this CSG with another CSG in place
  116951. * @param csg The CSG to subtact against this CSG
  116952. */
  116953. subtractInPlace(csg: CSG): void;
  116954. /**
  116955. * Intersect this CSG with another CSG
  116956. * @param csg The CSG to intersect against this CSG
  116957. * @returns A new CSG
  116958. */
  116959. intersect(csg: CSG): CSG;
  116960. /**
  116961. * Intersects this CSG with another CSG in place
  116962. * @param csg The CSG to intersect against this CSG
  116963. */
  116964. intersectInPlace(csg: CSG): void;
  116965. /**
  116966. * Return a new CSG solid with solid and empty space switched. This solid is
  116967. * not modified.
  116968. * @returns A new CSG solid with solid and empty space switched
  116969. */
  116970. inverse(): CSG;
  116971. /**
  116972. * Inverses the CSG in place
  116973. */
  116974. inverseInPlace(): void;
  116975. /**
  116976. * This is used to keep meshes transformations so they can be restored
  116977. * when we build back a Babylon Mesh
  116978. * NB : All CSG operations are performed in world coordinates
  116979. * @param csg The CSG to copy the transform attributes from
  116980. * @returns This CSG
  116981. */
  116982. copyTransformAttributes(csg: CSG): CSG;
  116983. /**
  116984. * Build Raw mesh from CSG
  116985. * Coordinates here are in world space
  116986. * @param name The name of the mesh geometry
  116987. * @param scene The Scene
  116988. * @param keepSubMeshes Specifies if the submeshes should be kept
  116989. * @returns A new Mesh
  116990. */
  116991. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  116992. /**
  116993. * Build Mesh from CSG taking material and transforms into account
  116994. * @param name The name of the Mesh
  116995. * @param material The material of the Mesh
  116996. * @param scene The Scene
  116997. * @param keepSubMeshes Specifies if submeshes should be kept
  116998. * @returns The new Mesh
  116999. */
  117000. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  117001. }
  117002. }
  117003. declare module BABYLON {
  117004. /**
  117005. * Class used to create a trail following a mesh
  117006. */
  117007. export class TrailMesh extends Mesh {
  117008. private _generator;
  117009. private _autoStart;
  117010. private _running;
  117011. private _diameter;
  117012. private _length;
  117013. private _sectionPolygonPointsCount;
  117014. private _sectionVectors;
  117015. private _sectionNormalVectors;
  117016. private _beforeRenderObserver;
  117017. /**
  117018. * @constructor
  117019. * @param name The value used by scene.getMeshByName() to do a lookup.
  117020. * @param generator The mesh to generate a trail.
  117021. * @param scene The scene to add this mesh to.
  117022. * @param diameter Diameter of trailing mesh. Default is 1.
  117023. * @param length Length of trailing mesh. Default is 60.
  117024. * @param autoStart Automatically start trailing mesh. Default true.
  117025. */
  117026. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  117027. /**
  117028. * "TrailMesh"
  117029. * @returns "TrailMesh"
  117030. */
  117031. getClassName(): string;
  117032. private _createMesh;
  117033. /**
  117034. * Start trailing mesh.
  117035. */
  117036. start(): void;
  117037. /**
  117038. * Stop trailing mesh.
  117039. */
  117040. stop(): void;
  117041. /**
  117042. * Update trailing mesh geometry.
  117043. */
  117044. update(): void;
  117045. /**
  117046. * Returns a new TrailMesh object.
  117047. * @param name is a string, the name given to the new mesh
  117048. * @param newGenerator use new generator object for cloned trail mesh
  117049. * @returns a new mesh
  117050. */
  117051. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117052. /**
  117053. * Serializes this trail mesh
  117054. * @param serializationObject object to write serialization to
  117055. */
  117056. serialize(serializationObject: any): void;
  117057. /**
  117058. * Parses a serialized trail mesh
  117059. * @param parsedMesh the serialized mesh
  117060. * @param scene the scene to create the trail mesh in
  117061. * @returns the created trail mesh
  117062. */
  117063. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117064. }
  117065. }
  117066. declare module BABYLON {
  117067. /**
  117068. * Class containing static functions to help procedurally build meshes
  117069. */
  117070. export class TiledBoxBuilder {
  117071. /**
  117072. * Creates a box mesh
  117073. * 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)
  117074. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117078. * @param name defines the name of the mesh
  117079. * @param options defines the options used to create the mesh
  117080. * @param scene defines the hosting scene
  117081. * @returns the box mesh
  117082. */
  117083. static CreateTiledBox(name: string, options: {
  117084. pattern?: number;
  117085. width?: number;
  117086. height?: number;
  117087. depth?: number;
  117088. tileSize?: number;
  117089. tileWidth?: number;
  117090. tileHeight?: number;
  117091. alignHorizontal?: number;
  117092. alignVertical?: number;
  117093. faceUV?: Vector4[];
  117094. faceColors?: Color4[];
  117095. sideOrientation?: number;
  117096. updatable?: boolean;
  117097. }, scene?: Nullable<Scene>): Mesh;
  117098. }
  117099. }
  117100. declare module BABYLON {
  117101. /**
  117102. * Class containing static functions to help procedurally build meshes
  117103. */
  117104. export class TorusKnotBuilder {
  117105. /**
  117106. * Creates a torus knot mesh
  117107. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117108. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117109. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117110. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117114. * @param name defines the name of the mesh
  117115. * @param options defines the options used to create the mesh
  117116. * @param scene defines the hosting scene
  117117. * @returns the torus knot mesh
  117118. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117119. */
  117120. static CreateTorusKnot(name: string, options: {
  117121. radius?: number;
  117122. tube?: number;
  117123. radialSegments?: number;
  117124. tubularSegments?: number;
  117125. p?: number;
  117126. q?: number;
  117127. updatable?: boolean;
  117128. sideOrientation?: number;
  117129. frontUVs?: Vector4;
  117130. backUVs?: Vector4;
  117131. }, scene: any): Mesh;
  117132. }
  117133. }
  117134. declare module BABYLON {
  117135. /**
  117136. * Polygon
  117137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117138. */
  117139. export class Polygon {
  117140. /**
  117141. * Creates a rectangle
  117142. * @param xmin bottom X coord
  117143. * @param ymin bottom Y coord
  117144. * @param xmax top X coord
  117145. * @param ymax top Y coord
  117146. * @returns points that make the resulting rectation
  117147. */
  117148. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117149. /**
  117150. * Creates a circle
  117151. * @param radius radius of circle
  117152. * @param cx scale in x
  117153. * @param cy scale in y
  117154. * @param numberOfSides number of sides that make up the circle
  117155. * @returns points that make the resulting circle
  117156. */
  117157. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117158. /**
  117159. * Creates a polygon from input string
  117160. * @param input Input polygon data
  117161. * @returns the parsed points
  117162. */
  117163. static Parse(input: string): Vector2[];
  117164. /**
  117165. * Starts building a polygon from x and y coordinates
  117166. * @param x x coordinate
  117167. * @param y y coordinate
  117168. * @returns the started path2
  117169. */
  117170. static StartingAt(x: number, y: number): Path2;
  117171. }
  117172. /**
  117173. * Builds a polygon
  117174. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  117175. */
  117176. export class PolygonMeshBuilder {
  117177. private _points;
  117178. private _outlinepoints;
  117179. private _holes;
  117180. private _name;
  117181. private _scene;
  117182. private _epoints;
  117183. private _eholes;
  117184. private _addToepoint;
  117185. /**
  117186. * Babylon reference to the earcut plugin.
  117187. */
  117188. bjsEarcut: any;
  117189. /**
  117190. * Creates a PolygonMeshBuilder
  117191. * @param name name of the builder
  117192. * @param contours Path of the polygon
  117193. * @param scene scene to add to when creating the mesh
  117194. * @param earcutInjection can be used to inject your own earcut reference
  117195. */
  117196. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117197. /**
  117198. * Adds a whole within the polygon
  117199. * @param hole Array of points defining the hole
  117200. * @returns this
  117201. */
  117202. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117203. /**
  117204. * Creates the polygon
  117205. * @param updatable If the mesh should be updatable
  117206. * @param depth The depth of the mesh created
  117207. * @returns the created mesh
  117208. */
  117209. build(updatable?: boolean, depth?: number): Mesh;
  117210. /**
  117211. * Creates the polygon
  117212. * @param depth The depth of the mesh created
  117213. * @returns the created VertexData
  117214. */
  117215. buildVertexData(depth?: number): VertexData;
  117216. /**
  117217. * Adds a side to the polygon
  117218. * @param positions points that make the polygon
  117219. * @param normals normals of the polygon
  117220. * @param uvs uvs of the polygon
  117221. * @param indices indices of the polygon
  117222. * @param bounds bounds of the polygon
  117223. * @param points points of the polygon
  117224. * @param depth depth of the polygon
  117225. * @param flip flip of the polygon
  117226. */
  117227. private addSide;
  117228. }
  117229. }
  117230. declare module BABYLON {
  117231. /**
  117232. * Class containing static functions to help procedurally build meshes
  117233. */
  117234. export class PolygonBuilder {
  117235. /**
  117236. * Creates a polygon mesh
  117237. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117238. * * 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
  117239. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117241. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117242. * * Remember you can only change the shape positions, not their number when updating a polygon
  117243. * @param name defines the name of the mesh
  117244. * @param options defines the options used to create the mesh
  117245. * @param scene defines the hosting scene
  117246. * @param earcutInjection can be used to inject your own earcut reference
  117247. * @returns the polygon mesh
  117248. */
  117249. static CreatePolygon(name: string, options: {
  117250. shape: Vector3[];
  117251. holes?: Vector3[][];
  117252. depth?: number;
  117253. faceUV?: Vector4[];
  117254. faceColors?: Color4[];
  117255. updatable?: boolean;
  117256. sideOrientation?: number;
  117257. frontUVs?: Vector4;
  117258. backUVs?: Vector4;
  117259. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117260. /**
  117261. * Creates an extruded polygon mesh, with depth in the Y direction.
  117262. * * 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)
  117263. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117264. * @param name defines the name of the mesh
  117265. * @param options defines the options used to create the mesh
  117266. * @param scene defines the hosting scene
  117267. * @param earcutInjection can be used to inject your own earcut reference
  117268. * @returns the polygon mesh
  117269. */
  117270. static ExtrudePolygon(name: string, options: {
  117271. shape: Vector3[];
  117272. holes?: Vector3[][];
  117273. depth?: number;
  117274. faceUV?: Vector4[];
  117275. faceColors?: Color4[];
  117276. updatable?: boolean;
  117277. sideOrientation?: number;
  117278. frontUVs?: Vector4;
  117279. backUVs?: Vector4;
  117280. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117281. }
  117282. }
  117283. declare module BABYLON {
  117284. /**
  117285. * Class containing static functions to help procedurally build meshes
  117286. */
  117287. export class LatheBuilder {
  117288. /**
  117289. * Creates lathe mesh.
  117290. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117291. * * 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
  117292. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117293. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117294. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117295. * * 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
  117296. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117297. * * 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
  117298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117299. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117302. * @param name defines the name of the mesh
  117303. * @param options defines the options used to create the mesh
  117304. * @param scene defines the hosting scene
  117305. * @returns the lathe mesh
  117306. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117307. */
  117308. static CreateLathe(name: string, options: {
  117309. shape: Vector3[];
  117310. radius?: number;
  117311. tessellation?: number;
  117312. clip?: number;
  117313. arc?: number;
  117314. closed?: boolean;
  117315. updatable?: boolean;
  117316. sideOrientation?: number;
  117317. frontUVs?: Vector4;
  117318. backUVs?: Vector4;
  117319. cap?: number;
  117320. invertUV?: boolean;
  117321. }, scene?: Nullable<Scene>): Mesh;
  117322. }
  117323. }
  117324. declare module BABYLON {
  117325. /**
  117326. * Class containing static functions to help procedurally build meshes
  117327. */
  117328. export class TiledPlaneBuilder {
  117329. /**
  117330. * Creates a tiled plane mesh
  117331. * * The parameter `pattern` will, depending on value, do nothing or
  117332. * * * flip (reflect about central vertical) alternate tiles across and up
  117333. * * * flip every tile on alternate rows
  117334. * * * rotate (180 degs) alternate tiles across and up
  117335. * * * rotate every tile on alternate rows
  117336. * * * flip and rotate alternate tiles across and up
  117337. * * * flip and rotate every tile on alternate rows
  117338. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117339. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117342. * * 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)
  117343. * * 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)
  117344. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117345. * @param name defines the name of the mesh
  117346. * @param options defines the options used to create the mesh
  117347. * @param scene defines the hosting scene
  117348. * @returns the box mesh
  117349. */
  117350. static CreateTiledPlane(name: string, options: {
  117351. pattern?: number;
  117352. tileSize?: number;
  117353. tileWidth?: number;
  117354. tileHeight?: number;
  117355. size?: number;
  117356. width?: number;
  117357. height?: number;
  117358. alignHorizontal?: number;
  117359. alignVertical?: number;
  117360. sideOrientation?: number;
  117361. frontUVs?: Vector4;
  117362. backUVs?: Vector4;
  117363. updatable?: boolean;
  117364. }, scene?: Nullable<Scene>): Mesh;
  117365. }
  117366. }
  117367. declare module BABYLON {
  117368. /**
  117369. * Class containing static functions to help procedurally build meshes
  117370. */
  117371. export class TubeBuilder {
  117372. /**
  117373. * Creates a tube mesh.
  117374. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117375. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117376. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117377. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117378. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117379. * * 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)
  117380. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117381. * * 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
  117382. * * 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
  117383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117387. * @param name defines the name of the mesh
  117388. * @param options defines the options used to create the mesh
  117389. * @param scene defines the hosting scene
  117390. * @returns the tube mesh
  117391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117392. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117393. */
  117394. static CreateTube(name: string, options: {
  117395. path: Vector3[];
  117396. radius?: number;
  117397. tessellation?: number;
  117398. radiusFunction?: {
  117399. (i: number, distance: number): number;
  117400. };
  117401. cap?: number;
  117402. arc?: number;
  117403. updatable?: boolean;
  117404. sideOrientation?: number;
  117405. frontUVs?: Vector4;
  117406. backUVs?: Vector4;
  117407. instance?: Mesh;
  117408. invertUV?: boolean;
  117409. }, scene?: Nullable<Scene>): Mesh;
  117410. }
  117411. }
  117412. declare module BABYLON {
  117413. /**
  117414. * Class containing static functions to help procedurally build meshes
  117415. */
  117416. export class IcoSphereBuilder {
  117417. /**
  117418. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117419. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117420. * * 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`)
  117421. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117422. * * 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
  117423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117426. * @param name defines the name of the mesh
  117427. * @param options defines the options used to create the mesh
  117428. * @param scene defines the hosting scene
  117429. * @returns the icosahedron mesh
  117430. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117431. */
  117432. static CreateIcoSphere(name: string, options: {
  117433. radius?: number;
  117434. radiusX?: number;
  117435. radiusY?: number;
  117436. radiusZ?: number;
  117437. flat?: boolean;
  117438. subdivisions?: number;
  117439. sideOrientation?: number;
  117440. frontUVs?: Vector4;
  117441. backUVs?: Vector4;
  117442. updatable?: boolean;
  117443. }, scene?: Nullable<Scene>): Mesh;
  117444. }
  117445. }
  117446. declare module BABYLON {
  117447. /**
  117448. * Class containing static functions to help procedurally build meshes
  117449. */
  117450. export class DecalBuilder {
  117451. /**
  117452. * Creates a decal mesh.
  117453. * 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
  117454. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117455. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117456. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117457. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117458. * @param name defines the name of the mesh
  117459. * @param sourceMesh defines the mesh where the decal must be applied
  117460. * @param options defines the options used to create the mesh
  117461. * @param scene defines the hosting scene
  117462. * @returns the decal mesh
  117463. * @see https://doc.babylonjs.com/how_to/decals
  117464. */
  117465. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117466. position?: Vector3;
  117467. normal?: Vector3;
  117468. size?: Vector3;
  117469. angle?: number;
  117470. }): Mesh;
  117471. }
  117472. }
  117473. declare module BABYLON {
  117474. /**
  117475. * Class containing static functions to help procedurally build meshes
  117476. */
  117477. export class MeshBuilder {
  117478. /**
  117479. * Creates a box mesh
  117480. * * The parameter `size` sets the size (float) of each box side (default 1)
  117481. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117482. * * 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)
  117483. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117484. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117485. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117486. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117487. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117488. * @param name defines the name of the mesh
  117489. * @param options defines the options used to create the mesh
  117490. * @param scene defines the hosting scene
  117491. * @returns the box mesh
  117492. */
  117493. static CreateBox(name: string, options: {
  117494. size?: number;
  117495. width?: number;
  117496. height?: number;
  117497. depth?: number;
  117498. faceUV?: Vector4[];
  117499. faceColors?: Color4[];
  117500. sideOrientation?: number;
  117501. frontUVs?: Vector4;
  117502. backUVs?: Vector4;
  117503. updatable?: boolean;
  117504. }, scene?: Nullable<Scene>): Mesh;
  117505. /**
  117506. * Creates a tiled box mesh
  117507. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117508. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117509. * @param name defines the name of the mesh
  117510. * @param options defines the options used to create the mesh
  117511. * @param scene defines the hosting scene
  117512. * @returns the tiled box mesh
  117513. */
  117514. static CreateTiledBox(name: string, options: {
  117515. pattern?: number;
  117516. size?: number;
  117517. width?: number;
  117518. height?: number;
  117519. depth: number;
  117520. tileSize?: number;
  117521. tileWidth?: number;
  117522. tileHeight?: number;
  117523. faceUV?: Vector4[];
  117524. faceColors?: Color4[];
  117525. alignHorizontal?: number;
  117526. alignVertical?: number;
  117527. sideOrientation?: number;
  117528. updatable?: boolean;
  117529. }, scene?: Nullable<Scene>): Mesh;
  117530. /**
  117531. * Creates a sphere mesh
  117532. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117533. * * 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`)
  117534. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117535. * * 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
  117536. * * 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)
  117537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117540. * @param name defines the name of the mesh
  117541. * @param options defines the options used to create the mesh
  117542. * @param scene defines the hosting scene
  117543. * @returns the sphere mesh
  117544. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117545. */
  117546. static CreateSphere(name: string, options: {
  117547. segments?: number;
  117548. diameter?: number;
  117549. diameterX?: number;
  117550. diameterY?: number;
  117551. diameterZ?: number;
  117552. arc?: number;
  117553. slice?: number;
  117554. sideOrientation?: number;
  117555. frontUVs?: Vector4;
  117556. backUVs?: Vector4;
  117557. updatable?: boolean;
  117558. }, scene?: Nullable<Scene>): Mesh;
  117559. /**
  117560. * Creates a plane polygonal mesh. By default, this is a disc
  117561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117562. * * 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
  117563. * * 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
  117564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117567. * @param name defines the name of the mesh
  117568. * @param options defines the options used to create the mesh
  117569. * @param scene defines the hosting scene
  117570. * @returns the plane polygonal mesh
  117571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117572. */
  117573. static CreateDisc(name: string, options: {
  117574. radius?: number;
  117575. tessellation?: number;
  117576. arc?: number;
  117577. updatable?: boolean;
  117578. sideOrientation?: number;
  117579. frontUVs?: Vector4;
  117580. backUVs?: Vector4;
  117581. }, scene?: Nullable<Scene>): Mesh;
  117582. /**
  117583. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117584. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117585. * * 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`)
  117586. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117587. * * 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
  117588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117591. * @param name defines the name of the mesh
  117592. * @param options defines the options used to create the mesh
  117593. * @param scene defines the hosting scene
  117594. * @returns the icosahedron mesh
  117595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117596. */
  117597. static CreateIcoSphere(name: string, options: {
  117598. radius?: number;
  117599. radiusX?: number;
  117600. radiusY?: number;
  117601. radiusZ?: number;
  117602. flat?: boolean;
  117603. subdivisions?: number;
  117604. sideOrientation?: number;
  117605. frontUVs?: Vector4;
  117606. backUVs?: Vector4;
  117607. updatable?: boolean;
  117608. }, scene?: Nullable<Scene>): Mesh;
  117609. /**
  117610. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117611. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117612. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117613. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117614. * * 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
  117615. * * 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
  117616. * * 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
  117617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117620. * * 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
  117621. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117622. * * 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
  117623. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117625. * @param name defines the name of the mesh
  117626. * @param options defines the options used to create the mesh
  117627. * @param scene defines the hosting scene
  117628. * @returns the ribbon mesh
  117629. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117630. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117631. */
  117632. static CreateRibbon(name: string, options: {
  117633. pathArray: Vector3[][];
  117634. closeArray?: boolean;
  117635. closePath?: boolean;
  117636. offset?: number;
  117637. updatable?: boolean;
  117638. sideOrientation?: number;
  117639. frontUVs?: Vector4;
  117640. backUVs?: Vector4;
  117641. instance?: Mesh;
  117642. invertUV?: boolean;
  117643. uvs?: Vector2[];
  117644. colors?: Color4[];
  117645. }, scene?: Nullable<Scene>): Mesh;
  117646. /**
  117647. * Creates a cylinder or a cone mesh
  117648. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117649. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117650. * * 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.
  117651. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117652. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117653. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117654. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117655. * * 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).
  117656. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117657. * * 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).
  117658. * * 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
  117659. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117660. * * 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
  117661. * * 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.
  117662. * * If `enclose` is false, a ring surface is one element.
  117663. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117664. * * 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
  117665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117668. * @param name defines the name of the mesh
  117669. * @param options defines the options used to create the mesh
  117670. * @param scene defines the hosting scene
  117671. * @returns the cylinder mesh
  117672. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117673. */
  117674. static CreateCylinder(name: string, options: {
  117675. height?: number;
  117676. diameterTop?: number;
  117677. diameterBottom?: number;
  117678. diameter?: number;
  117679. tessellation?: number;
  117680. subdivisions?: number;
  117681. arc?: number;
  117682. faceColors?: Color4[];
  117683. faceUV?: Vector4[];
  117684. updatable?: boolean;
  117685. hasRings?: boolean;
  117686. enclose?: boolean;
  117687. cap?: number;
  117688. sideOrientation?: number;
  117689. frontUVs?: Vector4;
  117690. backUVs?: Vector4;
  117691. }, scene?: Nullable<Scene>): Mesh;
  117692. /**
  117693. * Creates a torus mesh
  117694. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117695. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117696. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117697. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117698. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117700. * @param name defines the name of the mesh
  117701. * @param options defines the options used to create the mesh
  117702. * @param scene defines the hosting scene
  117703. * @returns the torus mesh
  117704. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117705. */
  117706. static CreateTorus(name: string, options: {
  117707. diameter?: number;
  117708. thickness?: number;
  117709. tessellation?: number;
  117710. updatable?: boolean;
  117711. sideOrientation?: number;
  117712. frontUVs?: Vector4;
  117713. backUVs?: Vector4;
  117714. }, scene?: Nullable<Scene>): Mesh;
  117715. /**
  117716. * Creates a torus knot mesh
  117717. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117718. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117719. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117720. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117724. * @param name defines the name of the mesh
  117725. * @param options defines the options used to create the mesh
  117726. * @param scene defines the hosting scene
  117727. * @returns the torus knot mesh
  117728. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117729. */
  117730. static CreateTorusKnot(name: string, options: {
  117731. radius?: number;
  117732. tube?: number;
  117733. radialSegments?: number;
  117734. tubularSegments?: number;
  117735. p?: number;
  117736. q?: number;
  117737. updatable?: boolean;
  117738. sideOrientation?: number;
  117739. frontUVs?: Vector4;
  117740. backUVs?: Vector4;
  117741. }, scene?: Nullable<Scene>): Mesh;
  117742. /**
  117743. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117744. * * 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
  117745. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117746. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117747. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117748. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117749. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117750. * * 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
  117751. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117753. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117754. * @param name defines the name of the new line system
  117755. * @param options defines the options used to create the line system
  117756. * @param scene defines the hosting scene
  117757. * @returns a new line system mesh
  117758. */
  117759. static CreateLineSystem(name: string, options: {
  117760. lines: Vector3[][];
  117761. updatable?: boolean;
  117762. instance?: Nullable<LinesMesh>;
  117763. colors?: Nullable<Color4[][]>;
  117764. useVertexAlpha?: boolean;
  117765. }, scene: Nullable<Scene>): LinesMesh;
  117766. /**
  117767. * Creates a line mesh
  117768. * 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
  117769. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117770. * * The parameter `points` is an array successive Vector3
  117771. * * 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
  117772. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117773. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117774. * * When updating an instance, remember that only point positions can change, not the number of points
  117775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117776. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117777. * @param name defines the name of the new line system
  117778. * @param options defines the options used to create the line system
  117779. * @param scene defines the hosting scene
  117780. * @returns a new line mesh
  117781. */
  117782. static CreateLines(name: string, options: {
  117783. points: Vector3[];
  117784. updatable?: boolean;
  117785. instance?: Nullable<LinesMesh>;
  117786. colors?: Color4[];
  117787. useVertexAlpha?: boolean;
  117788. }, scene?: Nullable<Scene>): LinesMesh;
  117789. /**
  117790. * Creates a dashed line mesh
  117791. * * 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
  117792. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117793. * * The parameter `points` is an array successive Vector3
  117794. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117795. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117796. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117797. * * 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
  117798. * * When updating an instance, remember that only point positions can change, not the number of points
  117799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117800. * @param name defines the name of the mesh
  117801. * @param options defines the options used to create the mesh
  117802. * @param scene defines the hosting scene
  117803. * @returns the dashed line mesh
  117804. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117805. */
  117806. static CreateDashedLines(name: string, options: {
  117807. points: Vector3[];
  117808. dashSize?: number;
  117809. gapSize?: number;
  117810. dashNb?: number;
  117811. updatable?: boolean;
  117812. instance?: LinesMesh;
  117813. }, scene?: Nullable<Scene>): LinesMesh;
  117814. /**
  117815. * 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.
  117816. * * 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.
  117817. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117818. * * 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.
  117819. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117820. * * 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
  117821. * * 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
  117822. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117827. * @param name defines the name of the mesh
  117828. * @param options defines the options used to create the mesh
  117829. * @param scene defines the hosting scene
  117830. * @returns the extruded shape mesh
  117831. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117832. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117833. */
  117834. static ExtrudeShape(name: string, options: {
  117835. shape: Vector3[];
  117836. path: Vector3[];
  117837. scale?: number;
  117838. rotation?: number;
  117839. cap?: number;
  117840. updatable?: boolean;
  117841. sideOrientation?: number;
  117842. frontUVs?: Vector4;
  117843. backUVs?: Vector4;
  117844. instance?: Mesh;
  117845. invertUV?: boolean;
  117846. }, scene?: Nullable<Scene>): Mesh;
  117847. /**
  117848. * Creates an custom extruded shape mesh.
  117849. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117850. * * 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.
  117851. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117852. * * 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
  117853. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117854. * * 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
  117855. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117856. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117857. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117858. * * 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
  117859. * * 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
  117860. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117865. * @param name defines the name of the mesh
  117866. * @param options defines the options used to create the mesh
  117867. * @param scene defines the hosting scene
  117868. * @returns the custom extruded shape mesh
  117869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117870. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117872. */
  117873. static ExtrudeShapeCustom(name: string, options: {
  117874. shape: Vector3[];
  117875. path: Vector3[];
  117876. scaleFunction?: any;
  117877. rotationFunction?: any;
  117878. ribbonCloseArray?: boolean;
  117879. ribbonClosePath?: boolean;
  117880. cap?: number;
  117881. updatable?: boolean;
  117882. sideOrientation?: number;
  117883. frontUVs?: Vector4;
  117884. backUVs?: Vector4;
  117885. instance?: Mesh;
  117886. invertUV?: boolean;
  117887. }, scene?: Nullable<Scene>): Mesh;
  117888. /**
  117889. * Creates lathe mesh.
  117890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117891. * * 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
  117892. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117893. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117894. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117895. * * 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
  117896. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117897. * * 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
  117898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117901. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117902. * @param name defines the name of the mesh
  117903. * @param options defines the options used to create the mesh
  117904. * @param scene defines the hosting scene
  117905. * @returns the lathe mesh
  117906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117907. */
  117908. static CreateLathe(name: string, options: {
  117909. shape: Vector3[];
  117910. radius?: number;
  117911. tessellation?: number;
  117912. clip?: number;
  117913. arc?: number;
  117914. closed?: boolean;
  117915. updatable?: boolean;
  117916. sideOrientation?: number;
  117917. frontUVs?: Vector4;
  117918. backUVs?: Vector4;
  117919. cap?: number;
  117920. invertUV?: boolean;
  117921. }, scene?: Nullable<Scene>): Mesh;
  117922. /**
  117923. * Creates a tiled plane mesh
  117924. * * You can set a limited pattern arrangement with the tiles
  117925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117928. * @param name defines the name of the mesh
  117929. * @param options defines the options used to create the mesh
  117930. * @param scene defines the hosting scene
  117931. * @returns the plane mesh
  117932. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117933. */
  117934. static CreateTiledPlane(name: string, options: {
  117935. pattern?: number;
  117936. tileSize?: number;
  117937. tileWidth?: number;
  117938. tileHeight?: number;
  117939. size?: number;
  117940. width?: number;
  117941. height?: number;
  117942. alignHorizontal?: number;
  117943. alignVertical?: number;
  117944. sideOrientation?: number;
  117945. frontUVs?: Vector4;
  117946. backUVs?: Vector4;
  117947. updatable?: boolean;
  117948. }, scene?: Nullable<Scene>): Mesh;
  117949. /**
  117950. * Creates a plane mesh
  117951. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  117952. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  117953. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  117954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117957. * @param name defines the name of the mesh
  117958. * @param options defines the options used to create the mesh
  117959. * @param scene defines the hosting scene
  117960. * @returns the plane mesh
  117961. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117962. */
  117963. static CreatePlane(name: string, options: {
  117964. size?: number;
  117965. width?: number;
  117966. height?: number;
  117967. sideOrientation?: number;
  117968. frontUVs?: Vector4;
  117969. backUVs?: Vector4;
  117970. updatable?: boolean;
  117971. sourcePlane?: Plane;
  117972. }, scene?: Nullable<Scene>): Mesh;
  117973. /**
  117974. * Creates a ground mesh
  117975. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117976. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117978. * @param name defines the name of the mesh
  117979. * @param options defines the options used to create the mesh
  117980. * @param scene defines the hosting scene
  117981. * @returns the ground mesh
  117982. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117983. */
  117984. static CreateGround(name: string, options: {
  117985. width?: number;
  117986. height?: number;
  117987. subdivisions?: number;
  117988. subdivisionsX?: number;
  117989. subdivisionsY?: number;
  117990. updatable?: boolean;
  117991. }, scene?: Nullable<Scene>): Mesh;
  117992. /**
  117993. * Creates a tiled ground mesh
  117994. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117995. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117996. * * 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
  117997. * * 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
  117998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117999. * @param name defines the name of the mesh
  118000. * @param options defines the options used to create the mesh
  118001. * @param scene defines the hosting scene
  118002. * @returns the tiled ground mesh
  118003. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  118004. */
  118005. static CreateTiledGround(name: string, options: {
  118006. xmin: number;
  118007. zmin: number;
  118008. xmax: number;
  118009. zmax: number;
  118010. subdivisions?: {
  118011. w: number;
  118012. h: number;
  118013. };
  118014. precision?: {
  118015. w: number;
  118016. h: number;
  118017. };
  118018. updatable?: boolean;
  118019. }, scene?: Nullable<Scene>): Mesh;
  118020. /**
  118021. * Creates a ground mesh from a height map
  118022. * * The parameter `url` sets the URL of the height map image resource.
  118023. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  118024. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  118025. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  118026. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  118027. * * 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.
  118028. * * 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).
  118029. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  118030. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  118031. * @param name defines the name of the mesh
  118032. * @param url defines the url to the height map
  118033. * @param options defines the options used to create the mesh
  118034. * @param scene defines the hosting scene
  118035. * @returns the ground mesh
  118036. * @see https://doc.babylonjs.com/babylon101/height_map
  118037. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118038. */
  118039. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118040. width?: number;
  118041. height?: number;
  118042. subdivisions?: number;
  118043. minHeight?: number;
  118044. maxHeight?: number;
  118045. colorFilter?: Color3;
  118046. alphaFilter?: number;
  118047. updatable?: boolean;
  118048. onReady?: (mesh: GroundMesh) => void;
  118049. }, scene?: Nullable<Scene>): GroundMesh;
  118050. /**
  118051. * Creates a polygon mesh
  118052. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118053. * * 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
  118054. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118056. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118057. * * Remember you can only change the shape positions, not their number when updating a polygon
  118058. * @param name defines the name of the mesh
  118059. * @param options defines the options used to create the mesh
  118060. * @param scene defines the hosting scene
  118061. * @param earcutInjection can be used to inject your own earcut reference
  118062. * @returns the polygon mesh
  118063. */
  118064. static CreatePolygon(name: string, options: {
  118065. shape: Vector3[];
  118066. holes?: Vector3[][];
  118067. depth?: number;
  118068. faceUV?: Vector4[];
  118069. faceColors?: Color4[];
  118070. updatable?: boolean;
  118071. sideOrientation?: number;
  118072. frontUVs?: Vector4;
  118073. backUVs?: Vector4;
  118074. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118075. /**
  118076. * Creates an extruded polygon mesh, with depth in the Y direction.
  118077. * * 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)
  118078. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118079. * @param name defines the name of the mesh
  118080. * @param options defines the options used to create the mesh
  118081. * @param scene defines the hosting scene
  118082. * @param earcutInjection can be used to inject your own earcut reference
  118083. * @returns the polygon mesh
  118084. */
  118085. static ExtrudePolygon(name: string, options: {
  118086. shape: Vector3[];
  118087. holes?: Vector3[][];
  118088. depth?: number;
  118089. faceUV?: Vector4[];
  118090. faceColors?: Color4[];
  118091. updatable?: boolean;
  118092. sideOrientation?: number;
  118093. frontUVs?: Vector4;
  118094. backUVs?: Vector4;
  118095. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118096. /**
  118097. * Creates a tube mesh.
  118098. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118099. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118100. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118101. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118102. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118103. * * 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)
  118104. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118105. * * 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
  118106. * * 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
  118107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118109. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118111. * @param name defines the name of the mesh
  118112. * @param options defines the options used to create the mesh
  118113. * @param scene defines the hosting scene
  118114. * @returns the tube mesh
  118115. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118116. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118117. */
  118118. static CreateTube(name: string, options: {
  118119. path: Vector3[];
  118120. radius?: number;
  118121. tessellation?: number;
  118122. radiusFunction?: {
  118123. (i: number, distance: number): number;
  118124. };
  118125. cap?: number;
  118126. arc?: number;
  118127. updatable?: boolean;
  118128. sideOrientation?: number;
  118129. frontUVs?: Vector4;
  118130. backUVs?: Vector4;
  118131. instance?: Mesh;
  118132. invertUV?: boolean;
  118133. }, scene?: Nullable<Scene>): Mesh;
  118134. /**
  118135. * Creates a polyhedron mesh
  118136. * * 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
  118137. * * The parameter `size` (positive float, default 1) sets the polygon size
  118138. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118139. * * 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`
  118140. * * 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
  118141. * * 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)`)
  118142. * * 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
  118143. * * 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
  118144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118147. * @param name defines the name of the mesh
  118148. * @param options defines the options used to create the mesh
  118149. * @param scene defines the hosting scene
  118150. * @returns the polyhedron mesh
  118151. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118152. */
  118153. static CreatePolyhedron(name: string, options: {
  118154. type?: number;
  118155. size?: number;
  118156. sizeX?: number;
  118157. sizeY?: number;
  118158. sizeZ?: number;
  118159. custom?: any;
  118160. faceUV?: Vector4[];
  118161. faceColors?: Color4[];
  118162. flat?: boolean;
  118163. updatable?: boolean;
  118164. sideOrientation?: number;
  118165. frontUVs?: Vector4;
  118166. backUVs?: Vector4;
  118167. }, scene?: Nullable<Scene>): Mesh;
  118168. /**
  118169. * Creates a decal mesh.
  118170. * 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
  118171. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118172. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118173. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118174. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118175. * @param name defines the name of the mesh
  118176. * @param sourceMesh defines the mesh where the decal must be applied
  118177. * @param options defines the options used to create the mesh
  118178. * @param scene defines the hosting scene
  118179. * @returns the decal mesh
  118180. * @see https://doc.babylonjs.com/how_to/decals
  118181. */
  118182. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118183. position?: Vector3;
  118184. normal?: Vector3;
  118185. size?: Vector3;
  118186. angle?: number;
  118187. }): Mesh;
  118188. }
  118189. }
  118190. declare module BABYLON {
  118191. /**
  118192. * A simplifier interface for future simplification implementations
  118193. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118194. */
  118195. export interface ISimplifier {
  118196. /**
  118197. * Simplification of a given mesh according to the given settings.
  118198. * Since this requires computation, it is assumed that the function runs async.
  118199. * @param settings The settings of the simplification, including quality and distance
  118200. * @param successCallback A callback that will be called after the mesh was simplified.
  118201. * @param errorCallback in case of an error, this callback will be called. optional.
  118202. */
  118203. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118204. }
  118205. /**
  118206. * Expected simplification settings.
  118207. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118208. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118209. */
  118210. export interface ISimplificationSettings {
  118211. /**
  118212. * Gets or sets the expected quality
  118213. */
  118214. quality: number;
  118215. /**
  118216. * Gets or sets the distance when this optimized version should be used
  118217. */
  118218. distance: number;
  118219. /**
  118220. * Gets an already optimized mesh
  118221. */
  118222. optimizeMesh?: boolean;
  118223. }
  118224. /**
  118225. * Class used to specify simplification options
  118226. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118227. */
  118228. export class SimplificationSettings implements ISimplificationSettings {
  118229. /** expected quality */
  118230. quality: number;
  118231. /** distance when this optimized version should be used */
  118232. distance: number;
  118233. /** already optimized mesh */
  118234. optimizeMesh?: boolean | undefined;
  118235. /**
  118236. * Creates a SimplificationSettings
  118237. * @param quality expected quality
  118238. * @param distance distance when this optimized version should be used
  118239. * @param optimizeMesh already optimized mesh
  118240. */
  118241. constructor(
  118242. /** expected quality */
  118243. quality: number,
  118244. /** distance when this optimized version should be used */
  118245. distance: number,
  118246. /** already optimized mesh */
  118247. optimizeMesh?: boolean | undefined);
  118248. }
  118249. /**
  118250. * Interface used to define a simplification task
  118251. */
  118252. export interface ISimplificationTask {
  118253. /**
  118254. * Array of settings
  118255. */
  118256. settings: Array<ISimplificationSettings>;
  118257. /**
  118258. * Simplification type
  118259. */
  118260. simplificationType: SimplificationType;
  118261. /**
  118262. * Mesh to simplify
  118263. */
  118264. mesh: Mesh;
  118265. /**
  118266. * Callback called on success
  118267. */
  118268. successCallback?: () => void;
  118269. /**
  118270. * Defines if parallel processing can be used
  118271. */
  118272. parallelProcessing: boolean;
  118273. }
  118274. /**
  118275. * Queue used to order the simplification tasks
  118276. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118277. */
  118278. export class SimplificationQueue {
  118279. private _simplificationArray;
  118280. /**
  118281. * Gets a boolean indicating that the process is still running
  118282. */
  118283. running: boolean;
  118284. /**
  118285. * Creates a new queue
  118286. */
  118287. constructor();
  118288. /**
  118289. * Adds a new simplification task
  118290. * @param task defines a task to add
  118291. */
  118292. addTask(task: ISimplificationTask): void;
  118293. /**
  118294. * Execute next task
  118295. */
  118296. executeNext(): void;
  118297. /**
  118298. * Execute a simplification task
  118299. * @param task defines the task to run
  118300. */
  118301. runSimplification(task: ISimplificationTask): void;
  118302. private getSimplifier;
  118303. }
  118304. /**
  118305. * The implemented types of simplification
  118306. * At the moment only Quadratic Error Decimation is implemented
  118307. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118308. */
  118309. export enum SimplificationType {
  118310. /** Quadratic error decimation */
  118311. QUADRATIC = 0
  118312. }
  118313. }
  118314. declare module BABYLON {
  118315. interface Scene {
  118316. /** @hidden (Backing field) */
  118317. _simplificationQueue: SimplificationQueue;
  118318. /**
  118319. * Gets or sets the simplification queue attached to the scene
  118320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118321. */
  118322. simplificationQueue: SimplificationQueue;
  118323. }
  118324. interface Mesh {
  118325. /**
  118326. * Simplify the mesh according to the given array of settings.
  118327. * Function will return immediately and will simplify async
  118328. * @param settings a collection of simplification settings
  118329. * @param parallelProcessing should all levels calculate parallel or one after the other
  118330. * @param simplificationType the type of simplification to run
  118331. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118332. * @returns the current mesh
  118333. */
  118334. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118335. }
  118336. /**
  118337. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118338. * created in a scene
  118339. */
  118340. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118341. /**
  118342. * The component name helpfull to identify the component in the list of scene components.
  118343. */
  118344. readonly name: string;
  118345. /**
  118346. * The scene the component belongs to.
  118347. */
  118348. scene: Scene;
  118349. /**
  118350. * Creates a new instance of the component for the given scene
  118351. * @param scene Defines the scene to register the component in
  118352. */
  118353. constructor(scene: Scene);
  118354. /**
  118355. * Registers the component in a given scene
  118356. */
  118357. register(): void;
  118358. /**
  118359. * Rebuilds the elements related to this component in case of
  118360. * context lost for instance.
  118361. */
  118362. rebuild(): void;
  118363. /**
  118364. * Disposes the component and the associated ressources
  118365. */
  118366. dispose(): void;
  118367. private _beforeCameraUpdate;
  118368. }
  118369. }
  118370. declare module BABYLON {
  118371. /**
  118372. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118373. */
  118374. export interface INavigationEnginePlugin {
  118375. /**
  118376. * plugin name
  118377. */
  118378. name: string;
  118379. /**
  118380. * Creates a navigation mesh
  118381. * @param meshes array of all the geometry used to compute the navigatio mesh
  118382. * @param parameters bunch of parameters used to filter geometry
  118383. */
  118384. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118385. /**
  118386. * Create a navigation mesh debug mesh
  118387. * @param scene is where the mesh will be added
  118388. * @returns debug display mesh
  118389. */
  118390. createDebugNavMesh(scene: Scene): Mesh;
  118391. /**
  118392. * Get a navigation mesh constrained position, closest to the parameter position
  118393. * @param position world position
  118394. * @returns the closest point to position constrained by the navigation mesh
  118395. */
  118396. getClosestPoint(position: Vector3): Vector3;
  118397. /**
  118398. * Get a navigation mesh constrained position, within a particular radius
  118399. * @param position world position
  118400. * @param maxRadius the maximum distance to the constrained world position
  118401. * @returns the closest point to position constrained by the navigation mesh
  118402. */
  118403. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118404. /**
  118405. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118406. * @param start world position
  118407. * @param end world position
  118408. * @returns array containing world position composing the path
  118409. */
  118410. computePath(start: Vector3, end: Vector3): Vector3[];
  118411. /**
  118412. * If this plugin is supported
  118413. * @returns true if plugin is supported
  118414. */
  118415. isSupported(): boolean;
  118416. /**
  118417. * Create a new Crowd so you can add agents
  118418. * @param maxAgents the maximum agent count in the crowd
  118419. * @param maxAgentRadius the maximum radius an agent can have
  118420. * @param scene to attach the crowd to
  118421. * @returns the crowd you can add agents to
  118422. */
  118423. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118424. /**
  118425. * Release all resources
  118426. */
  118427. dispose(): void;
  118428. }
  118429. /**
  118430. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118431. */
  118432. export interface ICrowd {
  118433. /**
  118434. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118435. * You can attach anything to that node. The node position is updated in the scene update tick.
  118436. * @param pos world position that will be constrained by the navigation mesh
  118437. * @param parameters agent parameters
  118438. * @param transform hooked to the agent that will be update by the scene
  118439. * @returns agent index
  118440. */
  118441. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118442. /**
  118443. * Returns the agent position in world space
  118444. * @param index agent index returned by addAgent
  118445. * @returns world space position
  118446. */
  118447. getAgentPosition(index: number): Vector3;
  118448. /**
  118449. * Gets the agent velocity in world space
  118450. * @param index agent index returned by addAgent
  118451. * @returns world space velocity
  118452. */
  118453. getAgentVelocity(index: number): Vector3;
  118454. /**
  118455. * remove a particular agent previously created
  118456. * @param index agent index returned by addAgent
  118457. */
  118458. removeAgent(index: number): void;
  118459. /**
  118460. * get the list of all agents attached to this crowd
  118461. * @returns list of agent indices
  118462. */
  118463. getAgents(): number[];
  118464. /**
  118465. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118466. * @param deltaTime in seconds
  118467. */
  118468. update(deltaTime: number): void;
  118469. /**
  118470. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118471. * @param index agent index returned by addAgent
  118472. * @param destination targeted world position
  118473. */
  118474. agentGoto(index: number, destination: Vector3): void;
  118475. /**
  118476. * Release all resources
  118477. */
  118478. dispose(): void;
  118479. }
  118480. /**
  118481. * Configures an agent
  118482. */
  118483. export interface IAgentParameters {
  118484. /**
  118485. * Agent radius. [Limit: >= 0]
  118486. */
  118487. radius: number;
  118488. /**
  118489. * Agent height. [Limit: > 0]
  118490. */
  118491. height: number;
  118492. /**
  118493. * Maximum allowed acceleration. [Limit: >= 0]
  118494. */
  118495. maxAcceleration: number;
  118496. /**
  118497. * Maximum allowed speed. [Limit: >= 0]
  118498. */
  118499. maxSpeed: number;
  118500. /**
  118501. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118502. */
  118503. collisionQueryRange: number;
  118504. /**
  118505. * The path visibility optimization range. [Limit: > 0]
  118506. */
  118507. pathOptimizationRange: number;
  118508. /**
  118509. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118510. */
  118511. separationWeight: number;
  118512. }
  118513. /**
  118514. * Configures the navigation mesh creation
  118515. */
  118516. export interface INavMeshParameters {
  118517. /**
  118518. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118519. */
  118520. cs: number;
  118521. /**
  118522. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118523. */
  118524. ch: number;
  118525. /**
  118526. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118527. */
  118528. walkableSlopeAngle: number;
  118529. /**
  118530. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118531. * be considered walkable. [Limit: >= 3] [Units: vx]
  118532. */
  118533. walkableHeight: number;
  118534. /**
  118535. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118536. */
  118537. walkableClimb: number;
  118538. /**
  118539. * The distance to erode/shrink the walkable area of the heightfield away from
  118540. * obstructions. [Limit: >=0] [Units: vx]
  118541. */
  118542. walkableRadius: number;
  118543. /**
  118544. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118545. */
  118546. maxEdgeLen: number;
  118547. /**
  118548. * The maximum distance a simplfied contour's border edges should deviate
  118549. * the original raw contour. [Limit: >=0] [Units: vx]
  118550. */
  118551. maxSimplificationError: number;
  118552. /**
  118553. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118554. */
  118555. minRegionArea: number;
  118556. /**
  118557. * Any regions with a span count smaller than this value will, if possible,
  118558. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118559. */
  118560. mergeRegionArea: number;
  118561. /**
  118562. * The maximum number of vertices allowed for polygons generated during the
  118563. * contour to polygon conversion process. [Limit: >= 3]
  118564. */
  118565. maxVertsPerPoly: number;
  118566. /**
  118567. * Sets the sampling distance to use when generating the detail mesh.
  118568. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118569. */
  118570. detailSampleDist: number;
  118571. /**
  118572. * The maximum distance the detail mesh surface should deviate from heightfield
  118573. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118574. */
  118575. detailSampleMaxError: number;
  118576. }
  118577. }
  118578. declare module BABYLON {
  118579. /**
  118580. * RecastJS navigation plugin
  118581. */
  118582. export class RecastJSPlugin implements INavigationEnginePlugin {
  118583. /**
  118584. * Reference to the Recast library
  118585. */
  118586. bjsRECAST: any;
  118587. /**
  118588. * plugin name
  118589. */
  118590. name: string;
  118591. /**
  118592. * the first navmesh created. We might extend this to support multiple navmeshes
  118593. */
  118594. navMesh: any;
  118595. /**
  118596. * Initializes the recastJS plugin
  118597. * @param recastInjection can be used to inject your own recast reference
  118598. */
  118599. constructor(recastInjection?: any);
  118600. /**
  118601. * Creates a navigation mesh
  118602. * @param meshes array of all the geometry used to compute the navigatio mesh
  118603. * @param parameters bunch of parameters used to filter geometry
  118604. */
  118605. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118606. /**
  118607. * Create a navigation mesh debug mesh
  118608. * @param scene is where the mesh will be added
  118609. * @returns debug display mesh
  118610. */
  118611. createDebugNavMesh(scene: Scene): Mesh;
  118612. /**
  118613. * Get a navigation mesh constrained position, closest to the parameter position
  118614. * @param position world position
  118615. * @returns the closest point to position constrained by the navigation mesh
  118616. */
  118617. getClosestPoint(position: Vector3): Vector3;
  118618. /**
  118619. * Get a navigation mesh constrained position, within a particular radius
  118620. * @param position world position
  118621. * @param maxRadius the maximum distance to the constrained world position
  118622. * @returns the closest point to position constrained by the navigation mesh
  118623. */
  118624. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118625. /**
  118626. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118627. * @param start world position
  118628. * @param end world position
  118629. * @returns array containing world position composing the path
  118630. */
  118631. computePath(start: Vector3, end: Vector3): Vector3[];
  118632. /**
  118633. * Create a new Crowd so you can add agents
  118634. * @param maxAgents the maximum agent count in the crowd
  118635. * @param maxAgentRadius the maximum radius an agent can have
  118636. * @param scene to attach the crowd to
  118637. * @returns the crowd you can add agents to
  118638. */
  118639. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118640. /**
  118641. * Disposes
  118642. */
  118643. dispose(): void;
  118644. /**
  118645. * If this plugin is supported
  118646. * @returns true if plugin is supported
  118647. */
  118648. isSupported(): boolean;
  118649. }
  118650. /**
  118651. * Recast detour crowd implementation
  118652. */
  118653. export class RecastJSCrowd implements ICrowd {
  118654. /**
  118655. * Recast/detour plugin
  118656. */
  118657. bjsRECASTPlugin: RecastJSPlugin;
  118658. /**
  118659. * Link to the detour crowd
  118660. */
  118661. recastCrowd: any;
  118662. /**
  118663. * One transform per agent
  118664. */
  118665. transforms: TransformNode[];
  118666. /**
  118667. * All agents created
  118668. */
  118669. agents: number[];
  118670. /**
  118671. * Link to the scene is kept to unregister the crowd from the scene
  118672. */
  118673. private _scene;
  118674. /**
  118675. * Observer for crowd updates
  118676. */
  118677. private _onBeforeAnimationsObserver;
  118678. /**
  118679. * Constructor
  118680. * @param plugin recastJS plugin
  118681. * @param maxAgents the maximum agent count in the crowd
  118682. * @param maxAgentRadius the maximum radius an agent can have
  118683. * @param scene to attach the crowd to
  118684. * @returns the crowd you can add agents to
  118685. */
  118686. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  118687. /**
  118688. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118689. * You can attach anything to that node. The node position is updated in the scene update tick.
  118690. * @param pos world position that will be constrained by the navigation mesh
  118691. * @param parameters agent parameters
  118692. * @param transform hooked to the agent that will be update by the scene
  118693. * @returns agent index
  118694. */
  118695. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118696. /**
  118697. * Returns the agent position in world space
  118698. * @param index agent index returned by addAgent
  118699. * @returns world space position
  118700. */
  118701. getAgentPosition(index: number): Vector3;
  118702. /**
  118703. * Returns the agent velocity in world space
  118704. * @param index agent index returned by addAgent
  118705. * @returns world space velocity
  118706. */
  118707. getAgentVelocity(index: number): Vector3;
  118708. /**
  118709. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118710. * @param index agent index returned by addAgent
  118711. * @param destination targeted world position
  118712. */
  118713. agentGoto(index: number, destination: Vector3): void;
  118714. /**
  118715. * remove a particular agent previously created
  118716. * @param index agent index returned by addAgent
  118717. */
  118718. removeAgent(index: number): void;
  118719. /**
  118720. * get the list of all agents attached to this crowd
  118721. * @returns list of agent indices
  118722. */
  118723. getAgents(): number[];
  118724. /**
  118725. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118726. * @param deltaTime in seconds
  118727. */
  118728. update(deltaTime: number): void;
  118729. /**
  118730. * Release all resources
  118731. */
  118732. dispose(): void;
  118733. }
  118734. }
  118735. declare module BABYLON {
  118736. /**
  118737. * Class used to enable access to IndexedDB
  118738. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118739. */
  118740. export class Database implements IOfflineProvider {
  118741. private _callbackManifestChecked;
  118742. private _currentSceneUrl;
  118743. private _db;
  118744. private _enableSceneOffline;
  118745. private _enableTexturesOffline;
  118746. private _manifestVersionFound;
  118747. private _mustUpdateRessources;
  118748. private _hasReachedQuota;
  118749. private _isSupported;
  118750. private _idbFactory;
  118751. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  118752. private static IsUASupportingBlobStorage;
  118753. /**
  118754. * Gets a boolean indicating if Database storate is enabled (off by default)
  118755. */
  118756. static IDBStorageEnabled: boolean;
  118757. /**
  118758. * Gets a boolean indicating if scene must be saved in the database
  118759. */
  118760. readonly enableSceneOffline: boolean;
  118761. /**
  118762. * Gets a boolean indicating if textures must be saved in the database
  118763. */
  118764. readonly enableTexturesOffline: boolean;
  118765. /**
  118766. * Creates a new Database
  118767. * @param urlToScene defines the url to load the scene
  118768. * @param callbackManifestChecked defines the callback to use when manifest is checked
  118769. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  118770. */
  118771. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  118772. private static _ParseURL;
  118773. private static _ReturnFullUrlLocation;
  118774. private _checkManifestFile;
  118775. /**
  118776. * Open the database and make it available
  118777. * @param successCallback defines the callback to call on success
  118778. * @param errorCallback defines the callback to call on error
  118779. */
  118780. open(successCallback: () => void, errorCallback: () => void): void;
  118781. /**
  118782. * Loads an image from the database
  118783. * @param url defines the url to load from
  118784. * @param image defines the target DOM image
  118785. */
  118786. loadImage(url: string, image: HTMLImageElement): void;
  118787. private _loadImageFromDBAsync;
  118788. private _saveImageIntoDBAsync;
  118789. private _checkVersionFromDB;
  118790. private _loadVersionFromDBAsync;
  118791. private _saveVersionIntoDBAsync;
  118792. /**
  118793. * Loads a file from database
  118794. * @param url defines the URL to load from
  118795. * @param sceneLoaded defines a callback to call on success
  118796. * @param progressCallBack defines a callback to call when progress changed
  118797. * @param errorCallback defines a callback to call on error
  118798. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  118799. */
  118800. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  118801. private _loadFileAsync;
  118802. private _saveFileAsync;
  118803. /**
  118804. * Validates if xhr data is correct
  118805. * @param xhr defines the request to validate
  118806. * @param dataType defines the expected data type
  118807. * @returns true if data is correct
  118808. */
  118809. private static _ValidateXHRData;
  118810. }
  118811. }
  118812. declare module BABYLON {
  118813. /** @hidden */
  118814. export var gpuUpdateParticlesPixelShader: {
  118815. name: string;
  118816. shader: string;
  118817. };
  118818. }
  118819. declare module BABYLON {
  118820. /** @hidden */
  118821. export var gpuUpdateParticlesVertexShader: {
  118822. name: string;
  118823. shader: string;
  118824. };
  118825. }
  118826. declare module BABYLON {
  118827. /** @hidden */
  118828. export var clipPlaneFragmentDeclaration2: {
  118829. name: string;
  118830. shader: string;
  118831. };
  118832. }
  118833. declare module BABYLON {
  118834. /** @hidden */
  118835. export var gpuRenderParticlesPixelShader: {
  118836. name: string;
  118837. shader: string;
  118838. };
  118839. }
  118840. declare module BABYLON {
  118841. /** @hidden */
  118842. export var clipPlaneVertexDeclaration2: {
  118843. name: string;
  118844. shader: string;
  118845. };
  118846. }
  118847. declare module BABYLON {
  118848. /** @hidden */
  118849. export var gpuRenderParticlesVertexShader: {
  118850. name: string;
  118851. shader: string;
  118852. };
  118853. }
  118854. declare module BABYLON {
  118855. /**
  118856. * This represents a GPU particle system in Babylon
  118857. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  118858. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  118859. */
  118860. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  118861. /**
  118862. * The layer mask we are rendering the particles through.
  118863. */
  118864. layerMask: number;
  118865. private _capacity;
  118866. private _activeCount;
  118867. private _currentActiveCount;
  118868. private _accumulatedCount;
  118869. private _renderEffect;
  118870. private _updateEffect;
  118871. private _buffer0;
  118872. private _buffer1;
  118873. private _spriteBuffer;
  118874. private _updateVAO;
  118875. private _renderVAO;
  118876. private _targetIndex;
  118877. private _sourceBuffer;
  118878. private _targetBuffer;
  118879. private _engine;
  118880. private _currentRenderId;
  118881. private _started;
  118882. private _stopped;
  118883. private _timeDelta;
  118884. private _randomTexture;
  118885. private _randomTexture2;
  118886. private _attributesStrideSize;
  118887. private _updateEffectOptions;
  118888. private _randomTextureSize;
  118889. private _actualFrame;
  118890. private readonly _rawTextureWidth;
  118891. /**
  118892. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  118893. */
  118894. static readonly IsSupported: boolean;
  118895. /**
  118896. * An event triggered when the system is disposed.
  118897. */
  118898. onDisposeObservable: Observable<GPUParticleSystem>;
  118899. /**
  118900. * Gets the maximum number of particles active at the same time.
  118901. * @returns The max number of active particles.
  118902. */
  118903. getCapacity(): number;
  118904. /**
  118905. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  118906. * to override the particles.
  118907. */
  118908. forceDepthWrite: boolean;
  118909. /**
  118910. * Gets or set the number of active particles
  118911. */
  118912. activeParticleCount: number;
  118913. private _preWarmDone;
  118914. /**
  118915. * Is this system ready to be used/rendered
  118916. * @return true if the system is ready
  118917. */
  118918. isReady(): boolean;
  118919. /**
  118920. * Gets if the system has been started. (Note: this will still be true after stop is called)
  118921. * @returns True if it has been started, otherwise false.
  118922. */
  118923. isStarted(): boolean;
  118924. /**
  118925. * Starts the particle system and begins to emit
  118926. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  118927. */
  118928. start(delay?: number): void;
  118929. /**
  118930. * Stops the particle system.
  118931. */
  118932. stop(): void;
  118933. /**
  118934. * Remove all active particles
  118935. */
  118936. reset(): void;
  118937. /**
  118938. * Returns the string "GPUParticleSystem"
  118939. * @returns a string containing the class name
  118940. */
  118941. getClassName(): string;
  118942. private _colorGradientsTexture;
  118943. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  118944. /**
  118945. * Adds a new color gradient
  118946. * @param gradient defines the gradient to use (between 0 and 1)
  118947. * @param color1 defines the color to affect to the specified gradient
  118948. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  118949. * @returns the current particle system
  118950. */
  118951. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  118952. /**
  118953. * Remove a specific color gradient
  118954. * @param gradient defines the gradient to remove
  118955. * @returns the current particle system
  118956. */
  118957. removeColorGradient(gradient: number): GPUParticleSystem;
  118958. private _angularSpeedGradientsTexture;
  118959. private _sizeGradientsTexture;
  118960. private _velocityGradientsTexture;
  118961. private _limitVelocityGradientsTexture;
  118962. private _dragGradientsTexture;
  118963. private _addFactorGradient;
  118964. /**
  118965. * Adds a new size gradient
  118966. * @param gradient defines the gradient to use (between 0 and 1)
  118967. * @param factor defines the size factor to affect to the specified gradient
  118968. * @returns the current particle system
  118969. */
  118970. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  118971. /**
  118972. * Remove a specific size gradient
  118973. * @param gradient defines the gradient to remove
  118974. * @returns the current particle system
  118975. */
  118976. removeSizeGradient(gradient: number): GPUParticleSystem;
  118977. /**
  118978. * Adds a new angular speed gradient
  118979. * @param gradient defines the gradient to use (between 0 and 1)
  118980. * @param factor defines the angular speed to affect to the specified gradient
  118981. * @returns the current particle system
  118982. */
  118983. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  118984. /**
  118985. * Remove a specific angular speed gradient
  118986. * @param gradient defines the gradient to remove
  118987. * @returns the current particle system
  118988. */
  118989. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  118990. /**
  118991. * Adds a new velocity gradient
  118992. * @param gradient defines the gradient to use (between 0 and 1)
  118993. * @param factor defines the velocity to affect to the specified gradient
  118994. * @returns the current particle system
  118995. */
  118996. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  118997. /**
  118998. * Remove a specific velocity gradient
  118999. * @param gradient defines the gradient to remove
  119000. * @returns the current particle system
  119001. */
  119002. removeVelocityGradient(gradient: number): GPUParticleSystem;
  119003. /**
  119004. * Adds a new limit velocity gradient
  119005. * @param gradient defines the gradient to use (between 0 and 1)
  119006. * @param factor defines the limit velocity value to affect to the specified gradient
  119007. * @returns the current particle system
  119008. */
  119009. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  119010. /**
  119011. * Remove a specific limit velocity gradient
  119012. * @param gradient defines the gradient to remove
  119013. * @returns the current particle system
  119014. */
  119015. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  119016. /**
  119017. * Adds a new drag gradient
  119018. * @param gradient defines the gradient to use (between 0 and 1)
  119019. * @param factor defines the drag value to affect to the specified gradient
  119020. * @returns the current particle system
  119021. */
  119022. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  119023. /**
  119024. * Remove a specific drag gradient
  119025. * @param gradient defines the gradient to remove
  119026. * @returns the current particle system
  119027. */
  119028. removeDragGradient(gradient: number): GPUParticleSystem;
  119029. /**
  119030. * Not supported by GPUParticleSystem
  119031. * @param gradient defines the gradient to use (between 0 and 1)
  119032. * @param factor defines the emit rate value to affect to the specified gradient
  119033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119034. * @returns the current particle system
  119035. */
  119036. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119037. /**
  119038. * Not supported by GPUParticleSystem
  119039. * @param gradient defines the gradient to remove
  119040. * @returns the current particle system
  119041. */
  119042. removeEmitRateGradient(gradient: number): IParticleSystem;
  119043. /**
  119044. * Not supported by GPUParticleSystem
  119045. * @param gradient defines the gradient to use (between 0 and 1)
  119046. * @param factor defines the start size value to affect to the specified gradient
  119047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119048. * @returns the current particle system
  119049. */
  119050. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119051. /**
  119052. * Not supported by GPUParticleSystem
  119053. * @param gradient defines the gradient to remove
  119054. * @returns the current particle system
  119055. */
  119056. removeStartSizeGradient(gradient: number): IParticleSystem;
  119057. /**
  119058. * Not supported by GPUParticleSystem
  119059. * @param gradient defines the gradient to use (between 0 and 1)
  119060. * @param min defines the color remap minimal range
  119061. * @param max defines the color remap maximal range
  119062. * @returns the current particle system
  119063. */
  119064. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119065. /**
  119066. * Not supported by GPUParticleSystem
  119067. * @param gradient defines the gradient to remove
  119068. * @returns the current particle system
  119069. */
  119070. removeColorRemapGradient(): IParticleSystem;
  119071. /**
  119072. * Not supported by GPUParticleSystem
  119073. * @param gradient defines the gradient to use (between 0 and 1)
  119074. * @param min defines the alpha remap minimal range
  119075. * @param max defines the alpha remap maximal range
  119076. * @returns the current particle system
  119077. */
  119078. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119079. /**
  119080. * Not supported by GPUParticleSystem
  119081. * @param gradient defines the gradient to remove
  119082. * @returns the current particle system
  119083. */
  119084. removeAlphaRemapGradient(): IParticleSystem;
  119085. /**
  119086. * Not supported by GPUParticleSystem
  119087. * @param gradient defines the gradient to use (between 0 and 1)
  119088. * @param color defines the color to affect to the specified gradient
  119089. * @returns the current particle system
  119090. */
  119091. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119092. /**
  119093. * Not supported by GPUParticleSystem
  119094. * @param gradient defines the gradient to remove
  119095. * @returns the current particle system
  119096. */
  119097. removeRampGradient(): IParticleSystem;
  119098. /**
  119099. * Not supported by GPUParticleSystem
  119100. * @returns the list of ramp gradients
  119101. */
  119102. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119103. /**
  119104. * Not supported by GPUParticleSystem
  119105. * Gets or sets a boolean indicating that ramp gradients must be used
  119106. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119107. */
  119108. useRampGradients: boolean;
  119109. /**
  119110. * Not supported by GPUParticleSystem
  119111. * @param gradient defines the gradient to use (between 0 and 1)
  119112. * @param factor defines the life time factor to affect to the specified gradient
  119113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119114. * @returns the current particle system
  119115. */
  119116. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119117. /**
  119118. * Not supported by GPUParticleSystem
  119119. * @param gradient defines the gradient to remove
  119120. * @returns the current particle system
  119121. */
  119122. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119123. /**
  119124. * Instantiates a GPU particle system.
  119125. * 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.
  119126. * @param name The name of the particle system
  119127. * @param options The options used to create the system
  119128. * @param scene The scene the particle system belongs to
  119129. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119130. */
  119131. constructor(name: string, options: Partial<{
  119132. capacity: number;
  119133. randomTextureSize: number;
  119134. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119135. protected _reset(): void;
  119136. private _createUpdateVAO;
  119137. private _createRenderVAO;
  119138. private _initialize;
  119139. /** @hidden */
  119140. _recreateUpdateEffect(): void;
  119141. /** @hidden */
  119142. _recreateRenderEffect(): void;
  119143. /**
  119144. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119145. * @param preWarm defines if we are in the pre-warmimg phase
  119146. */
  119147. animate(preWarm?: boolean): void;
  119148. private _createFactorGradientTexture;
  119149. private _createSizeGradientTexture;
  119150. private _createAngularSpeedGradientTexture;
  119151. private _createVelocityGradientTexture;
  119152. private _createLimitVelocityGradientTexture;
  119153. private _createDragGradientTexture;
  119154. private _createColorGradientTexture;
  119155. /**
  119156. * Renders the particle system in its current state
  119157. * @param preWarm defines if the system should only update the particles but not render them
  119158. * @returns the current number of particles
  119159. */
  119160. render(preWarm?: boolean): number;
  119161. /**
  119162. * Rebuilds the particle system
  119163. */
  119164. rebuild(): void;
  119165. private _releaseBuffers;
  119166. private _releaseVAOs;
  119167. /**
  119168. * Disposes the particle system and free the associated resources
  119169. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  119170. */
  119171. dispose(disposeTexture?: boolean): void;
  119172. /**
  119173. * Clones the particle system.
  119174. * @param name The name of the cloned object
  119175. * @param newEmitter The new emitter to use
  119176. * @returns the cloned particle system
  119177. */
  119178. clone(name: string, newEmitter: any): GPUParticleSystem;
  119179. /**
  119180. * Serializes the particle system to a JSON object.
  119181. * @returns the JSON object
  119182. */
  119183. serialize(): any;
  119184. /**
  119185. * Parses a JSON object to create a GPU particle system.
  119186. * @param parsedParticleSystem The JSON object to parse
  119187. * @param scene The scene to create the particle system in
  119188. * @param rootUrl The root url to use to load external dependencies like texture
  119189. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  119190. * @returns the parsed GPU particle system
  119191. */
  119192. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119193. }
  119194. }
  119195. declare module BABYLON {
  119196. /**
  119197. * Represents a set of particle systems working together to create a specific effect
  119198. */
  119199. export class ParticleSystemSet implements IDisposable {
  119200. private _emitterCreationOptions;
  119201. private _emitterNode;
  119202. /**
  119203. * Gets the particle system list
  119204. */
  119205. systems: IParticleSystem[];
  119206. /**
  119207. * Gets the emitter node used with this set
  119208. */
  119209. readonly emitterNode: Nullable<TransformNode>;
  119210. /**
  119211. * Creates a new emitter mesh as a sphere
  119212. * @param options defines the options used to create the sphere
  119213. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119214. * @param scene defines the hosting scene
  119215. */
  119216. setEmitterAsSphere(options: {
  119217. diameter: number;
  119218. segments: number;
  119219. color: Color3;
  119220. }, renderingGroupId: number, scene: Scene): void;
  119221. /**
  119222. * Starts all particle systems of the set
  119223. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119224. */
  119225. start(emitter?: AbstractMesh): void;
  119226. /**
  119227. * Release all associated resources
  119228. */
  119229. dispose(): void;
  119230. /**
  119231. * Serialize the set into a JSON compatible object
  119232. * @returns a JSON compatible representation of the set
  119233. */
  119234. serialize(): any;
  119235. /**
  119236. * Parse a new ParticleSystemSet from a serialized source
  119237. * @param data defines a JSON compatible representation of the set
  119238. * @param scene defines the hosting scene
  119239. * @param gpu defines if we want GPU particles or CPU particles
  119240. * @returns a new ParticleSystemSet
  119241. */
  119242. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119243. }
  119244. }
  119245. declare module BABYLON {
  119246. /**
  119247. * This class is made for on one-liner static method to help creating particle system set.
  119248. */
  119249. export class ParticleHelper {
  119250. /**
  119251. * Gets or sets base Assets URL
  119252. */
  119253. static BaseAssetsUrl: string;
  119254. /**
  119255. * Create a default particle system that you can tweak
  119256. * @param emitter defines the emitter to use
  119257. * @param capacity defines the system capacity (default is 500 particles)
  119258. * @param scene defines the hosting scene
  119259. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119260. * @returns the new Particle system
  119261. */
  119262. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119263. /**
  119264. * This is the main static method (one-liner) of this helper to create different particle systems
  119265. * @param type This string represents the type to the particle system to create
  119266. * @param scene The scene where the particle system should live
  119267. * @param gpu If the system will use gpu
  119268. * @returns the ParticleSystemSet created
  119269. */
  119270. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119271. /**
  119272. * Static function used to export a particle system to a ParticleSystemSet variable.
  119273. * Please note that the emitter shape is not exported
  119274. * @param systems defines the particle systems to export
  119275. * @returns the created particle system set
  119276. */
  119277. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119278. }
  119279. }
  119280. declare module BABYLON {
  119281. interface Engine {
  119282. /**
  119283. * Create an effect to use with particle systems.
  119284. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119285. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119286. * @param uniformsNames defines a list of attribute names
  119287. * @param samplers defines an array of string used to represent textures
  119288. * @param defines defines the string containing the defines to use to compile the shaders
  119289. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119290. * @param onCompiled defines a function to call when the effect creation is successful
  119291. * @param onError defines a function to call when the effect creation has failed
  119292. * @returns the new Effect
  119293. */
  119294. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119295. }
  119296. interface Mesh {
  119297. /**
  119298. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119299. * @returns an array of IParticleSystem
  119300. */
  119301. getEmittedParticleSystems(): IParticleSystem[];
  119302. /**
  119303. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119304. * @returns an array of IParticleSystem
  119305. */
  119306. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119307. }
  119308. /**
  119309. * @hidden
  119310. */
  119311. export var _IDoNeedToBeInTheBuild: number;
  119312. }
  119313. declare module BABYLON {
  119314. interface Scene {
  119315. /** @hidden (Backing field) */
  119316. _physicsEngine: Nullable<IPhysicsEngine>;
  119317. /**
  119318. * Gets the current physics engine
  119319. * @returns a IPhysicsEngine or null if none attached
  119320. */
  119321. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119322. /**
  119323. * Enables physics to the current scene
  119324. * @param gravity defines the scene's gravity for the physics engine
  119325. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119326. * @return a boolean indicating if the physics engine was initialized
  119327. */
  119328. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119329. /**
  119330. * Disables and disposes the physics engine associated with the scene
  119331. */
  119332. disablePhysicsEngine(): void;
  119333. /**
  119334. * Gets a boolean indicating if there is an active physics engine
  119335. * @returns a boolean indicating if there is an active physics engine
  119336. */
  119337. isPhysicsEnabled(): boolean;
  119338. /**
  119339. * Deletes a physics compound impostor
  119340. * @param compound defines the compound to delete
  119341. */
  119342. deleteCompoundImpostor(compound: any): void;
  119343. /**
  119344. * An event triggered when physic simulation is about to be run
  119345. */
  119346. onBeforePhysicsObservable: Observable<Scene>;
  119347. /**
  119348. * An event triggered when physic simulation has been done
  119349. */
  119350. onAfterPhysicsObservable: Observable<Scene>;
  119351. }
  119352. interface AbstractMesh {
  119353. /** @hidden */
  119354. _physicsImpostor: Nullable<PhysicsImpostor>;
  119355. /**
  119356. * Gets or sets impostor used for physic simulation
  119357. * @see http://doc.babylonjs.com/features/physics_engine
  119358. */
  119359. physicsImpostor: Nullable<PhysicsImpostor>;
  119360. /**
  119361. * Gets the current physics impostor
  119362. * @see http://doc.babylonjs.com/features/physics_engine
  119363. * @returns a physics impostor or null
  119364. */
  119365. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119366. /** Apply a physic impulse to the mesh
  119367. * @param force defines the force to apply
  119368. * @param contactPoint defines where to apply the force
  119369. * @returns the current mesh
  119370. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119371. */
  119372. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119373. /**
  119374. * Creates a physic joint between two meshes
  119375. * @param otherMesh defines the other mesh to use
  119376. * @param pivot1 defines the pivot to use on this mesh
  119377. * @param pivot2 defines the pivot to use on the other mesh
  119378. * @param options defines additional options (can be plugin dependent)
  119379. * @returns the current mesh
  119380. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119381. */
  119382. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119383. /** @hidden */
  119384. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119385. }
  119386. /**
  119387. * Defines the physics engine scene component responsible to manage a physics engine
  119388. */
  119389. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119390. /**
  119391. * The component name helpful to identify the component in the list of scene components.
  119392. */
  119393. readonly name: string;
  119394. /**
  119395. * The scene the component belongs to.
  119396. */
  119397. scene: Scene;
  119398. /**
  119399. * Creates a new instance of the component for the given scene
  119400. * @param scene Defines the scene to register the component in
  119401. */
  119402. constructor(scene: Scene);
  119403. /**
  119404. * Registers the component in a given scene
  119405. */
  119406. register(): void;
  119407. /**
  119408. * Rebuilds the elements related to this component in case of
  119409. * context lost for instance.
  119410. */
  119411. rebuild(): void;
  119412. /**
  119413. * Disposes the component and the associated ressources
  119414. */
  119415. dispose(): void;
  119416. }
  119417. }
  119418. declare module BABYLON {
  119419. /**
  119420. * A helper for physics simulations
  119421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119422. */
  119423. export class PhysicsHelper {
  119424. private _scene;
  119425. private _physicsEngine;
  119426. /**
  119427. * Initializes the Physics helper
  119428. * @param scene Babylon.js scene
  119429. */
  119430. constructor(scene: Scene);
  119431. /**
  119432. * Applies a radial explosion impulse
  119433. * @param origin the origin of the explosion
  119434. * @param radiusOrEventOptions the radius or the options of radial explosion
  119435. * @param strength the explosion strength
  119436. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119437. * @returns A physics radial explosion event, or null
  119438. */
  119439. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119440. /**
  119441. * Applies a radial explosion force
  119442. * @param origin the origin of the explosion
  119443. * @param radiusOrEventOptions the radius or the options of radial explosion
  119444. * @param strength the explosion strength
  119445. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119446. * @returns A physics radial explosion event, or null
  119447. */
  119448. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119449. /**
  119450. * Creates a gravitational field
  119451. * @param origin the origin of the explosion
  119452. * @param radiusOrEventOptions the radius or the options of radial explosion
  119453. * @param strength the explosion strength
  119454. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119455. * @returns A physics gravitational field event, or null
  119456. */
  119457. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119458. /**
  119459. * Creates a physics updraft event
  119460. * @param origin the origin of the updraft
  119461. * @param radiusOrEventOptions the radius or the options of the updraft
  119462. * @param strength the strength of the updraft
  119463. * @param height the height of the updraft
  119464. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119465. * @returns A physics updraft event, or null
  119466. */
  119467. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119468. /**
  119469. * Creates a physics vortex event
  119470. * @param origin the of the vortex
  119471. * @param radiusOrEventOptions the radius or the options of the vortex
  119472. * @param strength the strength of the vortex
  119473. * @param height the height of the vortex
  119474. * @returns a Physics vortex event, or null
  119475. * A physics vortex event or null
  119476. */
  119477. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119478. }
  119479. /**
  119480. * Represents a physics radial explosion event
  119481. */
  119482. class PhysicsRadialExplosionEvent {
  119483. private _scene;
  119484. private _options;
  119485. private _sphere;
  119486. private _dataFetched;
  119487. /**
  119488. * Initializes a radial explosioin event
  119489. * @param _scene BabylonJS scene
  119490. * @param _options The options for the vortex event
  119491. */
  119492. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119493. /**
  119494. * Returns the data related to the radial explosion event (sphere).
  119495. * @returns The radial explosion event data
  119496. */
  119497. getData(): PhysicsRadialExplosionEventData;
  119498. /**
  119499. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119500. * @param impostor A physics imposter
  119501. * @param origin the origin of the explosion
  119502. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119503. */
  119504. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119505. /**
  119506. * Triggers affecterd impostors callbacks
  119507. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119508. */
  119509. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119510. /**
  119511. * Disposes the sphere.
  119512. * @param force Specifies if the sphere should be disposed by force
  119513. */
  119514. dispose(force?: boolean): void;
  119515. /*** Helpers ***/
  119516. private _prepareSphere;
  119517. private _intersectsWithSphere;
  119518. }
  119519. /**
  119520. * Represents a gravitational field event
  119521. */
  119522. class PhysicsGravitationalFieldEvent {
  119523. private _physicsHelper;
  119524. private _scene;
  119525. private _origin;
  119526. private _options;
  119527. private _tickCallback;
  119528. private _sphere;
  119529. private _dataFetched;
  119530. /**
  119531. * Initializes the physics gravitational field event
  119532. * @param _physicsHelper A physics helper
  119533. * @param _scene BabylonJS scene
  119534. * @param _origin The origin position of the gravitational field event
  119535. * @param _options The options for the vortex event
  119536. */
  119537. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119538. /**
  119539. * Returns the data related to the gravitational field event (sphere).
  119540. * @returns A gravitational field event
  119541. */
  119542. getData(): PhysicsGravitationalFieldEventData;
  119543. /**
  119544. * Enables the gravitational field.
  119545. */
  119546. enable(): void;
  119547. /**
  119548. * Disables the gravitational field.
  119549. */
  119550. disable(): void;
  119551. /**
  119552. * Disposes the sphere.
  119553. * @param force The force to dispose from the gravitational field event
  119554. */
  119555. dispose(force?: boolean): void;
  119556. private _tick;
  119557. }
  119558. /**
  119559. * Represents a physics updraft event
  119560. */
  119561. class PhysicsUpdraftEvent {
  119562. private _scene;
  119563. private _origin;
  119564. private _options;
  119565. private _physicsEngine;
  119566. private _originTop;
  119567. private _originDirection;
  119568. private _tickCallback;
  119569. private _cylinder;
  119570. private _cylinderPosition;
  119571. private _dataFetched;
  119572. /**
  119573. * Initializes the physics updraft event
  119574. * @param _scene BabylonJS scene
  119575. * @param _origin The origin position of the updraft
  119576. * @param _options The options for the updraft event
  119577. */
  119578. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119579. /**
  119580. * Returns the data related to the updraft event (cylinder).
  119581. * @returns A physics updraft event
  119582. */
  119583. getData(): PhysicsUpdraftEventData;
  119584. /**
  119585. * Enables the updraft.
  119586. */
  119587. enable(): void;
  119588. /**
  119589. * Disables the updraft.
  119590. */
  119591. disable(): void;
  119592. /**
  119593. * Disposes the cylinder.
  119594. * @param force Specifies if the updraft should be disposed by force
  119595. */
  119596. dispose(force?: boolean): void;
  119597. private getImpostorHitData;
  119598. private _tick;
  119599. /*** Helpers ***/
  119600. private _prepareCylinder;
  119601. private _intersectsWithCylinder;
  119602. }
  119603. /**
  119604. * Represents a physics vortex event
  119605. */
  119606. class PhysicsVortexEvent {
  119607. private _scene;
  119608. private _origin;
  119609. private _options;
  119610. private _physicsEngine;
  119611. private _originTop;
  119612. private _tickCallback;
  119613. private _cylinder;
  119614. private _cylinderPosition;
  119615. private _dataFetched;
  119616. /**
  119617. * Initializes the physics vortex event
  119618. * @param _scene The BabylonJS scene
  119619. * @param _origin The origin position of the vortex
  119620. * @param _options The options for the vortex event
  119621. */
  119622. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119623. /**
  119624. * Returns the data related to the vortex event (cylinder).
  119625. * @returns The physics vortex event data
  119626. */
  119627. getData(): PhysicsVortexEventData;
  119628. /**
  119629. * Enables the vortex.
  119630. */
  119631. enable(): void;
  119632. /**
  119633. * Disables the cortex.
  119634. */
  119635. disable(): void;
  119636. /**
  119637. * Disposes the sphere.
  119638. * @param force
  119639. */
  119640. dispose(force?: boolean): void;
  119641. private getImpostorHitData;
  119642. private _tick;
  119643. /*** Helpers ***/
  119644. private _prepareCylinder;
  119645. private _intersectsWithCylinder;
  119646. }
  119647. /**
  119648. * Options fot the radial explosion event
  119649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119650. */
  119651. export class PhysicsRadialExplosionEventOptions {
  119652. /**
  119653. * The radius of the sphere for the radial explosion.
  119654. */
  119655. radius: number;
  119656. /**
  119657. * The strenth of the explosion.
  119658. */
  119659. strength: number;
  119660. /**
  119661. * The strenght of the force in correspondence to the distance of the affected object
  119662. */
  119663. falloff: PhysicsRadialImpulseFalloff;
  119664. /**
  119665. * Sphere options for the radial explosion.
  119666. */
  119667. sphere: {
  119668. segments: number;
  119669. diameter: number;
  119670. };
  119671. /**
  119672. * Sphere options for the radial explosion.
  119673. */
  119674. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  119675. }
  119676. /**
  119677. * Options fot the updraft event
  119678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119679. */
  119680. export class PhysicsUpdraftEventOptions {
  119681. /**
  119682. * The radius of the cylinder for the vortex
  119683. */
  119684. radius: number;
  119685. /**
  119686. * The strenth of the updraft.
  119687. */
  119688. strength: number;
  119689. /**
  119690. * The height of the cylinder for the updraft.
  119691. */
  119692. height: number;
  119693. /**
  119694. * The mode for the the updraft.
  119695. */
  119696. updraftMode: PhysicsUpdraftMode;
  119697. }
  119698. /**
  119699. * Options fot the vortex event
  119700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119701. */
  119702. export class PhysicsVortexEventOptions {
  119703. /**
  119704. * The radius of the cylinder for the vortex
  119705. */
  119706. radius: number;
  119707. /**
  119708. * The strenth of the vortex.
  119709. */
  119710. strength: number;
  119711. /**
  119712. * The height of the cylinder for the vortex.
  119713. */
  119714. height: number;
  119715. /**
  119716. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  119717. */
  119718. centripetalForceThreshold: number;
  119719. /**
  119720. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  119721. */
  119722. centripetalForceMultiplier: number;
  119723. /**
  119724. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  119725. */
  119726. centrifugalForceMultiplier: number;
  119727. /**
  119728. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  119729. */
  119730. updraftForceMultiplier: number;
  119731. }
  119732. /**
  119733. * The strenght of the force in correspondence to the distance of the affected object
  119734. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119735. */
  119736. export enum PhysicsRadialImpulseFalloff {
  119737. /** Defines that impulse is constant in strength across it's whole radius */
  119738. Constant = 0,
  119739. /** Defines that impulse gets weaker if it's further from the origin */
  119740. Linear = 1
  119741. }
  119742. /**
  119743. * The strength of the force in correspondence to the distance of the affected object
  119744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119745. */
  119746. export enum PhysicsUpdraftMode {
  119747. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  119748. Center = 0,
  119749. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  119750. Perpendicular = 1
  119751. }
  119752. /**
  119753. * Interface for a physics hit data
  119754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119755. */
  119756. export interface PhysicsHitData {
  119757. /**
  119758. * The force applied at the contact point
  119759. */
  119760. force: Vector3;
  119761. /**
  119762. * The contact point
  119763. */
  119764. contactPoint: Vector3;
  119765. /**
  119766. * The distance from the origin to the contact point
  119767. */
  119768. distanceFromOrigin: number;
  119769. }
  119770. /**
  119771. * Interface for radial explosion event data
  119772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119773. */
  119774. export interface PhysicsRadialExplosionEventData {
  119775. /**
  119776. * A sphere used for the radial explosion event
  119777. */
  119778. sphere: Mesh;
  119779. }
  119780. /**
  119781. * Interface for gravitational field event data
  119782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119783. */
  119784. export interface PhysicsGravitationalFieldEventData {
  119785. /**
  119786. * A sphere mesh used for the gravitational field event
  119787. */
  119788. sphere: Mesh;
  119789. }
  119790. /**
  119791. * Interface for updraft event data
  119792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119793. */
  119794. export interface PhysicsUpdraftEventData {
  119795. /**
  119796. * A cylinder used for the updraft event
  119797. */
  119798. cylinder: Mesh;
  119799. }
  119800. /**
  119801. * Interface for vortex event data
  119802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119803. */
  119804. export interface PhysicsVortexEventData {
  119805. /**
  119806. * A cylinder used for the vortex event
  119807. */
  119808. cylinder: Mesh;
  119809. }
  119810. /**
  119811. * Interface for an affected physics impostor
  119812. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119813. */
  119814. export interface PhysicsAffectedImpostorWithData {
  119815. /**
  119816. * The impostor affected by the effect
  119817. */
  119818. impostor: PhysicsImpostor;
  119819. /**
  119820. * The data about the hit/horce from the explosion
  119821. */
  119822. hitData: PhysicsHitData;
  119823. }
  119824. }
  119825. declare module BABYLON {
  119826. /** @hidden */
  119827. export var blackAndWhitePixelShader: {
  119828. name: string;
  119829. shader: string;
  119830. };
  119831. }
  119832. declare module BABYLON {
  119833. /**
  119834. * Post process used to render in black and white
  119835. */
  119836. export class BlackAndWhitePostProcess extends PostProcess {
  119837. /**
  119838. * Linear about to convert he result to black and white (default: 1)
  119839. */
  119840. degree: number;
  119841. /**
  119842. * Creates a black and white post process
  119843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  119844. * @param name The name of the effect.
  119845. * @param options The required width/height ratio to downsize to before computing the render pass.
  119846. * @param camera The camera to apply the render pass to.
  119847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119848. * @param engine The engine which the post process will be applied. (default: current engine)
  119849. * @param reusable If the post process can be reused on the same frame. (default: false)
  119850. */
  119851. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119852. }
  119853. }
  119854. declare module BABYLON {
  119855. /**
  119856. * This represents a set of one or more post processes in Babylon.
  119857. * A post process can be used to apply a shader to a texture after it is rendered.
  119858. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119859. */
  119860. export class PostProcessRenderEffect {
  119861. private _postProcesses;
  119862. private _getPostProcesses;
  119863. private _singleInstance;
  119864. private _cameras;
  119865. private _indicesForCamera;
  119866. /**
  119867. * Name of the effect
  119868. * @hidden
  119869. */
  119870. _name: string;
  119871. /**
  119872. * Instantiates a post process render effect.
  119873. * A post process can be used to apply a shader to a texture after it is rendered.
  119874. * @param engine The engine the effect is tied to
  119875. * @param name The name of the effect
  119876. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  119877. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  119878. */
  119879. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  119880. /**
  119881. * Checks if all the post processes in the effect are supported.
  119882. */
  119883. readonly isSupported: boolean;
  119884. /**
  119885. * Updates the current state of the effect
  119886. * @hidden
  119887. */
  119888. _update(): void;
  119889. /**
  119890. * Attaches the effect on cameras
  119891. * @param cameras The camera to attach to.
  119892. * @hidden
  119893. */
  119894. _attachCameras(cameras: Camera): void;
  119895. /**
  119896. * Attaches the effect on cameras
  119897. * @param cameras The camera to attach to.
  119898. * @hidden
  119899. */
  119900. _attachCameras(cameras: Camera[]): void;
  119901. /**
  119902. * Detaches the effect on cameras
  119903. * @param cameras The camera to detatch from.
  119904. * @hidden
  119905. */
  119906. _detachCameras(cameras: Camera): void;
  119907. /**
  119908. * Detatches the effect on cameras
  119909. * @param cameras The camera to detatch from.
  119910. * @hidden
  119911. */
  119912. _detachCameras(cameras: Camera[]): void;
  119913. /**
  119914. * Enables the effect on given cameras
  119915. * @param cameras The camera to enable.
  119916. * @hidden
  119917. */
  119918. _enable(cameras: Camera): void;
  119919. /**
  119920. * Enables the effect on given cameras
  119921. * @param cameras The camera to enable.
  119922. * @hidden
  119923. */
  119924. _enable(cameras: Nullable<Camera[]>): void;
  119925. /**
  119926. * Disables the effect on the given cameras
  119927. * @param cameras The camera to disable.
  119928. * @hidden
  119929. */
  119930. _disable(cameras: Camera): void;
  119931. /**
  119932. * Disables the effect on the given cameras
  119933. * @param cameras The camera to disable.
  119934. * @hidden
  119935. */
  119936. _disable(cameras: Nullable<Camera[]>): void;
  119937. /**
  119938. * Gets a list of the post processes contained in the effect.
  119939. * @param camera The camera to get the post processes on.
  119940. * @returns The list of the post processes in the effect.
  119941. */
  119942. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  119943. }
  119944. }
  119945. declare module BABYLON {
  119946. /** @hidden */
  119947. export var extractHighlightsPixelShader: {
  119948. name: string;
  119949. shader: string;
  119950. };
  119951. }
  119952. declare module BABYLON {
  119953. /**
  119954. * 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.
  119955. */
  119956. export class ExtractHighlightsPostProcess extends PostProcess {
  119957. /**
  119958. * The luminance threshold, pixels below this value will be set to black.
  119959. */
  119960. threshold: number;
  119961. /** @hidden */
  119962. _exposure: number;
  119963. /**
  119964. * Post process which has the input texture to be used when performing highlight extraction
  119965. * @hidden
  119966. */
  119967. _inputPostProcess: Nullable<PostProcess>;
  119968. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119969. }
  119970. }
  119971. declare module BABYLON {
  119972. /** @hidden */
  119973. export var bloomMergePixelShader: {
  119974. name: string;
  119975. shader: string;
  119976. };
  119977. }
  119978. declare module BABYLON {
  119979. /**
  119980. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  119981. */
  119982. export class BloomMergePostProcess extends PostProcess {
  119983. /** Weight of the bloom to be added to the original input. */
  119984. weight: number;
  119985. /**
  119986. * Creates a new instance of @see BloomMergePostProcess
  119987. * @param name The name of the effect.
  119988. * @param originalFromInput Post process which's input will be used for the merge.
  119989. * @param blurred Blurred highlights post process which's output will be used.
  119990. * @param weight Weight of the bloom to be added to the original input.
  119991. * @param options The required width/height ratio to downsize to before computing the render pass.
  119992. * @param camera The camera to apply the render pass to.
  119993. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119994. * @param engine The engine which the post process will be applied. (default: current engine)
  119995. * @param reusable If the post process can be reused on the same frame. (default: false)
  119996. * @param textureType Type of textures used when performing the post process. (default: 0)
  119997. * @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)
  119998. */
  119999. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  120000. /** Weight of the bloom to be added to the original input. */
  120001. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120002. }
  120003. }
  120004. declare module BABYLON {
  120005. /**
  120006. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  120007. */
  120008. export class BloomEffect extends PostProcessRenderEffect {
  120009. private bloomScale;
  120010. /**
  120011. * @hidden Internal
  120012. */
  120013. _effects: Array<PostProcess>;
  120014. /**
  120015. * @hidden Internal
  120016. */
  120017. _downscale: ExtractHighlightsPostProcess;
  120018. private _blurX;
  120019. private _blurY;
  120020. private _merge;
  120021. /**
  120022. * The luminance threshold to find bright areas of the image to bloom.
  120023. */
  120024. threshold: number;
  120025. /**
  120026. * The strength of the bloom.
  120027. */
  120028. weight: number;
  120029. /**
  120030. * Specifies the size of the bloom blur kernel, relative to the final output size
  120031. */
  120032. kernel: number;
  120033. /**
  120034. * Creates a new instance of @see BloomEffect
  120035. * @param scene The scene the effect belongs to.
  120036. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120037. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120038. * @param bloomWeight The the strength of bloom.
  120039. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120040. * @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)
  120041. */
  120042. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120043. /**
  120044. * Disposes each of the internal effects for a given camera.
  120045. * @param camera The camera to dispose the effect on.
  120046. */
  120047. disposeEffects(camera: Camera): void;
  120048. /**
  120049. * @hidden Internal
  120050. */
  120051. _updateEffects(): void;
  120052. /**
  120053. * Internal
  120054. * @returns if all the contained post processes are ready.
  120055. * @hidden
  120056. */
  120057. _isReady(): boolean;
  120058. }
  120059. }
  120060. declare module BABYLON {
  120061. /** @hidden */
  120062. export var chromaticAberrationPixelShader: {
  120063. name: string;
  120064. shader: string;
  120065. };
  120066. }
  120067. declare module BABYLON {
  120068. /**
  120069. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120070. */
  120071. export class ChromaticAberrationPostProcess extends PostProcess {
  120072. /**
  120073. * The amount of seperation of rgb channels (default: 30)
  120074. */
  120075. aberrationAmount: number;
  120076. /**
  120077. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120078. */
  120079. radialIntensity: number;
  120080. /**
  120081. * 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))
  120082. */
  120083. direction: Vector2;
  120084. /**
  120085. * 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))
  120086. */
  120087. centerPosition: Vector2;
  120088. /**
  120089. * Creates a new instance ChromaticAberrationPostProcess
  120090. * @param name The name of the effect.
  120091. * @param screenWidth The width of the screen to apply the effect on.
  120092. * @param screenHeight The height of the screen to apply the effect on.
  120093. * @param options The required width/height ratio to downsize to before computing the render pass.
  120094. * @param camera The camera to apply the render pass to.
  120095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120096. * @param engine The engine which the post process will be applied. (default: current engine)
  120097. * @param reusable If the post process can be reused on the same frame. (default: false)
  120098. * @param textureType Type of textures used when performing the post process. (default: 0)
  120099. * @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)
  120100. */
  120101. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120102. }
  120103. }
  120104. declare module BABYLON {
  120105. /** @hidden */
  120106. export var circleOfConfusionPixelShader: {
  120107. name: string;
  120108. shader: string;
  120109. };
  120110. }
  120111. declare module BABYLON {
  120112. /**
  120113. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120114. */
  120115. export class CircleOfConfusionPostProcess extends PostProcess {
  120116. /**
  120117. * 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.
  120118. */
  120119. lensSize: number;
  120120. /**
  120121. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120122. */
  120123. fStop: number;
  120124. /**
  120125. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120126. */
  120127. focusDistance: number;
  120128. /**
  120129. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120130. */
  120131. focalLength: number;
  120132. private _depthTexture;
  120133. /**
  120134. * Creates a new instance CircleOfConfusionPostProcess
  120135. * @param name The name of the effect.
  120136. * @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.
  120137. * @param options The required width/height ratio to downsize to before computing the render pass.
  120138. * @param camera The camera to apply the render pass to.
  120139. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120140. * @param engine The engine which the post process will be applied. (default: current engine)
  120141. * @param reusable If the post process can be reused on the same frame. (default: false)
  120142. * @param textureType Type of textures used when performing the post process. (default: 0)
  120143. * @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)
  120144. */
  120145. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120146. /**
  120147. * 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.
  120148. */
  120149. depthTexture: RenderTargetTexture;
  120150. }
  120151. }
  120152. declare module BABYLON {
  120153. /** @hidden */
  120154. export var colorCorrectionPixelShader: {
  120155. name: string;
  120156. shader: string;
  120157. };
  120158. }
  120159. declare module BABYLON {
  120160. /**
  120161. *
  120162. * This post-process allows the modification of rendered colors by using
  120163. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120164. *
  120165. * The object needs to be provided an url to a texture containing the color
  120166. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  120167. * Use an image editing software to tweak the LUT to match your needs.
  120168. *
  120169. * For an example of a color LUT, see here:
  120170. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  120171. * For explanations on color grading, see here:
  120172. * @see http://udn.epicgames.com/Three/ColorGrading.html
  120173. *
  120174. */
  120175. export class ColorCorrectionPostProcess extends PostProcess {
  120176. private _colorTableTexture;
  120177. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120178. }
  120179. }
  120180. declare module BABYLON {
  120181. /** @hidden */
  120182. export var convolutionPixelShader: {
  120183. name: string;
  120184. shader: string;
  120185. };
  120186. }
  120187. declare module BABYLON {
  120188. /**
  120189. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  120190. * input texture to perform effects such as edge detection or sharpening
  120191. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120192. */
  120193. export class ConvolutionPostProcess extends PostProcess {
  120194. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120195. kernel: number[];
  120196. /**
  120197. * Creates a new instance ConvolutionPostProcess
  120198. * @param name The name of the effect.
  120199. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120200. * @param options The required width/height ratio to downsize to before computing the render pass.
  120201. * @param camera The camera to apply the render pass to.
  120202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120203. * @param engine The engine which the post process will be applied. (default: current engine)
  120204. * @param reusable If the post process can be reused on the same frame. (default: false)
  120205. * @param textureType Type of textures used when performing the post process. (default: 0)
  120206. */
  120207. constructor(name: string,
  120208. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120209. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120210. /**
  120211. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120212. */
  120213. static EdgeDetect0Kernel: number[];
  120214. /**
  120215. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120216. */
  120217. static EdgeDetect1Kernel: number[];
  120218. /**
  120219. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120220. */
  120221. static EdgeDetect2Kernel: number[];
  120222. /**
  120223. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120224. */
  120225. static SharpenKernel: number[];
  120226. /**
  120227. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120228. */
  120229. static EmbossKernel: number[];
  120230. /**
  120231. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120232. */
  120233. static GaussianKernel: number[];
  120234. }
  120235. }
  120236. declare module BABYLON {
  120237. /**
  120238. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120239. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120240. * based on samples that have a large difference in distance than the center pixel.
  120241. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120242. */
  120243. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120244. direction: Vector2;
  120245. /**
  120246. * Creates a new instance CircleOfConfusionPostProcess
  120247. * @param name The name of the effect.
  120248. * @param scene The scene the effect belongs to.
  120249. * @param direction The direction the blur should be applied.
  120250. * @param kernel The size of the kernel used to blur.
  120251. * @param options The required width/height ratio to downsize to before computing the render pass.
  120252. * @param camera The camera to apply the render pass to.
  120253. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120254. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120256. * @param engine The engine which the post process will be applied. (default: current engine)
  120257. * @param reusable If the post process can be reused on the same frame. (default: false)
  120258. * @param textureType Type of textures used when performing the post process. (default: 0)
  120259. * @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)
  120260. */
  120261. 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);
  120262. }
  120263. }
  120264. declare module BABYLON {
  120265. /** @hidden */
  120266. export var depthOfFieldMergePixelShader: {
  120267. name: string;
  120268. shader: string;
  120269. };
  120270. }
  120271. declare module BABYLON {
  120272. /**
  120273. * Options to be set when merging outputs from the default pipeline.
  120274. */
  120275. export class DepthOfFieldMergePostProcessOptions {
  120276. /**
  120277. * The original image to merge on top of
  120278. */
  120279. originalFromInput: PostProcess;
  120280. /**
  120281. * Parameters to perform the merge of the depth of field effect
  120282. */
  120283. depthOfField?: {
  120284. circleOfConfusion: PostProcess;
  120285. blurSteps: Array<PostProcess>;
  120286. };
  120287. /**
  120288. * Parameters to perform the merge of bloom effect
  120289. */
  120290. bloom?: {
  120291. blurred: PostProcess;
  120292. weight: number;
  120293. };
  120294. }
  120295. /**
  120296. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120297. */
  120298. export class DepthOfFieldMergePostProcess extends PostProcess {
  120299. private blurSteps;
  120300. /**
  120301. * Creates a new instance of DepthOfFieldMergePostProcess
  120302. * @param name The name of the effect.
  120303. * @param originalFromInput Post process which's input will be used for the merge.
  120304. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120305. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120306. * @param options The required width/height ratio to downsize to before computing the render pass.
  120307. * @param camera The camera to apply the render pass to.
  120308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120309. * @param engine The engine which the post process will be applied. (default: current engine)
  120310. * @param reusable If the post process can be reused on the same frame. (default: false)
  120311. * @param textureType Type of textures used when performing the post process. (default: 0)
  120312. * @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)
  120313. */
  120314. 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);
  120315. /**
  120316. * Updates the effect with the current post process compile time values and recompiles the shader.
  120317. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120318. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120319. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120320. * @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
  120321. * @param onCompiled Called when the shader has been compiled.
  120322. * @param onError Called if there is an error when compiling a shader.
  120323. */
  120324. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. /**
  120329. * Specifies the level of max blur that should be applied when using the depth of field effect
  120330. */
  120331. export enum DepthOfFieldEffectBlurLevel {
  120332. /**
  120333. * Subtle blur
  120334. */
  120335. Low = 0,
  120336. /**
  120337. * Medium blur
  120338. */
  120339. Medium = 1,
  120340. /**
  120341. * Large blur
  120342. */
  120343. High = 2
  120344. }
  120345. /**
  120346. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120347. */
  120348. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120349. private _circleOfConfusion;
  120350. /**
  120351. * @hidden Internal, blurs from high to low
  120352. */
  120353. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120354. private _depthOfFieldBlurY;
  120355. private _dofMerge;
  120356. /**
  120357. * @hidden Internal post processes in depth of field effect
  120358. */
  120359. _effects: Array<PostProcess>;
  120360. /**
  120361. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120362. */
  120363. focalLength: number;
  120364. /**
  120365. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120366. */
  120367. fStop: number;
  120368. /**
  120369. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120370. */
  120371. focusDistance: number;
  120372. /**
  120373. * 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.
  120374. */
  120375. lensSize: number;
  120376. /**
  120377. * Creates a new instance DepthOfFieldEffect
  120378. * @param scene The scene the effect belongs to.
  120379. * @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.
  120380. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120381. * @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)
  120382. */
  120383. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120384. /**
  120385. * Get the current class name of the current effet
  120386. * @returns "DepthOfFieldEffect"
  120387. */
  120388. getClassName(): string;
  120389. /**
  120390. * 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.
  120391. */
  120392. depthTexture: RenderTargetTexture;
  120393. /**
  120394. * Disposes each of the internal effects for a given camera.
  120395. * @param camera The camera to dispose the effect on.
  120396. */
  120397. disposeEffects(camera: Camera): void;
  120398. /**
  120399. * @hidden Internal
  120400. */
  120401. _updateEffects(): void;
  120402. /**
  120403. * Internal
  120404. * @returns if all the contained post processes are ready.
  120405. * @hidden
  120406. */
  120407. _isReady(): boolean;
  120408. }
  120409. }
  120410. declare module BABYLON {
  120411. /** @hidden */
  120412. export var displayPassPixelShader: {
  120413. name: string;
  120414. shader: string;
  120415. };
  120416. }
  120417. declare module BABYLON {
  120418. /**
  120419. * DisplayPassPostProcess which produces an output the same as it's input
  120420. */
  120421. export class DisplayPassPostProcess extends PostProcess {
  120422. /**
  120423. * Creates the DisplayPassPostProcess
  120424. * @param name The name of the effect.
  120425. * @param options The required width/height ratio to downsize to before computing the render pass.
  120426. * @param camera The camera to apply the render pass to.
  120427. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120428. * @param engine The engine which the post process will be applied. (default: current engine)
  120429. * @param reusable If the post process can be reused on the same frame. (default: false)
  120430. */
  120431. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120432. }
  120433. }
  120434. declare module BABYLON {
  120435. /** @hidden */
  120436. export var filterPixelShader: {
  120437. name: string;
  120438. shader: string;
  120439. };
  120440. }
  120441. declare module BABYLON {
  120442. /**
  120443. * Applies a kernel filter to the image
  120444. */
  120445. export class FilterPostProcess extends PostProcess {
  120446. /** The matrix to be applied to the image */
  120447. kernelMatrix: Matrix;
  120448. /**
  120449. *
  120450. * @param name The name of the effect.
  120451. * @param kernelMatrix The matrix to be applied to the image
  120452. * @param options The required width/height ratio to downsize to before computing the render pass.
  120453. * @param camera The camera to apply the render pass to.
  120454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120455. * @param engine The engine which the post process will be applied. (default: current engine)
  120456. * @param reusable If the post process can be reused on the same frame. (default: false)
  120457. */
  120458. constructor(name: string,
  120459. /** The matrix to be applied to the image */
  120460. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120461. }
  120462. }
  120463. declare module BABYLON {
  120464. /** @hidden */
  120465. export var fxaaPixelShader: {
  120466. name: string;
  120467. shader: string;
  120468. };
  120469. }
  120470. declare module BABYLON {
  120471. /** @hidden */
  120472. export var fxaaVertexShader: {
  120473. name: string;
  120474. shader: string;
  120475. };
  120476. }
  120477. declare module BABYLON {
  120478. /**
  120479. * Fxaa post process
  120480. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120481. */
  120482. export class FxaaPostProcess extends PostProcess {
  120483. /** @hidden */
  120484. texelWidth: number;
  120485. /** @hidden */
  120486. texelHeight: number;
  120487. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120488. private _getDefines;
  120489. }
  120490. }
  120491. declare module BABYLON {
  120492. /** @hidden */
  120493. export var grainPixelShader: {
  120494. name: string;
  120495. shader: string;
  120496. };
  120497. }
  120498. declare module BABYLON {
  120499. /**
  120500. * The GrainPostProcess adds noise to the image at mid luminance levels
  120501. */
  120502. export class GrainPostProcess extends PostProcess {
  120503. /**
  120504. * The intensity of the grain added (default: 30)
  120505. */
  120506. intensity: number;
  120507. /**
  120508. * If the grain should be randomized on every frame
  120509. */
  120510. animated: boolean;
  120511. /**
  120512. * Creates a new instance of @see GrainPostProcess
  120513. * @param name The name of the effect.
  120514. * @param options The required width/height ratio to downsize to before computing the render pass.
  120515. * @param camera The camera to apply the render pass to.
  120516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120517. * @param engine The engine which the post process will be applied. (default: current engine)
  120518. * @param reusable If the post process can be reused on the same frame. (default: false)
  120519. * @param textureType Type of textures used when performing the post process. (default: 0)
  120520. * @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)
  120521. */
  120522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120523. }
  120524. }
  120525. declare module BABYLON {
  120526. /** @hidden */
  120527. export var highlightsPixelShader: {
  120528. name: string;
  120529. shader: string;
  120530. };
  120531. }
  120532. declare module BABYLON {
  120533. /**
  120534. * Extracts highlights from the image
  120535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120536. */
  120537. export class HighlightsPostProcess extends PostProcess {
  120538. /**
  120539. * Extracts highlights from the image
  120540. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120541. * @param name The name of the effect.
  120542. * @param options The required width/height ratio to downsize to before computing the render pass.
  120543. * @param camera The camera to apply the render pass to.
  120544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120545. * @param engine The engine which the post process will be applied. (default: current engine)
  120546. * @param reusable If the post process can be reused on the same frame. (default: false)
  120547. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120548. */
  120549. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120550. }
  120551. }
  120552. declare module BABYLON {
  120553. /** @hidden */
  120554. export var mrtFragmentDeclaration: {
  120555. name: string;
  120556. shader: string;
  120557. };
  120558. }
  120559. declare module BABYLON {
  120560. /** @hidden */
  120561. export var geometryPixelShader: {
  120562. name: string;
  120563. shader: string;
  120564. };
  120565. }
  120566. declare module BABYLON {
  120567. /** @hidden */
  120568. export var geometryVertexShader: {
  120569. name: string;
  120570. shader: string;
  120571. };
  120572. }
  120573. declare module BABYLON {
  120574. /** @hidden */
  120575. interface ISavedTransformationMatrix {
  120576. world: Matrix;
  120577. viewProjection: Matrix;
  120578. }
  120579. /**
  120580. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120581. */
  120582. export class GeometryBufferRenderer {
  120583. /**
  120584. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120585. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120586. */
  120587. static readonly POSITION_TEXTURE_TYPE: number;
  120588. /**
  120589. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120590. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120591. */
  120592. static readonly VELOCITY_TEXTURE_TYPE: number;
  120593. /**
  120594. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120595. * in order to compute objects velocities when enableVelocity is set to "true"
  120596. * @hidden
  120597. */
  120598. _previousTransformationMatrices: {
  120599. [index: number]: ISavedTransformationMatrix;
  120600. };
  120601. /**
  120602. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120603. * in order to compute objects velocities when enableVelocity is set to "true"
  120604. * @hidden
  120605. */
  120606. _previousBonesTransformationMatrices: {
  120607. [index: number]: Float32Array;
  120608. };
  120609. /**
  120610. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120611. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120612. */
  120613. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120614. private _scene;
  120615. private _multiRenderTarget;
  120616. private _ratio;
  120617. private _enablePosition;
  120618. private _enableVelocity;
  120619. private _positionIndex;
  120620. private _velocityIndex;
  120621. protected _effect: Effect;
  120622. protected _cachedDefines: string;
  120623. /**
  120624. * Set the render list (meshes to be rendered) used in the G buffer.
  120625. */
  120626. renderList: Mesh[];
  120627. /**
  120628. * Gets wether or not G buffer are supported by the running hardware.
  120629. * This requires draw buffer supports
  120630. */
  120631. readonly isSupported: boolean;
  120632. /**
  120633. * Returns the index of the given texture type in the G-Buffer textures array
  120634. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120635. * @returns the index of the given texture type in the G-Buffer textures array
  120636. */
  120637. getTextureIndex(textureType: number): number;
  120638. /**
  120639. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120640. */
  120641. /**
  120642. * Sets whether or not objects positions are enabled for the G buffer.
  120643. */
  120644. enablePosition: boolean;
  120645. /**
  120646. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120647. */
  120648. /**
  120649. * Sets wether or not objects velocities are enabled for the G buffer.
  120650. */
  120651. enableVelocity: boolean;
  120652. /**
  120653. * Gets the scene associated with the buffer.
  120654. */
  120655. readonly scene: Scene;
  120656. /**
  120657. * Gets the ratio used by the buffer during its creation.
  120658. * How big is the buffer related to the main canvas.
  120659. */
  120660. readonly ratio: number;
  120661. /** @hidden */
  120662. static _SceneComponentInitialization: (scene: Scene) => void;
  120663. /**
  120664. * Creates a new G Buffer for the scene
  120665. * @param scene The scene the buffer belongs to
  120666. * @param ratio How big is the buffer related to the main canvas.
  120667. */
  120668. constructor(scene: Scene, ratio?: number);
  120669. /**
  120670. * Checks wether everything is ready to render a submesh to the G buffer.
  120671. * @param subMesh the submesh to check readiness for
  120672. * @param useInstances is the mesh drawn using instance or not
  120673. * @returns true if ready otherwise false
  120674. */
  120675. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120676. /**
  120677. * Gets the current underlying G Buffer.
  120678. * @returns the buffer
  120679. */
  120680. getGBuffer(): MultiRenderTarget;
  120681. /**
  120682. * Gets the number of samples used to render the buffer (anti aliasing).
  120683. */
  120684. /**
  120685. * Sets the number of samples used to render the buffer (anti aliasing).
  120686. */
  120687. samples: number;
  120688. /**
  120689. * Disposes the renderer and frees up associated resources.
  120690. */
  120691. dispose(): void;
  120692. protected _createRenderTargets(): void;
  120693. private _copyBonesTransformationMatrices;
  120694. }
  120695. }
  120696. declare module BABYLON {
  120697. interface Scene {
  120698. /** @hidden (Backing field) */
  120699. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120700. /**
  120701. * Gets or Sets the current geometry buffer associated to the scene.
  120702. */
  120703. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120704. /**
  120705. * Enables a GeometryBufferRender and associates it with the scene
  120706. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  120707. * @returns the GeometryBufferRenderer
  120708. */
  120709. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  120710. /**
  120711. * Disables the GeometryBufferRender associated with the scene
  120712. */
  120713. disableGeometryBufferRenderer(): void;
  120714. }
  120715. /**
  120716. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120717. * in several rendering techniques.
  120718. */
  120719. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  120720. /**
  120721. * The component name helpful to identify the component in the list of scene components.
  120722. */
  120723. readonly name: string;
  120724. /**
  120725. * The scene the component belongs to.
  120726. */
  120727. scene: Scene;
  120728. /**
  120729. * Creates a new instance of the component for the given scene
  120730. * @param scene Defines the scene to register the component in
  120731. */
  120732. constructor(scene: Scene);
  120733. /**
  120734. * Registers the component in a given scene
  120735. */
  120736. register(): void;
  120737. /**
  120738. * Rebuilds the elements related to this component in case of
  120739. * context lost for instance.
  120740. */
  120741. rebuild(): void;
  120742. /**
  120743. * Disposes the component and the associated ressources
  120744. */
  120745. dispose(): void;
  120746. private _gatherRenderTargets;
  120747. }
  120748. }
  120749. declare module BABYLON {
  120750. /** @hidden */
  120751. export var motionBlurPixelShader: {
  120752. name: string;
  120753. shader: string;
  120754. };
  120755. }
  120756. declare module BABYLON {
  120757. /**
  120758. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  120759. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  120760. * As an example, all you have to do is to create the post-process:
  120761. * var mb = new BABYLON.MotionBlurPostProcess(
  120762. * 'mb', // The name of the effect.
  120763. * scene, // The scene containing the objects to blur according to their velocity.
  120764. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  120765. * camera // The camera to apply the render pass to.
  120766. * );
  120767. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  120768. */
  120769. export class MotionBlurPostProcess extends PostProcess {
  120770. /**
  120771. * Defines how much the image is blurred by the movement. Default value is equal to 1
  120772. */
  120773. motionStrength: number;
  120774. /**
  120775. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  120776. */
  120777. /**
  120778. * Sets the number of iterations to be used for motion blur quality
  120779. */
  120780. motionBlurSamples: number;
  120781. private _motionBlurSamples;
  120782. private _geometryBufferRenderer;
  120783. /**
  120784. * Creates a new instance MotionBlurPostProcess
  120785. * @param name The name of the effect.
  120786. * @param scene The scene containing the objects to blur according to their velocity.
  120787. * @param options The required width/height ratio to downsize to before computing the render pass.
  120788. * @param camera The camera to apply the render pass to.
  120789. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120790. * @param engine The engine which the post process will be applied. (default: current engine)
  120791. * @param reusable If the post process can be reused on the same frame. (default: false)
  120792. * @param textureType Type of textures used when performing the post process. (default: 0)
  120793. * @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)
  120794. */
  120795. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120796. /**
  120797. * Excludes the given skinned mesh from computing bones velocities.
  120798. * 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.
  120799. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  120800. */
  120801. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120802. /**
  120803. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  120804. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  120805. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  120806. */
  120807. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120808. /**
  120809. * Disposes the post process.
  120810. * @param camera The camera to dispose the post process on.
  120811. */
  120812. dispose(camera?: Camera): void;
  120813. }
  120814. }
  120815. declare module BABYLON {
  120816. /** @hidden */
  120817. export var refractionPixelShader: {
  120818. name: string;
  120819. shader: string;
  120820. };
  120821. }
  120822. declare module BABYLON {
  120823. /**
  120824. * Post process which applies a refractin texture
  120825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120826. */
  120827. export class RefractionPostProcess extends PostProcess {
  120828. /** the base color of the refraction (used to taint the rendering) */
  120829. color: Color3;
  120830. /** simulated refraction depth */
  120831. depth: number;
  120832. /** the coefficient of the base color (0 to remove base color tainting) */
  120833. colorLevel: number;
  120834. private _refTexture;
  120835. private _ownRefractionTexture;
  120836. /**
  120837. * Gets or sets the refraction texture
  120838. * Please note that you are responsible for disposing the texture if you set it manually
  120839. */
  120840. refractionTexture: Texture;
  120841. /**
  120842. * Initializes the RefractionPostProcess
  120843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120844. * @param name The name of the effect.
  120845. * @param refractionTextureUrl Url of the refraction texture to use
  120846. * @param color the base color of the refraction (used to taint the rendering)
  120847. * @param depth simulated refraction depth
  120848. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  120849. * @param camera The camera to apply the render pass to.
  120850. * @param options The required width/height ratio to downsize to before computing the render pass.
  120851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120852. * @param engine The engine which the post process will be applied. (default: current engine)
  120853. * @param reusable If the post process can be reused on the same frame. (default: false)
  120854. */
  120855. constructor(name: string, refractionTextureUrl: string,
  120856. /** the base color of the refraction (used to taint the rendering) */
  120857. color: Color3,
  120858. /** simulated refraction depth */
  120859. depth: number,
  120860. /** the coefficient of the base color (0 to remove base color tainting) */
  120861. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120862. /**
  120863. * Disposes of the post process
  120864. * @param camera Camera to dispose post process on
  120865. */
  120866. dispose(camera: Camera): void;
  120867. }
  120868. }
  120869. declare module BABYLON {
  120870. /** @hidden */
  120871. export var sharpenPixelShader: {
  120872. name: string;
  120873. shader: string;
  120874. };
  120875. }
  120876. declare module BABYLON {
  120877. /**
  120878. * The SharpenPostProcess applies a sharpen kernel to every pixel
  120879. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120880. */
  120881. export class SharpenPostProcess extends PostProcess {
  120882. /**
  120883. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  120884. */
  120885. colorAmount: number;
  120886. /**
  120887. * How much sharpness should be applied (default: 0.3)
  120888. */
  120889. edgeAmount: number;
  120890. /**
  120891. * Creates a new instance ConvolutionPostProcess
  120892. * @param name The name of the effect.
  120893. * @param options The required width/height ratio to downsize to before computing the render pass.
  120894. * @param camera The camera to apply the render pass to.
  120895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120896. * @param engine The engine which the post process will be applied. (default: current engine)
  120897. * @param reusable If the post process can be reused on the same frame. (default: false)
  120898. * @param textureType Type of textures used when performing the post process. (default: 0)
  120899. * @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)
  120900. */
  120901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120902. }
  120903. }
  120904. declare module BABYLON {
  120905. /**
  120906. * PostProcessRenderPipeline
  120907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120908. */
  120909. export class PostProcessRenderPipeline {
  120910. private engine;
  120911. private _renderEffects;
  120912. private _renderEffectsForIsolatedPass;
  120913. /**
  120914. * List of inspectable custom properties (used by the Inspector)
  120915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  120916. */
  120917. inspectableCustomProperties: IInspectable[];
  120918. /**
  120919. * @hidden
  120920. */
  120921. protected _cameras: Camera[];
  120922. /** @hidden */
  120923. _name: string;
  120924. /**
  120925. * Gets pipeline name
  120926. */
  120927. readonly name: string;
  120928. /**
  120929. * Initializes a PostProcessRenderPipeline
  120930. * @param engine engine to add the pipeline to
  120931. * @param name name of the pipeline
  120932. */
  120933. constructor(engine: Engine, name: string);
  120934. /**
  120935. * Gets the class name
  120936. * @returns "PostProcessRenderPipeline"
  120937. */
  120938. getClassName(): string;
  120939. /**
  120940. * If all the render effects in the pipeline are supported
  120941. */
  120942. readonly isSupported: boolean;
  120943. /**
  120944. * Adds an effect to the pipeline
  120945. * @param renderEffect the effect to add
  120946. */
  120947. addEffect(renderEffect: PostProcessRenderEffect): void;
  120948. /** @hidden */
  120949. _rebuild(): void;
  120950. /** @hidden */
  120951. _enableEffect(renderEffectName: string, cameras: Camera): void;
  120952. /** @hidden */
  120953. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  120954. /** @hidden */
  120955. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120956. /** @hidden */
  120957. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120958. /** @hidden */
  120959. _attachCameras(cameras: Camera, unique: boolean): void;
  120960. /** @hidden */
  120961. _attachCameras(cameras: Camera[], unique: boolean): void;
  120962. /** @hidden */
  120963. _detachCameras(cameras: Camera): void;
  120964. /** @hidden */
  120965. _detachCameras(cameras: Nullable<Camera[]>): void;
  120966. /** @hidden */
  120967. _update(): void;
  120968. /** @hidden */
  120969. _reset(): void;
  120970. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  120971. /**
  120972. * Disposes of the pipeline
  120973. */
  120974. dispose(): void;
  120975. }
  120976. }
  120977. declare module BABYLON {
  120978. /**
  120979. * PostProcessRenderPipelineManager class
  120980. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120981. */
  120982. export class PostProcessRenderPipelineManager {
  120983. private _renderPipelines;
  120984. /**
  120985. * Initializes a PostProcessRenderPipelineManager
  120986. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120987. */
  120988. constructor();
  120989. /**
  120990. * Gets the list of supported render pipelines
  120991. */
  120992. readonly supportedPipelines: PostProcessRenderPipeline[];
  120993. /**
  120994. * Adds a pipeline to the manager
  120995. * @param renderPipeline The pipeline to add
  120996. */
  120997. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  120998. /**
  120999. * Attaches a camera to the pipeline
  121000. * @param renderPipelineName The name of the pipeline to attach to
  121001. * @param cameras the camera to attach
  121002. * @param unique if the camera can be attached multiple times to the pipeline
  121003. */
  121004. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  121005. /**
  121006. * Detaches a camera from the pipeline
  121007. * @param renderPipelineName The name of the pipeline to detach from
  121008. * @param cameras the camera to detach
  121009. */
  121010. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  121011. /**
  121012. * Enables an effect by name on a pipeline
  121013. * @param renderPipelineName the name of the pipeline to enable the effect in
  121014. * @param renderEffectName the name of the effect to enable
  121015. * @param cameras the cameras that the effect should be enabled on
  121016. */
  121017. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121018. /**
  121019. * Disables an effect by name on a pipeline
  121020. * @param renderPipelineName the name of the pipeline to disable the effect in
  121021. * @param renderEffectName the name of the effect to disable
  121022. * @param cameras the cameras that the effect should be disabled on
  121023. */
  121024. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  121025. /**
  121026. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  121027. */
  121028. update(): void;
  121029. /** @hidden */
  121030. _rebuild(): void;
  121031. /**
  121032. * Disposes of the manager and pipelines
  121033. */
  121034. dispose(): void;
  121035. }
  121036. }
  121037. declare module BABYLON {
  121038. interface Scene {
  121039. /** @hidden (Backing field) */
  121040. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121041. /**
  121042. * Gets the postprocess render pipeline manager
  121043. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121044. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121045. */
  121046. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121047. }
  121048. /**
  121049. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121050. */
  121051. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121052. /**
  121053. * The component name helpfull to identify the component in the list of scene components.
  121054. */
  121055. readonly name: string;
  121056. /**
  121057. * The scene the component belongs to.
  121058. */
  121059. scene: Scene;
  121060. /**
  121061. * Creates a new instance of the component for the given scene
  121062. * @param scene Defines the scene to register the component in
  121063. */
  121064. constructor(scene: Scene);
  121065. /**
  121066. * Registers the component in a given scene
  121067. */
  121068. register(): void;
  121069. /**
  121070. * Rebuilds the elements related to this component in case of
  121071. * context lost for instance.
  121072. */
  121073. rebuild(): void;
  121074. /**
  121075. * Disposes the component and the associated ressources
  121076. */
  121077. dispose(): void;
  121078. private _gatherRenderTargets;
  121079. }
  121080. }
  121081. declare module BABYLON {
  121082. /**
  121083. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121084. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121085. */
  121086. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121087. private _scene;
  121088. private _camerasToBeAttached;
  121089. /**
  121090. * ID of the sharpen post process,
  121091. */
  121092. private readonly SharpenPostProcessId;
  121093. /**
  121094. * @ignore
  121095. * ID of the image processing post process;
  121096. */
  121097. readonly ImageProcessingPostProcessId: string;
  121098. /**
  121099. * @ignore
  121100. * ID of the Fast Approximate Anti-Aliasing post process;
  121101. */
  121102. readonly FxaaPostProcessId: string;
  121103. /**
  121104. * ID of the chromatic aberration post process,
  121105. */
  121106. private readonly ChromaticAberrationPostProcessId;
  121107. /**
  121108. * ID of the grain post process
  121109. */
  121110. private readonly GrainPostProcessId;
  121111. /**
  121112. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121113. */
  121114. sharpen: SharpenPostProcess;
  121115. private _sharpenEffect;
  121116. private bloom;
  121117. /**
  121118. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121119. */
  121120. depthOfField: DepthOfFieldEffect;
  121121. /**
  121122. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121123. */
  121124. fxaa: FxaaPostProcess;
  121125. /**
  121126. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121127. */
  121128. imageProcessing: ImageProcessingPostProcess;
  121129. /**
  121130. * Chromatic aberration post process which will shift rgb colors in the image
  121131. */
  121132. chromaticAberration: ChromaticAberrationPostProcess;
  121133. private _chromaticAberrationEffect;
  121134. /**
  121135. * Grain post process which add noise to the image
  121136. */
  121137. grain: GrainPostProcess;
  121138. private _grainEffect;
  121139. /**
  121140. * Glow post process which adds a glow to emissive areas of the image
  121141. */
  121142. private _glowLayer;
  121143. /**
  121144. * Animations which can be used to tweak settings over a period of time
  121145. */
  121146. animations: Animation[];
  121147. private _imageProcessingConfigurationObserver;
  121148. private _sharpenEnabled;
  121149. private _bloomEnabled;
  121150. private _depthOfFieldEnabled;
  121151. private _depthOfFieldBlurLevel;
  121152. private _fxaaEnabled;
  121153. private _imageProcessingEnabled;
  121154. private _defaultPipelineTextureType;
  121155. private _bloomScale;
  121156. private _chromaticAberrationEnabled;
  121157. private _grainEnabled;
  121158. private _buildAllowed;
  121159. /**
  121160. * Gets active scene
  121161. */
  121162. readonly scene: Scene;
  121163. /**
  121164. * Enable or disable the sharpen process from the pipeline
  121165. */
  121166. sharpenEnabled: boolean;
  121167. private _resizeObserver;
  121168. private _hardwareScaleLevel;
  121169. private _bloomKernel;
  121170. /**
  121171. * Specifies the size of the bloom blur kernel, relative to the final output size
  121172. */
  121173. bloomKernel: number;
  121174. /**
  121175. * Specifies the weight of the bloom in the final rendering
  121176. */
  121177. private _bloomWeight;
  121178. /**
  121179. * Specifies the luma threshold for the area that will be blurred by the bloom
  121180. */
  121181. private _bloomThreshold;
  121182. private _hdr;
  121183. /**
  121184. * The strength of the bloom.
  121185. */
  121186. bloomWeight: number;
  121187. /**
  121188. * The strength of the bloom.
  121189. */
  121190. bloomThreshold: number;
  121191. /**
  121192. * The scale of the bloom, lower value will provide better performance.
  121193. */
  121194. bloomScale: number;
  121195. /**
  121196. * Enable or disable the bloom from the pipeline
  121197. */
  121198. bloomEnabled: boolean;
  121199. private _rebuildBloom;
  121200. /**
  121201. * If the depth of field is enabled.
  121202. */
  121203. depthOfFieldEnabled: boolean;
  121204. /**
  121205. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121206. */
  121207. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121208. /**
  121209. * If the anti aliasing is enabled.
  121210. */
  121211. fxaaEnabled: boolean;
  121212. private _samples;
  121213. /**
  121214. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121215. */
  121216. samples: number;
  121217. /**
  121218. * If image processing is enabled.
  121219. */
  121220. imageProcessingEnabled: boolean;
  121221. /**
  121222. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121223. */
  121224. glowLayerEnabled: boolean;
  121225. /**
  121226. * Gets the glow layer (or null if not defined)
  121227. */
  121228. readonly glowLayer: Nullable<GlowLayer>;
  121229. /**
  121230. * Enable or disable the chromaticAberration process from the pipeline
  121231. */
  121232. chromaticAberrationEnabled: boolean;
  121233. /**
  121234. * Enable or disable the grain process from the pipeline
  121235. */
  121236. grainEnabled: boolean;
  121237. /**
  121238. * @constructor
  121239. * @param name - The rendering pipeline name (default: "")
  121240. * @param hdr - If high dynamic range textures should be used (default: true)
  121241. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121242. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121243. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121244. */
  121245. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121246. /**
  121247. * Get the class name
  121248. * @returns "DefaultRenderingPipeline"
  121249. */
  121250. getClassName(): string;
  121251. /**
  121252. * Force the compilation of the entire pipeline.
  121253. */
  121254. prepare(): void;
  121255. private _hasCleared;
  121256. private _prevPostProcess;
  121257. private _prevPrevPostProcess;
  121258. private _setAutoClearAndTextureSharing;
  121259. private _depthOfFieldSceneObserver;
  121260. private _buildPipeline;
  121261. private _disposePostProcesses;
  121262. /**
  121263. * Adds a camera to the pipeline
  121264. * @param camera the camera to be added
  121265. */
  121266. addCamera(camera: Camera): void;
  121267. /**
  121268. * Removes a camera from the pipeline
  121269. * @param camera the camera to remove
  121270. */
  121271. removeCamera(camera: Camera): void;
  121272. /**
  121273. * Dispose of the pipeline and stop all post processes
  121274. */
  121275. dispose(): void;
  121276. /**
  121277. * Serialize the rendering pipeline (Used when exporting)
  121278. * @returns the serialized object
  121279. */
  121280. serialize(): any;
  121281. /**
  121282. * Parse the serialized pipeline
  121283. * @param source Source pipeline.
  121284. * @param scene The scene to load the pipeline to.
  121285. * @param rootUrl The URL of the serialized pipeline.
  121286. * @returns An instantiated pipeline from the serialized object.
  121287. */
  121288. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121289. }
  121290. }
  121291. declare module BABYLON {
  121292. /** @hidden */
  121293. export var lensHighlightsPixelShader: {
  121294. name: string;
  121295. shader: string;
  121296. };
  121297. }
  121298. declare module BABYLON {
  121299. /** @hidden */
  121300. export var depthOfFieldPixelShader: {
  121301. name: string;
  121302. shader: string;
  121303. };
  121304. }
  121305. declare module BABYLON {
  121306. /**
  121307. * BABYLON.JS Chromatic Aberration GLSL Shader
  121308. * Author: Olivier Guyot
  121309. * Separates very slightly R, G and B colors on the edges of the screen
  121310. * Inspired by Francois Tarlier & Martins Upitis
  121311. */
  121312. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121313. /**
  121314. * @ignore
  121315. * The chromatic aberration PostProcess id in the pipeline
  121316. */
  121317. LensChromaticAberrationEffect: string;
  121318. /**
  121319. * @ignore
  121320. * The highlights enhancing PostProcess id in the pipeline
  121321. */
  121322. HighlightsEnhancingEffect: string;
  121323. /**
  121324. * @ignore
  121325. * The depth-of-field PostProcess id in the pipeline
  121326. */
  121327. LensDepthOfFieldEffect: string;
  121328. private _scene;
  121329. private _depthTexture;
  121330. private _grainTexture;
  121331. private _chromaticAberrationPostProcess;
  121332. private _highlightsPostProcess;
  121333. private _depthOfFieldPostProcess;
  121334. private _edgeBlur;
  121335. private _grainAmount;
  121336. private _chromaticAberration;
  121337. private _distortion;
  121338. private _highlightsGain;
  121339. private _highlightsThreshold;
  121340. private _dofDistance;
  121341. private _dofAperture;
  121342. private _dofDarken;
  121343. private _dofPentagon;
  121344. private _blurNoise;
  121345. /**
  121346. * @constructor
  121347. *
  121348. * Effect parameters are as follow:
  121349. * {
  121350. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121351. * edge_blur: number; // from 0 to x (1 for realism)
  121352. * distortion: number; // from 0 to x (1 for realism)
  121353. * grain_amount: number; // from 0 to 1
  121354. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121355. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121356. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121357. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121358. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121359. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121360. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121361. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121362. * }
  121363. * Note: if an effect parameter is unset, effect is disabled
  121364. *
  121365. * @param name The rendering pipeline name
  121366. * @param parameters - An object containing all parameters (see above)
  121367. * @param scene The scene linked to this pipeline
  121368. * @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)
  121369. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121370. */
  121371. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121372. /**
  121373. * Get the class name
  121374. * @returns "LensRenderingPipeline"
  121375. */
  121376. getClassName(): string;
  121377. /**
  121378. * Gets associated scene
  121379. */
  121380. readonly scene: Scene;
  121381. /**
  121382. * Gets or sets the edge blur
  121383. */
  121384. edgeBlur: number;
  121385. /**
  121386. * Gets or sets the grain amount
  121387. */
  121388. grainAmount: number;
  121389. /**
  121390. * Gets or sets the chromatic aberration amount
  121391. */
  121392. chromaticAberration: number;
  121393. /**
  121394. * Gets or sets the depth of field aperture
  121395. */
  121396. dofAperture: number;
  121397. /**
  121398. * Gets or sets the edge distortion
  121399. */
  121400. edgeDistortion: number;
  121401. /**
  121402. * Gets or sets the depth of field distortion
  121403. */
  121404. dofDistortion: number;
  121405. /**
  121406. * Gets or sets the darken out of focus amount
  121407. */
  121408. darkenOutOfFocus: number;
  121409. /**
  121410. * Gets or sets a boolean indicating if blur noise is enabled
  121411. */
  121412. blurNoise: boolean;
  121413. /**
  121414. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121415. */
  121416. pentagonBokeh: boolean;
  121417. /**
  121418. * Gets or sets the highlight grain amount
  121419. */
  121420. highlightsGain: number;
  121421. /**
  121422. * Gets or sets the highlight threshold
  121423. */
  121424. highlightsThreshold: number;
  121425. /**
  121426. * Sets the amount of blur at the edges
  121427. * @param amount blur amount
  121428. */
  121429. setEdgeBlur(amount: number): void;
  121430. /**
  121431. * Sets edge blur to 0
  121432. */
  121433. disableEdgeBlur(): void;
  121434. /**
  121435. * Sets the amout of grain
  121436. * @param amount Amount of grain
  121437. */
  121438. setGrainAmount(amount: number): void;
  121439. /**
  121440. * Set grain amount to 0
  121441. */
  121442. disableGrain(): void;
  121443. /**
  121444. * Sets the chromatic aberration amount
  121445. * @param amount amount of chromatic aberration
  121446. */
  121447. setChromaticAberration(amount: number): void;
  121448. /**
  121449. * Sets chromatic aberration amount to 0
  121450. */
  121451. disableChromaticAberration(): void;
  121452. /**
  121453. * Sets the EdgeDistortion amount
  121454. * @param amount amount of EdgeDistortion
  121455. */
  121456. setEdgeDistortion(amount: number): void;
  121457. /**
  121458. * Sets edge distortion to 0
  121459. */
  121460. disableEdgeDistortion(): void;
  121461. /**
  121462. * Sets the FocusDistance amount
  121463. * @param amount amount of FocusDistance
  121464. */
  121465. setFocusDistance(amount: number): void;
  121466. /**
  121467. * Disables depth of field
  121468. */
  121469. disableDepthOfField(): void;
  121470. /**
  121471. * Sets the Aperture amount
  121472. * @param amount amount of Aperture
  121473. */
  121474. setAperture(amount: number): void;
  121475. /**
  121476. * Sets the DarkenOutOfFocus amount
  121477. * @param amount amount of DarkenOutOfFocus
  121478. */
  121479. setDarkenOutOfFocus(amount: number): void;
  121480. private _pentagonBokehIsEnabled;
  121481. /**
  121482. * Creates a pentagon bokeh effect
  121483. */
  121484. enablePentagonBokeh(): void;
  121485. /**
  121486. * Disables the pentagon bokeh effect
  121487. */
  121488. disablePentagonBokeh(): void;
  121489. /**
  121490. * Enables noise blur
  121491. */
  121492. enableNoiseBlur(): void;
  121493. /**
  121494. * Disables noise blur
  121495. */
  121496. disableNoiseBlur(): void;
  121497. /**
  121498. * Sets the HighlightsGain amount
  121499. * @param amount amount of HighlightsGain
  121500. */
  121501. setHighlightsGain(amount: number): void;
  121502. /**
  121503. * Sets the HighlightsThreshold amount
  121504. * @param amount amount of HighlightsThreshold
  121505. */
  121506. setHighlightsThreshold(amount: number): void;
  121507. /**
  121508. * Disables highlights
  121509. */
  121510. disableHighlights(): void;
  121511. /**
  121512. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121513. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121514. */
  121515. dispose(disableDepthRender?: boolean): void;
  121516. private _createChromaticAberrationPostProcess;
  121517. private _createHighlightsPostProcess;
  121518. private _createDepthOfFieldPostProcess;
  121519. private _createGrainTexture;
  121520. }
  121521. }
  121522. declare module BABYLON {
  121523. /** @hidden */
  121524. export var ssao2PixelShader: {
  121525. name: string;
  121526. shader: string;
  121527. };
  121528. }
  121529. declare module BABYLON {
  121530. /** @hidden */
  121531. export var ssaoCombinePixelShader: {
  121532. name: string;
  121533. shader: string;
  121534. };
  121535. }
  121536. declare module BABYLON {
  121537. /**
  121538. * Render pipeline to produce ssao effect
  121539. */
  121540. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121541. /**
  121542. * @ignore
  121543. * The PassPostProcess id in the pipeline that contains the original scene color
  121544. */
  121545. SSAOOriginalSceneColorEffect: string;
  121546. /**
  121547. * @ignore
  121548. * The SSAO PostProcess id in the pipeline
  121549. */
  121550. SSAORenderEffect: string;
  121551. /**
  121552. * @ignore
  121553. * The horizontal blur PostProcess id in the pipeline
  121554. */
  121555. SSAOBlurHRenderEffect: string;
  121556. /**
  121557. * @ignore
  121558. * The vertical blur PostProcess id in the pipeline
  121559. */
  121560. SSAOBlurVRenderEffect: string;
  121561. /**
  121562. * @ignore
  121563. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121564. */
  121565. SSAOCombineRenderEffect: string;
  121566. /**
  121567. * The output strength of the SSAO post-process. Default value is 1.0.
  121568. */
  121569. totalStrength: number;
  121570. /**
  121571. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121572. */
  121573. maxZ: number;
  121574. /**
  121575. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121576. */
  121577. minZAspect: number;
  121578. private _samples;
  121579. /**
  121580. * Number of samples used for the SSAO calculations. Default value is 8
  121581. */
  121582. samples: number;
  121583. private _textureSamples;
  121584. /**
  121585. * Number of samples to use for antialiasing
  121586. */
  121587. textureSamples: number;
  121588. /**
  121589. * Ratio object used for SSAO ratio and blur ratio
  121590. */
  121591. private _ratio;
  121592. /**
  121593. * Dynamically generated sphere sampler.
  121594. */
  121595. private _sampleSphere;
  121596. /**
  121597. * Blur filter offsets
  121598. */
  121599. private _samplerOffsets;
  121600. private _expensiveBlur;
  121601. /**
  121602. * If bilateral blur should be used
  121603. */
  121604. expensiveBlur: boolean;
  121605. /**
  121606. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121607. */
  121608. radius: number;
  121609. /**
  121610. * The base color of the SSAO post-process
  121611. * The final result is "base + ssao" between [0, 1]
  121612. */
  121613. base: number;
  121614. /**
  121615. * Support test.
  121616. */
  121617. static readonly IsSupported: boolean;
  121618. private _scene;
  121619. private _depthTexture;
  121620. private _normalTexture;
  121621. private _randomTexture;
  121622. private _originalColorPostProcess;
  121623. private _ssaoPostProcess;
  121624. private _blurHPostProcess;
  121625. private _blurVPostProcess;
  121626. private _ssaoCombinePostProcess;
  121627. private _firstUpdate;
  121628. /**
  121629. * Gets active scene
  121630. */
  121631. readonly scene: Scene;
  121632. /**
  121633. * @constructor
  121634. * @param name The rendering pipeline name
  121635. * @param scene The scene linked to this pipeline
  121636. * @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 }
  121637. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121638. */
  121639. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121640. /**
  121641. * Get the class name
  121642. * @returns "SSAO2RenderingPipeline"
  121643. */
  121644. getClassName(): string;
  121645. /**
  121646. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121647. */
  121648. dispose(disableGeometryBufferRenderer?: boolean): void;
  121649. private _createBlurPostProcess;
  121650. /** @hidden */
  121651. _rebuild(): void;
  121652. private _bits;
  121653. private _radicalInverse_VdC;
  121654. private _hammersley;
  121655. private _hemisphereSample_uniform;
  121656. private _generateHemisphere;
  121657. private _createSSAOPostProcess;
  121658. private _createSSAOCombinePostProcess;
  121659. private _createRandomTexture;
  121660. /**
  121661. * Serialize the rendering pipeline (Used when exporting)
  121662. * @returns the serialized object
  121663. */
  121664. serialize(): any;
  121665. /**
  121666. * Parse the serialized pipeline
  121667. * @param source Source pipeline.
  121668. * @param scene The scene to load the pipeline to.
  121669. * @param rootUrl The URL of the serialized pipeline.
  121670. * @returns An instantiated pipeline from the serialized object.
  121671. */
  121672. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  121673. }
  121674. }
  121675. declare module BABYLON {
  121676. /** @hidden */
  121677. export var ssaoPixelShader: {
  121678. name: string;
  121679. shader: string;
  121680. };
  121681. }
  121682. declare module BABYLON {
  121683. /**
  121684. * Render pipeline to produce ssao effect
  121685. */
  121686. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  121687. /**
  121688. * @ignore
  121689. * The PassPostProcess id in the pipeline that contains the original scene color
  121690. */
  121691. SSAOOriginalSceneColorEffect: string;
  121692. /**
  121693. * @ignore
  121694. * The SSAO PostProcess id in the pipeline
  121695. */
  121696. SSAORenderEffect: string;
  121697. /**
  121698. * @ignore
  121699. * The horizontal blur PostProcess id in the pipeline
  121700. */
  121701. SSAOBlurHRenderEffect: string;
  121702. /**
  121703. * @ignore
  121704. * The vertical blur PostProcess id in the pipeline
  121705. */
  121706. SSAOBlurVRenderEffect: string;
  121707. /**
  121708. * @ignore
  121709. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121710. */
  121711. SSAOCombineRenderEffect: string;
  121712. /**
  121713. * The output strength of the SSAO post-process. Default value is 1.0.
  121714. */
  121715. totalStrength: number;
  121716. /**
  121717. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  121718. */
  121719. radius: number;
  121720. /**
  121721. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  121722. * Must not be equal to fallOff and superior to fallOff.
  121723. * Default value is 0.0075
  121724. */
  121725. area: number;
  121726. /**
  121727. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  121728. * Must not be equal to area and inferior to area.
  121729. * Default value is 0.000001
  121730. */
  121731. fallOff: number;
  121732. /**
  121733. * The base color of the SSAO post-process
  121734. * The final result is "base + ssao" between [0, 1]
  121735. */
  121736. base: number;
  121737. private _scene;
  121738. private _depthTexture;
  121739. private _randomTexture;
  121740. private _originalColorPostProcess;
  121741. private _ssaoPostProcess;
  121742. private _blurHPostProcess;
  121743. private _blurVPostProcess;
  121744. private _ssaoCombinePostProcess;
  121745. private _firstUpdate;
  121746. /**
  121747. * Gets active scene
  121748. */
  121749. readonly scene: Scene;
  121750. /**
  121751. * @constructor
  121752. * @param name - The rendering pipeline name
  121753. * @param scene - The scene linked to this pipeline
  121754. * @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 }
  121755. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  121756. */
  121757. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121758. /**
  121759. * Get the class name
  121760. * @returns "SSAORenderingPipeline"
  121761. */
  121762. getClassName(): string;
  121763. /**
  121764. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121765. */
  121766. dispose(disableDepthRender?: boolean): void;
  121767. private _createBlurPostProcess;
  121768. /** @hidden */
  121769. _rebuild(): void;
  121770. private _createSSAOPostProcess;
  121771. private _createSSAOCombinePostProcess;
  121772. private _createRandomTexture;
  121773. }
  121774. }
  121775. declare module BABYLON {
  121776. /** @hidden */
  121777. export var standardPixelShader: {
  121778. name: string;
  121779. shader: string;
  121780. };
  121781. }
  121782. declare module BABYLON {
  121783. /**
  121784. * Standard rendering pipeline
  121785. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121786. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  121787. */
  121788. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121789. /**
  121790. * Public members
  121791. */
  121792. /**
  121793. * Post-process which contains the original scene color before the pipeline applies all the effects
  121794. */
  121795. originalPostProcess: Nullable<PostProcess>;
  121796. /**
  121797. * Post-process used to down scale an image x4
  121798. */
  121799. downSampleX4PostProcess: Nullable<PostProcess>;
  121800. /**
  121801. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  121802. */
  121803. brightPassPostProcess: Nullable<PostProcess>;
  121804. /**
  121805. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  121806. */
  121807. blurHPostProcesses: PostProcess[];
  121808. /**
  121809. * Post-process array storing all the vertical blur post-processes used by the pipeline
  121810. */
  121811. blurVPostProcesses: PostProcess[];
  121812. /**
  121813. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  121814. */
  121815. textureAdderPostProcess: Nullable<PostProcess>;
  121816. /**
  121817. * Post-process used to create volumetric lighting effect
  121818. */
  121819. volumetricLightPostProcess: Nullable<PostProcess>;
  121820. /**
  121821. * Post-process used to smooth the previous volumetric light post-process on the X axis
  121822. */
  121823. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  121824. /**
  121825. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  121826. */
  121827. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  121828. /**
  121829. * Post-process used to merge the volumetric light effect and the real scene color
  121830. */
  121831. volumetricLightMergePostProces: Nullable<PostProcess>;
  121832. /**
  121833. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  121834. */
  121835. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  121836. /**
  121837. * Base post-process used to calculate the average luminance of the final image for HDR
  121838. */
  121839. luminancePostProcess: Nullable<PostProcess>;
  121840. /**
  121841. * Post-processes used to create down sample post-processes in order to get
  121842. * the average luminance of the final image for HDR
  121843. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  121844. */
  121845. luminanceDownSamplePostProcesses: PostProcess[];
  121846. /**
  121847. * Post-process used to create a HDR effect (light adaptation)
  121848. */
  121849. hdrPostProcess: Nullable<PostProcess>;
  121850. /**
  121851. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  121852. */
  121853. textureAdderFinalPostProcess: Nullable<PostProcess>;
  121854. /**
  121855. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  121856. */
  121857. lensFlareFinalPostProcess: Nullable<PostProcess>;
  121858. /**
  121859. * Post-process used to merge the final HDR post-process and the real scene color
  121860. */
  121861. hdrFinalPostProcess: Nullable<PostProcess>;
  121862. /**
  121863. * Post-process used to create a lens flare effect
  121864. */
  121865. lensFlarePostProcess: Nullable<PostProcess>;
  121866. /**
  121867. * Post-process that merges the result of the lens flare post-process and the real scene color
  121868. */
  121869. lensFlareComposePostProcess: Nullable<PostProcess>;
  121870. /**
  121871. * Post-process used to create a motion blur effect
  121872. */
  121873. motionBlurPostProcess: Nullable<PostProcess>;
  121874. /**
  121875. * Post-process used to create a depth of field effect
  121876. */
  121877. depthOfFieldPostProcess: Nullable<PostProcess>;
  121878. /**
  121879. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121880. */
  121881. fxaaPostProcess: Nullable<FxaaPostProcess>;
  121882. /**
  121883. * Represents the brightness threshold in order to configure the illuminated surfaces
  121884. */
  121885. brightThreshold: number;
  121886. /**
  121887. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  121888. */
  121889. blurWidth: number;
  121890. /**
  121891. * Sets if the blur for highlighted surfaces must be only horizontal
  121892. */
  121893. horizontalBlur: boolean;
  121894. /**
  121895. * Gets the overall exposure used by the pipeline
  121896. */
  121897. /**
  121898. * Sets the overall exposure used by the pipeline
  121899. */
  121900. exposure: number;
  121901. /**
  121902. * Texture used typically to simulate "dirty" on camera lens
  121903. */
  121904. lensTexture: Nullable<Texture>;
  121905. /**
  121906. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  121907. */
  121908. volumetricLightCoefficient: number;
  121909. /**
  121910. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  121911. */
  121912. volumetricLightPower: number;
  121913. /**
  121914. * Used the set the blur intensity to smooth the volumetric lights
  121915. */
  121916. volumetricLightBlurScale: number;
  121917. /**
  121918. * Light (spot or directional) used to generate the volumetric lights rays
  121919. * The source light must have a shadow generate so the pipeline can get its
  121920. * depth map
  121921. */
  121922. sourceLight: Nullable<SpotLight | DirectionalLight>;
  121923. /**
  121924. * For eye adaptation, represents the minimum luminance the eye can see
  121925. */
  121926. hdrMinimumLuminance: number;
  121927. /**
  121928. * For eye adaptation, represents the decrease luminance speed
  121929. */
  121930. hdrDecreaseRate: number;
  121931. /**
  121932. * For eye adaptation, represents the increase luminance speed
  121933. */
  121934. hdrIncreaseRate: number;
  121935. /**
  121936. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121937. */
  121938. /**
  121939. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121940. */
  121941. hdrAutoExposure: boolean;
  121942. /**
  121943. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  121944. */
  121945. lensColorTexture: Nullable<Texture>;
  121946. /**
  121947. * The overall strengh for the lens flare effect
  121948. */
  121949. lensFlareStrength: number;
  121950. /**
  121951. * Dispersion coefficient for lens flare ghosts
  121952. */
  121953. lensFlareGhostDispersal: number;
  121954. /**
  121955. * Main lens flare halo width
  121956. */
  121957. lensFlareHaloWidth: number;
  121958. /**
  121959. * Based on the lens distortion effect, defines how much the lens flare result
  121960. * is distorted
  121961. */
  121962. lensFlareDistortionStrength: number;
  121963. /**
  121964. * Lens star texture must be used to simulate rays on the flares and is available
  121965. * in the documentation
  121966. */
  121967. lensStarTexture: Nullable<Texture>;
  121968. /**
  121969. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  121970. * flare effect by taking account of the dirt texture
  121971. */
  121972. lensFlareDirtTexture: Nullable<Texture>;
  121973. /**
  121974. * Represents the focal length for the depth of field effect
  121975. */
  121976. depthOfFieldDistance: number;
  121977. /**
  121978. * Represents the blur intensity for the blurred part of the depth of field effect
  121979. */
  121980. depthOfFieldBlurWidth: number;
  121981. /**
  121982. * Gets how much the image is blurred by the movement while using the motion blur post-process
  121983. */
  121984. /**
  121985. * Sets how much the image is blurred by the movement while using the motion blur post-process
  121986. */
  121987. motionStrength: number;
  121988. /**
  121989. * Gets wether or not the motion blur post-process is object based or screen based.
  121990. */
  121991. /**
  121992. * Sets wether or not the motion blur post-process should be object based or screen based
  121993. */
  121994. objectBasedMotionBlur: boolean;
  121995. /**
  121996. * List of animations for the pipeline (IAnimatable implementation)
  121997. */
  121998. animations: Animation[];
  121999. /**
  122000. * Private members
  122001. */
  122002. private _scene;
  122003. private _currentDepthOfFieldSource;
  122004. private _basePostProcess;
  122005. private _fixedExposure;
  122006. private _currentExposure;
  122007. private _hdrAutoExposure;
  122008. private _hdrCurrentLuminance;
  122009. private _motionStrength;
  122010. private _isObjectBasedMotionBlur;
  122011. private _floatTextureType;
  122012. private _ratio;
  122013. private _bloomEnabled;
  122014. private _depthOfFieldEnabled;
  122015. private _vlsEnabled;
  122016. private _lensFlareEnabled;
  122017. private _hdrEnabled;
  122018. private _motionBlurEnabled;
  122019. private _fxaaEnabled;
  122020. private _motionBlurSamples;
  122021. private _volumetricLightStepsCount;
  122022. private _samples;
  122023. /**
  122024. * @ignore
  122025. * Specifies if the bloom pipeline is enabled
  122026. */
  122027. BloomEnabled: boolean;
  122028. /**
  122029. * @ignore
  122030. * Specifies if the depth of field pipeline is enabed
  122031. */
  122032. DepthOfFieldEnabled: boolean;
  122033. /**
  122034. * @ignore
  122035. * Specifies if the lens flare pipeline is enabed
  122036. */
  122037. LensFlareEnabled: boolean;
  122038. /**
  122039. * @ignore
  122040. * Specifies if the HDR pipeline is enabled
  122041. */
  122042. HDREnabled: boolean;
  122043. /**
  122044. * @ignore
  122045. * Specifies if the volumetric lights scattering effect is enabled
  122046. */
  122047. VLSEnabled: boolean;
  122048. /**
  122049. * @ignore
  122050. * Specifies if the motion blur effect is enabled
  122051. */
  122052. MotionBlurEnabled: boolean;
  122053. /**
  122054. * Specifies if anti-aliasing is enabled
  122055. */
  122056. fxaaEnabled: boolean;
  122057. /**
  122058. * Specifies the number of steps used to calculate the volumetric lights
  122059. * Typically in interval [50, 200]
  122060. */
  122061. volumetricLightStepsCount: number;
  122062. /**
  122063. * Specifies the number of samples used for the motion blur effect
  122064. * Typically in interval [16, 64]
  122065. */
  122066. motionBlurSamples: number;
  122067. /**
  122068. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122069. */
  122070. samples: number;
  122071. /**
  122072. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122073. * @constructor
  122074. * @param name The rendering pipeline name
  122075. * @param scene The scene linked to this pipeline
  122076. * @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)
  122077. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122078. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122079. */
  122080. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122081. private _buildPipeline;
  122082. private _createDownSampleX4PostProcess;
  122083. private _createBrightPassPostProcess;
  122084. private _createBlurPostProcesses;
  122085. private _createTextureAdderPostProcess;
  122086. private _createVolumetricLightPostProcess;
  122087. private _createLuminancePostProcesses;
  122088. private _createHdrPostProcess;
  122089. private _createLensFlarePostProcess;
  122090. private _createDepthOfFieldPostProcess;
  122091. private _createMotionBlurPostProcess;
  122092. private _getDepthTexture;
  122093. private _disposePostProcesses;
  122094. /**
  122095. * Dispose of the pipeline and stop all post processes
  122096. */
  122097. dispose(): void;
  122098. /**
  122099. * Serialize the rendering pipeline (Used when exporting)
  122100. * @returns the serialized object
  122101. */
  122102. serialize(): any;
  122103. /**
  122104. * Parse the serialized pipeline
  122105. * @param source Source pipeline.
  122106. * @param scene The scene to load the pipeline to.
  122107. * @param rootUrl The URL of the serialized pipeline.
  122108. * @returns An instantiated pipeline from the serialized object.
  122109. */
  122110. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122111. /**
  122112. * Luminance steps
  122113. */
  122114. static LuminanceSteps: number;
  122115. }
  122116. }
  122117. declare module BABYLON {
  122118. /** @hidden */
  122119. export var tonemapPixelShader: {
  122120. name: string;
  122121. shader: string;
  122122. };
  122123. }
  122124. declare module BABYLON {
  122125. /** Defines operator used for tonemapping */
  122126. export enum TonemappingOperator {
  122127. /** Hable */
  122128. Hable = 0,
  122129. /** Reinhard */
  122130. Reinhard = 1,
  122131. /** HejiDawson */
  122132. HejiDawson = 2,
  122133. /** Photographic */
  122134. Photographic = 3
  122135. }
  122136. /**
  122137. * Defines a post process to apply tone mapping
  122138. */
  122139. export class TonemapPostProcess extends PostProcess {
  122140. private _operator;
  122141. /** Defines the required exposure adjustement */
  122142. exposureAdjustment: number;
  122143. /**
  122144. * Creates a new TonemapPostProcess
  122145. * @param name defines the name of the postprocess
  122146. * @param _operator defines the operator to use
  122147. * @param exposureAdjustment defines the required exposure adjustement
  122148. * @param camera defines the camera to use (can be null)
  122149. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122150. * @param engine defines the hosting engine (can be ignore if camera is set)
  122151. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122152. */
  122153. constructor(name: string, _operator: TonemappingOperator,
  122154. /** Defines the required exposure adjustement */
  122155. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122156. }
  122157. }
  122158. declare module BABYLON {
  122159. /** @hidden */
  122160. export var depthVertexShader: {
  122161. name: string;
  122162. shader: string;
  122163. };
  122164. }
  122165. declare module BABYLON {
  122166. /** @hidden */
  122167. export var volumetricLightScatteringPixelShader: {
  122168. name: string;
  122169. shader: string;
  122170. };
  122171. }
  122172. declare module BABYLON {
  122173. /** @hidden */
  122174. export var volumetricLightScatteringPassPixelShader: {
  122175. name: string;
  122176. shader: string;
  122177. };
  122178. }
  122179. declare module BABYLON {
  122180. /**
  122181. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  122182. */
  122183. export class VolumetricLightScatteringPostProcess extends PostProcess {
  122184. private _volumetricLightScatteringPass;
  122185. private _volumetricLightScatteringRTT;
  122186. private _viewPort;
  122187. private _screenCoordinates;
  122188. private _cachedDefines;
  122189. /**
  122190. * If not undefined, the mesh position is computed from the attached node position
  122191. */
  122192. attachedNode: {
  122193. position: Vector3;
  122194. };
  122195. /**
  122196. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122197. */
  122198. customMeshPosition: Vector3;
  122199. /**
  122200. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122201. */
  122202. useCustomMeshPosition: boolean;
  122203. /**
  122204. * If the post-process should inverse the light scattering direction
  122205. */
  122206. invert: boolean;
  122207. /**
  122208. * The internal mesh used by the post-process
  122209. */
  122210. mesh: Mesh;
  122211. /**
  122212. * @hidden
  122213. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122214. */
  122215. useDiffuseColor: boolean;
  122216. /**
  122217. * Array containing the excluded meshes not rendered in the internal pass
  122218. */
  122219. excludedMeshes: AbstractMesh[];
  122220. /**
  122221. * Controls the overall intensity of the post-process
  122222. */
  122223. exposure: number;
  122224. /**
  122225. * Dissipates each sample's contribution in range [0, 1]
  122226. */
  122227. decay: number;
  122228. /**
  122229. * Controls the overall intensity of each sample
  122230. */
  122231. weight: number;
  122232. /**
  122233. * Controls the density of each sample
  122234. */
  122235. density: number;
  122236. /**
  122237. * @constructor
  122238. * @param name The post-process name
  122239. * @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)
  122240. * @param camera The camera that the post-process will be attached to
  122241. * @param mesh The mesh used to create the light scattering
  122242. * @param samples The post-process quality, default 100
  122243. * @param samplingModeThe post-process filtering mode
  122244. * @param engine The babylon engine
  122245. * @param reusable If the post-process is reusable
  122246. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122247. */
  122248. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122249. /**
  122250. * Returns the string "VolumetricLightScatteringPostProcess"
  122251. * @returns "VolumetricLightScatteringPostProcess"
  122252. */
  122253. getClassName(): string;
  122254. private _isReady;
  122255. /**
  122256. * Sets the new light position for light scattering effect
  122257. * @param position The new custom light position
  122258. */
  122259. setCustomMeshPosition(position: Vector3): void;
  122260. /**
  122261. * Returns the light position for light scattering effect
  122262. * @return Vector3 The custom light position
  122263. */
  122264. getCustomMeshPosition(): Vector3;
  122265. /**
  122266. * Disposes the internal assets and detaches the post-process from the camera
  122267. */
  122268. dispose(camera: Camera): void;
  122269. /**
  122270. * Returns the render target texture used by the post-process
  122271. * @return the render target texture used by the post-process
  122272. */
  122273. getPass(): RenderTargetTexture;
  122274. private _meshExcluded;
  122275. private _createPass;
  122276. private _updateMeshScreenCoordinates;
  122277. /**
  122278. * Creates a default mesh for the Volumeric Light Scattering post-process
  122279. * @param name The mesh name
  122280. * @param scene The scene where to create the mesh
  122281. * @return the default mesh
  122282. */
  122283. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122284. }
  122285. }
  122286. declare module BABYLON {
  122287. interface Scene {
  122288. /** @hidden (Backing field) */
  122289. _boundingBoxRenderer: BoundingBoxRenderer;
  122290. /** @hidden (Backing field) */
  122291. _forceShowBoundingBoxes: boolean;
  122292. /**
  122293. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122294. */
  122295. forceShowBoundingBoxes: boolean;
  122296. /**
  122297. * Gets the bounding box renderer associated with the scene
  122298. * @returns a BoundingBoxRenderer
  122299. */
  122300. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122301. }
  122302. interface AbstractMesh {
  122303. /** @hidden (Backing field) */
  122304. _showBoundingBox: boolean;
  122305. /**
  122306. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122307. */
  122308. showBoundingBox: boolean;
  122309. }
  122310. /**
  122311. * Component responsible of rendering the bounding box of the meshes in a scene.
  122312. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122313. */
  122314. export class BoundingBoxRenderer implements ISceneComponent {
  122315. /**
  122316. * The component name helpfull to identify the component in the list of scene components.
  122317. */
  122318. readonly name: string;
  122319. /**
  122320. * The scene the component belongs to.
  122321. */
  122322. scene: Scene;
  122323. /**
  122324. * Color of the bounding box lines placed in front of an object
  122325. */
  122326. frontColor: Color3;
  122327. /**
  122328. * Color of the bounding box lines placed behind an object
  122329. */
  122330. backColor: Color3;
  122331. /**
  122332. * Defines if the renderer should show the back lines or not
  122333. */
  122334. showBackLines: boolean;
  122335. /**
  122336. * @hidden
  122337. */
  122338. renderList: SmartArray<BoundingBox>;
  122339. private _colorShader;
  122340. private _vertexBuffers;
  122341. private _indexBuffer;
  122342. private _fillIndexBuffer;
  122343. private _fillIndexData;
  122344. /**
  122345. * Instantiates a new bounding box renderer in a scene.
  122346. * @param scene the scene the renderer renders in
  122347. */
  122348. constructor(scene: Scene);
  122349. /**
  122350. * Registers the component in a given scene
  122351. */
  122352. register(): void;
  122353. private _evaluateSubMesh;
  122354. private _activeMesh;
  122355. private _prepareRessources;
  122356. private _createIndexBuffer;
  122357. /**
  122358. * Rebuilds the elements related to this component in case of
  122359. * context lost for instance.
  122360. */
  122361. rebuild(): void;
  122362. /**
  122363. * @hidden
  122364. */
  122365. reset(): void;
  122366. /**
  122367. * Render the bounding boxes of a specific rendering group
  122368. * @param renderingGroupId defines the rendering group to render
  122369. */
  122370. render(renderingGroupId: number): void;
  122371. /**
  122372. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122373. * @param mesh Define the mesh to render the occlusion bounding box for
  122374. */
  122375. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122376. /**
  122377. * Dispose and release the resources attached to this renderer.
  122378. */
  122379. dispose(): void;
  122380. }
  122381. }
  122382. declare module BABYLON {
  122383. /** @hidden */
  122384. export var depthPixelShader: {
  122385. name: string;
  122386. shader: string;
  122387. };
  122388. }
  122389. declare module BABYLON {
  122390. /**
  122391. * This represents a depth renderer in Babylon.
  122392. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122393. */
  122394. export class DepthRenderer {
  122395. private _scene;
  122396. private _depthMap;
  122397. private _effect;
  122398. private readonly _storeNonLinearDepth;
  122399. private readonly _clearColor;
  122400. /** Get if the depth renderer is using packed depth or not */
  122401. readonly isPacked: boolean;
  122402. private _cachedDefines;
  122403. private _camera;
  122404. /**
  122405. * Specifiess that the depth renderer will only be used within
  122406. * the camera it is created for.
  122407. * This can help forcing its rendering during the camera processing.
  122408. */
  122409. useOnlyInActiveCamera: boolean;
  122410. /** @hidden */
  122411. static _SceneComponentInitialization: (scene: Scene) => void;
  122412. /**
  122413. * Instantiates a depth renderer
  122414. * @param scene The scene the renderer belongs to
  122415. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122416. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122417. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122418. */
  122419. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122420. /**
  122421. * Creates the depth rendering effect and checks if the effect is ready.
  122422. * @param subMesh The submesh to be used to render the depth map of
  122423. * @param useInstances If multiple world instances should be used
  122424. * @returns if the depth renderer is ready to render the depth map
  122425. */
  122426. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122427. /**
  122428. * Gets the texture which the depth map will be written to.
  122429. * @returns The depth map texture
  122430. */
  122431. getDepthMap(): RenderTargetTexture;
  122432. /**
  122433. * Disposes of the depth renderer.
  122434. */
  122435. dispose(): void;
  122436. }
  122437. }
  122438. declare module BABYLON {
  122439. interface Scene {
  122440. /** @hidden (Backing field) */
  122441. _depthRenderer: {
  122442. [id: string]: DepthRenderer;
  122443. };
  122444. /**
  122445. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122446. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122447. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122448. * @returns the created depth renderer
  122449. */
  122450. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122451. /**
  122452. * Disables a depth renderer for a given camera
  122453. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122454. */
  122455. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122456. }
  122457. /**
  122458. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122459. * in several rendering techniques.
  122460. */
  122461. export class DepthRendererSceneComponent implements ISceneComponent {
  122462. /**
  122463. * The component name helpfull to identify the component in the list of scene components.
  122464. */
  122465. readonly name: string;
  122466. /**
  122467. * The scene the component belongs to.
  122468. */
  122469. scene: Scene;
  122470. /**
  122471. * Creates a new instance of the component for the given scene
  122472. * @param scene Defines the scene to register the component in
  122473. */
  122474. constructor(scene: Scene);
  122475. /**
  122476. * Registers the component in a given scene
  122477. */
  122478. register(): void;
  122479. /**
  122480. * Rebuilds the elements related to this component in case of
  122481. * context lost for instance.
  122482. */
  122483. rebuild(): void;
  122484. /**
  122485. * Disposes the component and the associated ressources
  122486. */
  122487. dispose(): void;
  122488. private _gatherRenderTargets;
  122489. private _gatherActiveCameraRenderTargets;
  122490. }
  122491. }
  122492. declare module BABYLON {
  122493. /** @hidden */
  122494. export var outlinePixelShader: {
  122495. name: string;
  122496. shader: string;
  122497. };
  122498. }
  122499. declare module BABYLON {
  122500. /** @hidden */
  122501. export var outlineVertexShader: {
  122502. name: string;
  122503. shader: string;
  122504. };
  122505. }
  122506. declare module BABYLON {
  122507. interface Scene {
  122508. /** @hidden */
  122509. _outlineRenderer: OutlineRenderer;
  122510. /**
  122511. * Gets the outline renderer associated with the scene
  122512. * @returns a OutlineRenderer
  122513. */
  122514. getOutlineRenderer(): OutlineRenderer;
  122515. }
  122516. interface AbstractMesh {
  122517. /** @hidden (Backing field) */
  122518. _renderOutline: boolean;
  122519. /**
  122520. * Gets or sets a boolean indicating if the outline must be rendered as well
  122521. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122522. */
  122523. renderOutline: boolean;
  122524. /** @hidden (Backing field) */
  122525. _renderOverlay: boolean;
  122526. /**
  122527. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122528. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122529. */
  122530. renderOverlay: boolean;
  122531. }
  122532. /**
  122533. * This class is responsible to draw bothe outline/overlay of meshes.
  122534. * It should not be used directly but through the available method on mesh.
  122535. */
  122536. export class OutlineRenderer implements ISceneComponent {
  122537. /**
  122538. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122539. */
  122540. private static _StencilReference;
  122541. /**
  122542. * The name of the component. Each component must have a unique name.
  122543. */
  122544. name: string;
  122545. /**
  122546. * The scene the component belongs to.
  122547. */
  122548. scene: Scene;
  122549. /**
  122550. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122551. */
  122552. zOffset: number;
  122553. private _engine;
  122554. private _effect;
  122555. private _cachedDefines;
  122556. private _savedDepthWrite;
  122557. /**
  122558. * Instantiates a new outline renderer. (There could be only one per scene).
  122559. * @param scene Defines the scene it belongs to
  122560. */
  122561. constructor(scene: Scene);
  122562. /**
  122563. * Register the component to one instance of a scene.
  122564. */
  122565. register(): void;
  122566. /**
  122567. * Rebuilds the elements related to this component in case of
  122568. * context lost for instance.
  122569. */
  122570. rebuild(): void;
  122571. /**
  122572. * Disposes the component and the associated ressources.
  122573. */
  122574. dispose(): void;
  122575. /**
  122576. * Renders the outline in the canvas.
  122577. * @param subMesh Defines the sumesh to render
  122578. * @param batch Defines the batch of meshes in case of instances
  122579. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122580. */
  122581. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122582. /**
  122583. * Returns whether or not the outline renderer is ready for a given submesh.
  122584. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122585. * @param subMesh Defines the submesh to check readyness for
  122586. * @param useInstances Defines wheter wee are trying to render instances or not
  122587. * @returns true if ready otherwise false
  122588. */
  122589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122590. private _beforeRenderingMesh;
  122591. private _afterRenderingMesh;
  122592. }
  122593. }
  122594. declare module BABYLON {
  122595. /**
  122596. * Defines the list of states available for a task inside a AssetsManager
  122597. */
  122598. export enum AssetTaskState {
  122599. /**
  122600. * Initialization
  122601. */
  122602. INIT = 0,
  122603. /**
  122604. * Running
  122605. */
  122606. RUNNING = 1,
  122607. /**
  122608. * Done
  122609. */
  122610. DONE = 2,
  122611. /**
  122612. * Error
  122613. */
  122614. ERROR = 3
  122615. }
  122616. /**
  122617. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122618. */
  122619. export abstract class AbstractAssetTask {
  122620. /**
  122621. * Task name
  122622. */ name: string;
  122623. /**
  122624. * Callback called when the task is successful
  122625. */
  122626. onSuccess: (task: any) => void;
  122627. /**
  122628. * Callback called when the task is not successful
  122629. */
  122630. onError: (task: any, message?: string, exception?: any) => void;
  122631. /**
  122632. * Creates a new AssetsManager
  122633. * @param name defines the name of the task
  122634. */
  122635. constructor(
  122636. /**
  122637. * Task name
  122638. */ name: string);
  122639. private _isCompleted;
  122640. private _taskState;
  122641. private _errorObject;
  122642. /**
  122643. * Get if the task is completed
  122644. */
  122645. readonly isCompleted: boolean;
  122646. /**
  122647. * Gets the current state of the task
  122648. */
  122649. readonly taskState: AssetTaskState;
  122650. /**
  122651. * Gets the current error object (if task is in error)
  122652. */
  122653. readonly errorObject: {
  122654. message?: string;
  122655. exception?: any;
  122656. };
  122657. /**
  122658. * Internal only
  122659. * @hidden
  122660. */
  122661. _setErrorObject(message?: string, exception?: any): void;
  122662. /**
  122663. * Execute the current task
  122664. * @param scene defines the scene where you want your assets to be loaded
  122665. * @param onSuccess is a callback called when the task is successfully executed
  122666. * @param onError is a callback called if an error occurs
  122667. */
  122668. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122669. /**
  122670. * Execute the current task
  122671. * @param scene defines the scene where you want your assets to be loaded
  122672. * @param onSuccess is a callback called when the task is successfully executed
  122673. * @param onError is a callback called if an error occurs
  122674. */
  122675. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122676. /**
  122677. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  122678. * This can be used with failed tasks that have the reason for failure fixed.
  122679. */
  122680. reset(): void;
  122681. private onErrorCallback;
  122682. private onDoneCallback;
  122683. }
  122684. /**
  122685. * Define the interface used by progress events raised during assets loading
  122686. */
  122687. export interface IAssetsProgressEvent {
  122688. /**
  122689. * Defines the number of remaining tasks to process
  122690. */
  122691. remainingCount: number;
  122692. /**
  122693. * Defines the total number of tasks
  122694. */
  122695. totalCount: number;
  122696. /**
  122697. * Defines the task that was just processed
  122698. */
  122699. task: AbstractAssetTask;
  122700. }
  122701. /**
  122702. * Class used to share progress information about assets loading
  122703. */
  122704. export class AssetsProgressEvent implements IAssetsProgressEvent {
  122705. /**
  122706. * Defines the number of remaining tasks to process
  122707. */
  122708. remainingCount: number;
  122709. /**
  122710. * Defines the total number of tasks
  122711. */
  122712. totalCount: number;
  122713. /**
  122714. * Defines the task that was just processed
  122715. */
  122716. task: AbstractAssetTask;
  122717. /**
  122718. * Creates a AssetsProgressEvent
  122719. * @param remainingCount defines the number of remaining tasks to process
  122720. * @param totalCount defines the total number of tasks
  122721. * @param task defines the task that was just processed
  122722. */
  122723. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  122724. }
  122725. /**
  122726. * Define a task used by AssetsManager to load meshes
  122727. */
  122728. export class MeshAssetTask extends AbstractAssetTask {
  122729. /**
  122730. * Defines the name of the task
  122731. */
  122732. name: string;
  122733. /**
  122734. * Defines the list of mesh's names you want to load
  122735. */
  122736. meshesNames: any;
  122737. /**
  122738. * Defines the root url to use as a base to load your meshes and associated resources
  122739. */
  122740. rootUrl: string;
  122741. /**
  122742. * Defines the filename of the scene to load from
  122743. */
  122744. sceneFilename: string;
  122745. /**
  122746. * Gets the list of loaded meshes
  122747. */
  122748. loadedMeshes: Array<AbstractMesh>;
  122749. /**
  122750. * Gets the list of loaded particle systems
  122751. */
  122752. loadedParticleSystems: Array<IParticleSystem>;
  122753. /**
  122754. * Gets the list of loaded skeletons
  122755. */
  122756. loadedSkeletons: Array<Skeleton>;
  122757. /**
  122758. * Gets the list of loaded animation groups
  122759. */
  122760. loadedAnimationGroups: Array<AnimationGroup>;
  122761. /**
  122762. * Callback called when the task is successful
  122763. */
  122764. onSuccess: (task: MeshAssetTask) => void;
  122765. /**
  122766. * Callback called when the task is successful
  122767. */
  122768. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  122769. /**
  122770. * Creates a new MeshAssetTask
  122771. * @param name defines the name of the task
  122772. * @param meshesNames defines the list of mesh's names you want to load
  122773. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  122774. * @param sceneFilename defines the filename of the scene to load from
  122775. */
  122776. constructor(
  122777. /**
  122778. * Defines the name of the task
  122779. */
  122780. name: string,
  122781. /**
  122782. * Defines the list of mesh's names you want to load
  122783. */
  122784. meshesNames: any,
  122785. /**
  122786. * Defines the root url to use as a base to load your meshes and associated resources
  122787. */
  122788. rootUrl: string,
  122789. /**
  122790. * Defines the filename of the scene to load from
  122791. */
  122792. sceneFilename: string);
  122793. /**
  122794. * Execute the current task
  122795. * @param scene defines the scene where you want your assets to be loaded
  122796. * @param onSuccess is a callback called when the task is successfully executed
  122797. * @param onError is a callback called if an error occurs
  122798. */
  122799. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122800. }
  122801. /**
  122802. * Define a task used by AssetsManager to load text content
  122803. */
  122804. export class TextFileAssetTask extends AbstractAssetTask {
  122805. /**
  122806. * Defines the name of the task
  122807. */
  122808. name: string;
  122809. /**
  122810. * Defines the location of the file to load
  122811. */
  122812. url: string;
  122813. /**
  122814. * Gets the loaded text string
  122815. */
  122816. text: string;
  122817. /**
  122818. * Callback called when the task is successful
  122819. */
  122820. onSuccess: (task: TextFileAssetTask) => void;
  122821. /**
  122822. * Callback called when the task is successful
  122823. */
  122824. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  122825. /**
  122826. * Creates a new TextFileAssetTask object
  122827. * @param name defines the name of the task
  122828. * @param url defines the location of the file to load
  122829. */
  122830. constructor(
  122831. /**
  122832. * Defines the name of the task
  122833. */
  122834. name: string,
  122835. /**
  122836. * Defines the location of the file to load
  122837. */
  122838. url: string);
  122839. /**
  122840. * Execute the current task
  122841. * @param scene defines the scene where you want your assets to be loaded
  122842. * @param onSuccess is a callback called when the task is successfully executed
  122843. * @param onError is a callback called if an error occurs
  122844. */
  122845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122846. }
  122847. /**
  122848. * Define a task used by AssetsManager to load binary data
  122849. */
  122850. export class BinaryFileAssetTask extends AbstractAssetTask {
  122851. /**
  122852. * Defines the name of the task
  122853. */
  122854. name: string;
  122855. /**
  122856. * Defines the location of the file to load
  122857. */
  122858. url: string;
  122859. /**
  122860. * Gets the lodaded data (as an array buffer)
  122861. */
  122862. data: ArrayBuffer;
  122863. /**
  122864. * Callback called when the task is successful
  122865. */
  122866. onSuccess: (task: BinaryFileAssetTask) => void;
  122867. /**
  122868. * Callback called when the task is successful
  122869. */
  122870. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  122871. /**
  122872. * Creates a new BinaryFileAssetTask object
  122873. * @param name defines the name of the new task
  122874. * @param url defines the location of the file to load
  122875. */
  122876. constructor(
  122877. /**
  122878. * Defines the name of the task
  122879. */
  122880. name: string,
  122881. /**
  122882. * Defines the location of the file to load
  122883. */
  122884. url: string);
  122885. /**
  122886. * Execute the current task
  122887. * @param scene defines the scene where you want your assets to be loaded
  122888. * @param onSuccess is a callback called when the task is successfully executed
  122889. * @param onError is a callback called if an error occurs
  122890. */
  122891. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122892. }
  122893. /**
  122894. * Define a task used by AssetsManager to load images
  122895. */
  122896. export class ImageAssetTask extends AbstractAssetTask {
  122897. /**
  122898. * Defines the name of the task
  122899. */
  122900. name: string;
  122901. /**
  122902. * Defines the location of the image to load
  122903. */
  122904. url: string;
  122905. /**
  122906. * Gets the loaded images
  122907. */
  122908. image: HTMLImageElement;
  122909. /**
  122910. * Callback called when the task is successful
  122911. */
  122912. onSuccess: (task: ImageAssetTask) => void;
  122913. /**
  122914. * Callback called when the task is successful
  122915. */
  122916. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  122917. /**
  122918. * Creates a new ImageAssetTask
  122919. * @param name defines the name of the task
  122920. * @param url defines the location of the image to load
  122921. */
  122922. constructor(
  122923. /**
  122924. * Defines the name of the task
  122925. */
  122926. name: string,
  122927. /**
  122928. * Defines the location of the image to load
  122929. */
  122930. url: string);
  122931. /**
  122932. * Execute the current task
  122933. * @param scene defines the scene where you want your assets to be loaded
  122934. * @param onSuccess is a callback called when the task is successfully executed
  122935. * @param onError is a callback called if an error occurs
  122936. */
  122937. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122938. }
  122939. /**
  122940. * Defines the interface used by texture loading tasks
  122941. */
  122942. export interface ITextureAssetTask<TEX extends BaseTexture> {
  122943. /**
  122944. * Gets the loaded texture
  122945. */
  122946. texture: TEX;
  122947. }
  122948. /**
  122949. * Define a task used by AssetsManager to load 2D textures
  122950. */
  122951. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  122952. /**
  122953. * Defines the name of the task
  122954. */
  122955. name: string;
  122956. /**
  122957. * Defines the location of the file to load
  122958. */
  122959. url: string;
  122960. /**
  122961. * Defines if mipmap should not be generated (default is false)
  122962. */
  122963. noMipmap?: boolean | undefined;
  122964. /**
  122965. * Defines if texture must be inverted on Y axis (default is false)
  122966. */
  122967. invertY?: boolean | undefined;
  122968. /**
  122969. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122970. */
  122971. samplingMode: number;
  122972. /**
  122973. * Gets the loaded texture
  122974. */
  122975. texture: Texture;
  122976. /**
  122977. * Callback called when the task is successful
  122978. */
  122979. onSuccess: (task: TextureAssetTask) => void;
  122980. /**
  122981. * Callback called when the task is successful
  122982. */
  122983. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  122984. /**
  122985. * Creates a new TextureAssetTask object
  122986. * @param name defines the name of the task
  122987. * @param url defines the location of the file to load
  122988. * @param noMipmap defines if mipmap should not be generated (default is false)
  122989. * @param invertY defines if texture must be inverted on Y axis (default is false)
  122990. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122991. */
  122992. constructor(
  122993. /**
  122994. * Defines the name of the task
  122995. */
  122996. name: string,
  122997. /**
  122998. * Defines the location of the file to load
  122999. */
  123000. url: string,
  123001. /**
  123002. * Defines if mipmap should not be generated (default is false)
  123003. */
  123004. noMipmap?: boolean | undefined,
  123005. /**
  123006. * Defines if texture must be inverted on Y axis (default is false)
  123007. */
  123008. invertY?: boolean | undefined,
  123009. /**
  123010. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123011. */
  123012. samplingMode?: number);
  123013. /**
  123014. * Execute the current task
  123015. * @param scene defines the scene where you want your assets to be loaded
  123016. * @param onSuccess is a callback called when the task is successfully executed
  123017. * @param onError is a callback called if an error occurs
  123018. */
  123019. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123020. }
  123021. /**
  123022. * Define a task used by AssetsManager to load cube textures
  123023. */
  123024. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  123025. /**
  123026. * Defines the name of the task
  123027. */
  123028. name: string;
  123029. /**
  123030. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123031. */
  123032. url: string;
  123033. /**
  123034. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123035. */
  123036. extensions?: string[] | undefined;
  123037. /**
  123038. * Defines if mipmaps should not be generated (default is false)
  123039. */
  123040. noMipmap?: boolean | undefined;
  123041. /**
  123042. * Defines the explicit list of files (undefined by default)
  123043. */
  123044. files?: string[] | undefined;
  123045. /**
  123046. * Gets the loaded texture
  123047. */
  123048. texture: CubeTexture;
  123049. /**
  123050. * Callback called when the task is successful
  123051. */
  123052. onSuccess: (task: CubeTextureAssetTask) => void;
  123053. /**
  123054. * Callback called when the task is successful
  123055. */
  123056. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123057. /**
  123058. * Creates a new CubeTextureAssetTask
  123059. * @param name defines the name of the task
  123060. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123061. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123062. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123063. * @param files defines the explicit list of files (undefined by default)
  123064. */
  123065. constructor(
  123066. /**
  123067. * Defines the name of the task
  123068. */
  123069. name: string,
  123070. /**
  123071. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123072. */
  123073. url: string,
  123074. /**
  123075. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123076. */
  123077. extensions?: string[] | undefined,
  123078. /**
  123079. * Defines if mipmaps should not be generated (default is false)
  123080. */
  123081. noMipmap?: boolean | undefined,
  123082. /**
  123083. * Defines the explicit list of files (undefined by default)
  123084. */
  123085. files?: string[] | undefined);
  123086. /**
  123087. * Execute the current task
  123088. * @param scene defines the scene where you want your assets to be loaded
  123089. * @param onSuccess is a callback called when the task is successfully executed
  123090. * @param onError is a callback called if an error occurs
  123091. */
  123092. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123093. }
  123094. /**
  123095. * Define a task used by AssetsManager to load HDR cube textures
  123096. */
  123097. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123098. /**
  123099. * Defines the name of the task
  123100. */
  123101. name: string;
  123102. /**
  123103. * Defines the location of the file to load
  123104. */
  123105. url: string;
  123106. /**
  123107. * Defines the desired size (the more it increases the longer the generation will be)
  123108. */
  123109. size: number;
  123110. /**
  123111. * Defines if mipmaps should not be generated (default is false)
  123112. */
  123113. noMipmap: boolean;
  123114. /**
  123115. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123116. */
  123117. generateHarmonics: boolean;
  123118. /**
  123119. * 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)
  123120. */
  123121. gammaSpace: boolean;
  123122. /**
  123123. * Internal Use Only
  123124. */
  123125. reserved: boolean;
  123126. /**
  123127. * Gets the loaded texture
  123128. */
  123129. texture: HDRCubeTexture;
  123130. /**
  123131. * Callback called when the task is successful
  123132. */
  123133. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123134. /**
  123135. * Callback called when the task is successful
  123136. */
  123137. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123138. /**
  123139. * Creates a new HDRCubeTextureAssetTask object
  123140. * @param name defines the name of the task
  123141. * @param url defines the location of the file to load
  123142. * @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.
  123143. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123144. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123145. * @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)
  123146. * @param reserved Internal use only
  123147. */
  123148. constructor(
  123149. /**
  123150. * Defines the name of the task
  123151. */
  123152. name: string,
  123153. /**
  123154. * Defines the location of the file to load
  123155. */
  123156. url: string,
  123157. /**
  123158. * Defines the desired size (the more it increases the longer the generation will be)
  123159. */
  123160. size: number,
  123161. /**
  123162. * Defines if mipmaps should not be generated (default is false)
  123163. */
  123164. noMipmap?: boolean,
  123165. /**
  123166. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123167. */
  123168. generateHarmonics?: boolean,
  123169. /**
  123170. * 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)
  123171. */
  123172. gammaSpace?: boolean,
  123173. /**
  123174. * Internal Use Only
  123175. */
  123176. reserved?: boolean);
  123177. /**
  123178. * Execute the current task
  123179. * @param scene defines the scene where you want your assets to be loaded
  123180. * @param onSuccess is a callback called when the task is successfully executed
  123181. * @param onError is a callback called if an error occurs
  123182. */
  123183. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123184. }
  123185. /**
  123186. * Define a task used by AssetsManager to load Equirectangular cube textures
  123187. */
  123188. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  123189. /**
  123190. * Defines the name of the task
  123191. */
  123192. name: string;
  123193. /**
  123194. * Defines the location of the file to load
  123195. */
  123196. url: string;
  123197. /**
  123198. * Defines the desired size (the more it increases the longer the generation will be)
  123199. */
  123200. size: number;
  123201. /**
  123202. * Defines if mipmaps should not be generated (default is false)
  123203. */
  123204. noMipmap: boolean;
  123205. /**
  123206. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123207. * but the standard material would require them in Gamma space) (default is true)
  123208. */
  123209. gammaSpace: boolean;
  123210. /**
  123211. * Gets the loaded texture
  123212. */
  123213. texture: EquiRectangularCubeTexture;
  123214. /**
  123215. * Callback called when the task is successful
  123216. */
  123217. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123218. /**
  123219. * Callback called when the task is successful
  123220. */
  123221. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123222. /**
  123223. * Creates a new EquiRectangularCubeTextureAssetTask object
  123224. * @param name defines the name of the task
  123225. * @param url defines the location of the file to load
  123226. * @param size defines the desired size (the more it increases the longer the generation will be)
  123227. * If the size is omitted this implies you are using a preprocessed cubemap.
  123228. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123229. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123230. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123231. * (default is true)
  123232. */
  123233. constructor(
  123234. /**
  123235. * Defines the name of the task
  123236. */
  123237. name: string,
  123238. /**
  123239. * Defines the location of the file to load
  123240. */
  123241. url: string,
  123242. /**
  123243. * Defines the desired size (the more it increases the longer the generation will be)
  123244. */
  123245. size: number,
  123246. /**
  123247. * Defines if mipmaps should not be generated (default is false)
  123248. */
  123249. noMipmap?: boolean,
  123250. /**
  123251. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123252. * but the standard material would require them in Gamma space) (default is true)
  123253. */
  123254. gammaSpace?: boolean);
  123255. /**
  123256. * Execute the current task
  123257. * @param scene defines the scene where you want your assets to be loaded
  123258. * @param onSuccess is a callback called when the task is successfully executed
  123259. * @param onError is a callback called if an error occurs
  123260. */
  123261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123262. }
  123263. /**
  123264. * This class can be used to easily import assets into a scene
  123265. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123266. */
  123267. export class AssetsManager {
  123268. private _scene;
  123269. private _isLoading;
  123270. protected _tasks: AbstractAssetTask[];
  123271. protected _waitingTasksCount: number;
  123272. protected _totalTasksCount: number;
  123273. /**
  123274. * Callback called when all tasks are processed
  123275. */
  123276. onFinish: (tasks: AbstractAssetTask[]) => void;
  123277. /**
  123278. * Callback called when a task is successful
  123279. */
  123280. onTaskSuccess: (task: AbstractAssetTask) => void;
  123281. /**
  123282. * Callback called when a task had an error
  123283. */
  123284. onTaskError: (task: AbstractAssetTask) => void;
  123285. /**
  123286. * Callback called when a task is done (whatever the result is)
  123287. */
  123288. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123289. /**
  123290. * Observable called when all tasks are processed
  123291. */
  123292. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123293. /**
  123294. * Observable called when a task had an error
  123295. */
  123296. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123297. /**
  123298. * Observable called when all tasks were executed
  123299. */
  123300. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123301. /**
  123302. * Observable called when a task is done (whatever the result is)
  123303. */
  123304. onProgressObservable: Observable<IAssetsProgressEvent>;
  123305. /**
  123306. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123307. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123308. */
  123309. useDefaultLoadingScreen: boolean;
  123310. /**
  123311. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123312. * when all assets have been downloaded.
  123313. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123314. */
  123315. autoHideLoadingUI: boolean;
  123316. /**
  123317. * Creates a new AssetsManager
  123318. * @param scene defines the scene to work on
  123319. */
  123320. constructor(scene: Scene);
  123321. /**
  123322. * Add a MeshAssetTask to the list of active tasks
  123323. * @param taskName defines the name of the new task
  123324. * @param meshesNames defines the name of meshes to load
  123325. * @param rootUrl defines the root url to use to locate files
  123326. * @param sceneFilename defines the filename of the scene file
  123327. * @returns a new MeshAssetTask object
  123328. */
  123329. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123330. /**
  123331. * Add a TextFileAssetTask to the list of active tasks
  123332. * @param taskName defines the name of the new task
  123333. * @param url defines the url of the file to load
  123334. * @returns a new TextFileAssetTask object
  123335. */
  123336. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123337. /**
  123338. * Add a BinaryFileAssetTask to the list of active tasks
  123339. * @param taskName defines the name of the new task
  123340. * @param url defines the url of the file to load
  123341. * @returns a new BinaryFileAssetTask object
  123342. */
  123343. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123344. /**
  123345. * Add a ImageAssetTask to the list of active tasks
  123346. * @param taskName defines the name of the new task
  123347. * @param url defines the url of the file to load
  123348. * @returns a new ImageAssetTask object
  123349. */
  123350. addImageTask(taskName: string, url: string): ImageAssetTask;
  123351. /**
  123352. * Add a TextureAssetTask to the list of active tasks
  123353. * @param taskName defines the name of the new task
  123354. * @param url defines the url of the file to load
  123355. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123356. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123357. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123358. * @returns a new TextureAssetTask object
  123359. */
  123360. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123361. /**
  123362. * Add a CubeTextureAssetTask to the list of active tasks
  123363. * @param taskName defines the name of the new task
  123364. * @param url defines the url of the file to load
  123365. * @param extensions defines the extension to use to load the cube map (can be null)
  123366. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123367. * @param files defines the list of files to load (can be null)
  123368. * @returns a new CubeTextureAssetTask object
  123369. */
  123370. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123371. /**
  123372. *
  123373. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123374. * @param taskName defines the name of the new task
  123375. * @param url defines the url of the file to load
  123376. * @param size defines the size you want for the cubemap (can be null)
  123377. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123378. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123379. * @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)
  123380. * @param reserved Internal use only
  123381. * @returns a new HDRCubeTextureAssetTask object
  123382. */
  123383. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123384. /**
  123385. *
  123386. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123387. * @param taskName defines the name of the new task
  123388. * @param url defines the url of the file to load
  123389. * @param size defines the size you want for the cubemap (can be null)
  123390. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123391. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123392. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123393. * @returns a new EquiRectangularCubeTextureAssetTask object
  123394. */
  123395. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123396. /**
  123397. * Remove a task from the assets manager.
  123398. * @param task the task to remove
  123399. */
  123400. removeTask(task: AbstractAssetTask): void;
  123401. private _decreaseWaitingTasksCount;
  123402. private _runTask;
  123403. /**
  123404. * Reset the AssetsManager and remove all tasks
  123405. * @return the current instance of the AssetsManager
  123406. */
  123407. reset(): AssetsManager;
  123408. /**
  123409. * Start the loading process
  123410. * @return the current instance of the AssetsManager
  123411. */
  123412. load(): AssetsManager;
  123413. /**
  123414. * Start the loading process as an async operation
  123415. * @return a promise returning the list of failed tasks
  123416. */
  123417. loadAsync(): Promise<void>;
  123418. }
  123419. }
  123420. declare module BABYLON {
  123421. /**
  123422. * Wrapper class for promise with external resolve and reject.
  123423. */
  123424. export class Deferred<T> {
  123425. /**
  123426. * The promise associated with this deferred object.
  123427. */
  123428. readonly promise: Promise<T>;
  123429. private _resolve;
  123430. private _reject;
  123431. /**
  123432. * The resolve method of the promise associated with this deferred object.
  123433. */
  123434. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123435. /**
  123436. * The reject method of the promise associated with this deferred object.
  123437. */
  123438. readonly reject: (reason?: any) => void;
  123439. /**
  123440. * Constructor for this deferred object.
  123441. */
  123442. constructor();
  123443. }
  123444. }
  123445. declare module BABYLON {
  123446. /**
  123447. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123448. */
  123449. export class MeshExploder {
  123450. private _centerMesh;
  123451. private _meshes;
  123452. private _meshesOrigins;
  123453. private _toCenterVectors;
  123454. private _scaledDirection;
  123455. private _newPosition;
  123456. private _centerPosition;
  123457. /**
  123458. * Explodes meshes from a center mesh.
  123459. * @param meshes The meshes to explode.
  123460. * @param centerMesh The mesh to be center of explosion.
  123461. */
  123462. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123463. private _setCenterMesh;
  123464. /**
  123465. * Get class name
  123466. * @returns "MeshExploder"
  123467. */
  123468. getClassName(): string;
  123469. /**
  123470. * "Exploded meshes"
  123471. * @returns Array of meshes with the centerMesh at index 0.
  123472. */
  123473. getMeshes(): Array<Mesh>;
  123474. /**
  123475. * Explodes meshes giving a specific direction
  123476. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123477. */
  123478. explode(direction?: number): void;
  123479. }
  123480. }
  123481. declare module BABYLON {
  123482. /**
  123483. * Class used to help managing file picking and drag'n'drop
  123484. */
  123485. export class FilesInput {
  123486. /**
  123487. * List of files ready to be loaded
  123488. */
  123489. static readonly FilesToLoad: {
  123490. [key: string]: File;
  123491. };
  123492. /**
  123493. * Callback called when a file is processed
  123494. */
  123495. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123496. private _engine;
  123497. private _currentScene;
  123498. private _sceneLoadedCallback;
  123499. private _progressCallback;
  123500. private _additionalRenderLoopLogicCallback;
  123501. private _textureLoadingCallback;
  123502. private _startingProcessingFilesCallback;
  123503. private _onReloadCallback;
  123504. private _errorCallback;
  123505. private _elementToMonitor;
  123506. private _sceneFileToLoad;
  123507. private _filesToLoad;
  123508. /**
  123509. * Creates a new FilesInput
  123510. * @param engine defines the rendering engine
  123511. * @param scene defines the hosting scene
  123512. * @param sceneLoadedCallback callback called when scene is loaded
  123513. * @param progressCallback callback called to track progress
  123514. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123515. * @param textureLoadingCallback callback called when a texture is loading
  123516. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123517. * @param onReloadCallback callback called when a reload is requested
  123518. * @param errorCallback callback call if an error occurs
  123519. */
  123520. 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);
  123521. private _dragEnterHandler;
  123522. private _dragOverHandler;
  123523. private _dropHandler;
  123524. /**
  123525. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123526. * @param elementToMonitor defines the DOM element to track
  123527. */
  123528. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123529. /**
  123530. * Release all associated resources
  123531. */
  123532. dispose(): void;
  123533. private renderFunction;
  123534. private drag;
  123535. private drop;
  123536. private _traverseFolder;
  123537. private _processFiles;
  123538. /**
  123539. * Load files from a drop event
  123540. * @param event defines the drop event to use as source
  123541. */
  123542. loadFiles(event: any): void;
  123543. private _processReload;
  123544. /**
  123545. * Reload the current scene from the loaded files
  123546. */
  123547. reload(): void;
  123548. }
  123549. }
  123550. declare module BABYLON {
  123551. /**
  123552. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123553. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123554. */
  123555. export class SceneOptimization {
  123556. /**
  123557. * Defines the priority of this optimization (0 by default which means first in the list)
  123558. */
  123559. priority: number;
  123560. /**
  123561. * Gets a string describing the action executed by the current optimization
  123562. * @returns description string
  123563. */
  123564. getDescription(): string;
  123565. /**
  123566. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123567. * @param scene defines the current scene where to apply this optimization
  123568. * @param optimizer defines the current optimizer
  123569. * @returns true if everything that can be done was applied
  123570. */
  123571. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123572. /**
  123573. * Creates the SceneOptimization object
  123574. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123575. * @param desc defines the description associated with the optimization
  123576. */
  123577. constructor(
  123578. /**
  123579. * Defines the priority of this optimization (0 by default which means first in the list)
  123580. */
  123581. priority?: number);
  123582. }
  123583. /**
  123584. * Defines an optimization used to reduce the size of render target textures
  123585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123586. */
  123587. export class TextureOptimization extends SceneOptimization {
  123588. /**
  123589. * Defines the priority of this optimization (0 by default which means first in the list)
  123590. */
  123591. priority: number;
  123592. /**
  123593. * 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
  123594. */
  123595. maximumSize: number;
  123596. /**
  123597. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123598. */
  123599. step: number;
  123600. /**
  123601. * Gets a string describing the action executed by the current optimization
  123602. * @returns description string
  123603. */
  123604. getDescription(): string;
  123605. /**
  123606. * Creates the TextureOptimization object
  123607. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123608. * @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
  123609. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123610. */
  123611. constructor(
  123612. /**
  123613. * Defines the priority of this optimization (0 by default which means first in the list)
  123614. */
  123615. priority?: number,
  123616. /**
  123617. * 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
  123618. */
  123619. maximumSize?: number,
  123620. /**
  123621. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123622. */
  123623. step?: number);
  123624. /**
  123625. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123626. * @param scene defines the current scene where to apply this optimization
  123627. * @param optimizer defines the current optimizer
  123628. * @returns true if everything that can be done was applied
  123629. */
  123630. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123631. }
  123632. /**
  123633. * Defines an optimization used to increase or decrease the rendering resolution
  123634. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123635. */
  123636. export class HardwareScalingOptimization extends SceneOptimization {
  123637. /**
  123638. * Defines the priority of this optimization (0 by default which means first in the list)
  123639. */
  123640. priority: number;
  123641. /**
  123642. * Defines the maximum scale to use (2 by default)
  123643. */
  123644. maximumScale: number;
  123645. /**
  123646. * Defines the step to use between two passes (0.5 by default)
  123647. */
  123648. step: number;
  123649. private _currentScale;
  123650. private _directionOffset;
  123651. /**
  123652. * Gets a string describing the action executed by the current optimization
  123653. * @return description string
  123654. */
  123655. getDescription(): string;
  123656. /**
  123657. * Creates the HardwareScalingOptimization object
  123658. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123659. * @param maximumScale defines the maximum scale to use (2 by default)
  123660. * @param step defines the step to use between two passes (0.5 by default)
  123661. */
  123662. constructor(
  123663. /**
  123664. * Defines the priority of this optimization (0 by default which means first in the list)
  123665. */
  123666. priority?: number,
  123667. /**
  123668. * Defines the maximum scale to use (2 by default)
  123669. */
  123670. maximumScale?: number,
  123671. /**
  123672. * Defines the step to use between two passes (0.5 by default)
  123673. */
  123674. step?: number);
  123675. /**
  123676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123677. * @param scene defines the current scene where to apply this optimization
  123678. * @param optimizer defines the current optimizer
  123679. * @returns true if everything that can be done was applied
  123680. */
  123681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123682. }
  123683. /**
  123684. * Defines an optimization used to remove shadows
  123685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123686. */
  123687. export class ShadowsOptimization extends SceneOptimization {
  123688. /**
  123689. * Gets a string describing the action executed by the current optimization
  123690. * @return description string
  123691. */
  123692. getDescription(): string;
  123693. /**
  123694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123695. * @param scene defines the current scene where to apply this optimization
  123696. * @param optimizer defines the current optimizer
  123697. * @returns true if everything that can be done was applied
  123698. */
  123699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123700. }
  123701. /**
  123702. * Defines an optimization used to turn post-processes off
  123703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123704. */
  123705. export class PostProcessesOptimization extends SceneOptimization {
  123706. /**
  123707. * Gets a string describing the action executed by the current optimization
  123708. * @return description string
  123709. */
  123710. getDescription(): string;
  123711. /**
  123712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123713. * @param scene defines the current scene where to apply this optimization
  123714. * @param optimizer defines the current optimizer
  123715. * @returns true if everything that can be done was applied
  123716. */
  123717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123718. }
  123719. /**
  123720. * Defines an optimization used to turn lens flares off
  123721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123722. */
  123723. export class LensFlaresOptimization extends SceneOptimization {
  123724. /**
  123725. * Gets a string describing the action executed by the current optimization
  123726. * @return description string
  123727. */
  123728. getDescription(): string;
  123729. /**
  123730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123731. * @param scene defines the current scene where to apply this optimization
  123732. * @param optimizer defines the current optimizer
  123733. * @returns true if everything that can be done was applied
  123734. */
  123735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123736. }
  123737. /**
  123738. * Defines an optimization based on user defined callback.
  123739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123740. */
  123741. export class CustomOptimization extends SceneOptimization {
  123742. /**
  123743. * Callback called to apply the custom optimization.
  123744. */
  123745. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  123746. /**
  123747. * Callback called to get custom description
  123748. */
  123749. onGetDescription: () => string;
  123750. /**
  123751. * Gets a string describing the action executed by the current optimization
  123752. * @returns description string
  123753. */
  123754. getDescription(): string;
  123755. /**
  123756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123757. * @param scene defines the current scene where to apply this optimization
  123758. * @param optimizer defines the current optimizer
  123759. * @returns true if everything that can be done was applied
  123760. */
  123761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123762. }
  123763. /**
  123764. * Defines an optimization used to turn particles off
  123765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123766. */
  123767. export class ParticlesOptimization extends SceneOptimization {
  123768. /**
  123769. * Gets a string describing the action executed by the current optimization
  123770. * @return description string
  123771. */
  123772. getDescription(): string;
  123773. /**
  123774. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123775. * @param scene defines the current scene where to apply this optimization
  123776. * @param optimizer defines the current optimizer
  123777. * @returns true if everything that can be done was applied
  123778. */
  123779. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123780. }
  123781. /**
  123782. * Defines an optimization used to turn render targets off
  123783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123784. */
  123785. export class RenderTargetsOptimization extends SceneOptimization {
  123786. /**
  123787. * Gets a string describing the action executed by the current optimization
  123788. * @return description string
  123789. */
  123790. getDescription(): string;
  123791. /**
  123792. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123793. * @param scene defines the current scene where to apply this optimization
  123794. * @param optimizer defines the current optimizer
  123795. * @returns true if everything that can be done was applied
  123796. */
  123797. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123798. }
  123799. /**
  123800. * Defines an optimization used to merge meshes with compatible materials
  123801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123802. */
  123803. export class MergeMeshesOptimization extends SceneOptimization {
  123804. private static _UpdateSelectionTree;
  123805. /**
  123806. * Gets or sets a boolean which defines if optimization octree has to be updated
  123807. */
  123808. /**
  123809. * Gets or sets a boolean which defines if optimization octree has to be updated
  123810. */
  123811. static UpdateSelectionTree: boolean;
  123812. /**
  123813. * Gets a string describing the action executed by the current optimization
  123814. * @return description string
  123815. */
  123816. getDescription(): string;
  123817. private _canBeMerged;
  123818. /**
  123819. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123820. * @param scene defines the current scene where to apply this optimization
  123821. * @param optimizer defines the current optimizer
  123822. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  123823. * @returns true if everything that can be done was applied
  123824. */
  123825. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  123826. }
  123827. /**
  123828. * Defines a list of options used by SceneOptimizer
  123829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123830. */
  123831. export class SceneOptimizerOptions {
  123832. /**
  123833. * Defines the target frame rate to reach (60 by default)
  123834. */
  123835. targetFrameRate: number;
  123836. /**
  123837. * Defines the interval between two checkes (2000ms by default)
  123838. */
  123839. trackerDuration: number;
  123840. /**
  123841. * Gets the list of optimizations to apply
  123842. */
  123843. optimizations: SceneOptimization[];
  123844. /**
  123845. * Creates a new list of options used by SceneOptimizer
  123846. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  123847. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  123848. */
  123849. constructor(
  123850. /**
  123851. * Defines the target frame rate to reach (60 by default)
  123852. */
  123853. targetFrameRate?: number,
  123854. /**
  123855. * Defines the interval between two checkes (2000ms by default)
  123856. */
  123857. trackerDuration?: number);
  123858. /**
  123859. * Add a new optimization
  123860. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  123861. * @returns the current SceneOptimizerOptions
  123862. */
  123863. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  123864. /**
  123865. * Add a new custom optimization
  123866. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  123867. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  123868. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123869. * @returns the current SceneOptimizerOptions
  123870. */
  123871. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  123872. /**
  123873. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  123874. * @param targetFrameRate defines the target frame rate (60 by default)
  123875. * @returns a SceneOptimizerOptions object
  123876. */
  123877. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123878. /**
  123879. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  123880. * @param targetFrameRate defines the target frame rate (60 by default)
  123881. * @returns a SceneOptimizerOptions object
  123882. */
  123883. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123884. /**
  123885. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  123886. * @param targetFrameRate defines the target frame rate (60 by default)
  123887. * @returns a SceneOptimizerOptions object
  123888. */
  123889. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123890. }
  123891. /**
  123892. * Class used to run optimizations in order to reach a target frame rate
  123893. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123894. */
  123895. export class SceneOptimizer implements IDisposable {
  123896. private _isRunning;
  123897. private _options;
  123898. private _scene;
  123899. private _currentPriorityLevel;
  123900. private _targetFrameRate;
  123901. private _trackerDuration;
  123902. private _currentFrameRate;
  123903. private _sceneDisposeObserver;
  123904. private _improvementMode;
  123905. /**
  123906. * Defines an observable called when the optimizer reaches the target frame rate
  123907. */
  123908. onSuccessObservable: Observable<SceneOptimizer>;
  123909. /**
  123910. * Defines an observable called when the optimizer enables an optimization
  123911. */
  123912. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  123913. /**
  123914. * Defines an observable called when the optimizer is not able to reach the target frame rate
  123915. */
  123916. onFailureObservable: Observable<SceneOptimizer>;
  123917. /**
  123918. * Gets a boolean indicating if the optimizer is in improvement mode
  123919. */
  123920. readonly isInImprovementMode: boolean;
  123921. /**
  123922. * Gets the current priority level (0 at start)
  123923. */
  123924. readonly currentPriorityLevel: number;
  123925. /**
  123926. * Gets the current frame rate checked by the SceneOptimizer
  123927. */
  123928. readonly currentFrameRate: number;
  123929. /**
  123930. * Gets or sets the current target frame rate (60 by default)
  123931. */
  123932. /**
  123933. * Gets or sets the current target frame rate (60 by default)
  123934. */
  123935. targetFrameRate: number;
  123936. /**
  123937. * Gets or sets the current interval between two checks (every 2000ms by default)
  123938. */
  123939. /**
  123940. * Gets or sets the current interval between two checks (every 2000ms by default)
  123941. */
  123942. trackerDuration: number;
  123943. /**
  123944. * Gets the list of active optimizations
  123945. */
  123946. readonly optimizations: SceneOptimization[];
  123947. /**
  123948. * Creates a new SceneOptimizer
  123949. * @param scene defines the scene to work on
  123950. * @param options defines the options to use with the SceneOptimizer
  123951. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  123952. * @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)
  123953. */
  123954. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  123955. /**
  123956. * Stops the current optimizer
  123957. */
  123958. stop(): void;
  123959. /**
  123960. * Reset the optimizer to initial step (current priority level = 0)
  123961. */
  123962. reset(): void;
  123963. /**
  123964. * Start the optimizer. By default it will try to reach a specific framerate
  123965. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  123966. */
  123967. start(): void;
  123968. private _checkCurrentState;
  123969. /**
  123970. * Release all resources
  123971. */
  123972. dispose(): void;
  123973. /**
  123974. * Helper function to create a SceneOptimizer with one single line of code
  123975. * @param scene defines the scene to work on
  123976. * @param options defines the options to use with the SceneOptimizer
  123977. * @param onSuccess defines a callback to call on success
  123978. * @param onFailure defines a callback to call on failure
  123979. * @returns the new SceneOptimizer object
  123980. */
  123981. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  123982. }
  123983. }
  123984. declare module BABYLON {
  123985. /**
  123986. * Class used to serialize a scene into a string
  123987. */
  123988. export class SceneSerializer {
  123989. /**
  123990. * Clear cache used by a previous serialization
  123991. */
  123992. static ClearCache(): void;
  123993. /**
  123994. * Serialize a scene into a JSON compatible object
  123995. * @param scene defines the scene to serialize
  123996. * @returns a JSON compatible object
  123997. */
  123998. static Serialize(scene: Scene): any;
  123999. /**
  124000. * Serialize a mesh into a JSON compatible object
  124001. * @param toSerialize defines the mesh to serialize
  124002. * @param withParents defines if parents must be serialized as well
  124003. * @param withChildren defines if children must be serialized as well
  124004. * @returns a JSON compatible object
  124005. */
  124006. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  124007. }
  124008. }
  124009. declare module BABYLON {
  124010. /**
  124011. * Class used to host texture specific utilities
  124012. */
  124013. export class TextureTools {
  124014. /**
  124015. * Uses the GPU to create a copy texture rescaled at a given size
  124016. * @param texture Texture to copy from
  124017. * @param width defines the desired width
  124018. * @param height defines the desired height
  124019. * @param useBilinearMode defines if bilinear mode has to be used
  124020. * @return the generated texture
  124021. */
  124022. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  124023. }
  124024. }
  124025. declare module BABYLON {
  124026. /**
  124027. * This represents the different options available for the video capture.
  124028. */
  124029. export interface VideoRecorderOptions {
  124030. /** Defines the mime type of the video. */
  124031. mimeType: string;
  124032. /** Defines the FPS the video should be recorded at. */
  124033. fps: number;
  124034. /** Defines the chunk size for the recording data. */
  124035. recordChunckSize: number;
  124036. /** The audio tracks to attach to the recording. */
  124037. audioTracks?: MediaStreamTrack[];
  124038. }
  124039. /**
  124040. * This can help with recording videos from BabylonJS.
  124041. * This is based on the available WebRTC functionalities of the browser.
  124042. *
  124043. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124044. */
  124045. export class VideoRecorder {
  124046. private static readonly _defaultOptions;
  124047. /**
  124048. * Returns whether or not the VideoRecorder is available in your browser.
  124049. * @param engine Defines the Babylon Engine.
  124050. * @returns true if supported otherwise false.
  124051. */
  124052. static IsSupported(engine: Engine): boolean;
  124053. private readonly _options;
  124054. private _canvas;
  124055. private _mediaRecorder;
  124056. private _recordedChunks;
  124057. private _fileName;
  124058. private _resolve;
  124059. private _reject;
  124060. /**
  124061. * True when a recording is already in progress.
  124062. */
  124063. readonly isRecording: boolean;
  124064. /**
  124065. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124066. * @param engine Defines the BabylonJS Engine you wish to record.
  124067. * @param options Defines options that can be used to customize the capture.
  124068. */
  124069. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124070. /**
  124071. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124072. */
  124073. stopRecording(): void;
  124074. /**
  124075. * Starts recording the canvas for a max duration specified in parameters.
  124076. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124077. * If null no automatic download will start and you can rely on the promise to get the data back.
  124078. * @param maxDuration Defines the maximum recording time in seconds.
  124079. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124080. * @return A promise callback at the end of the recording with the video data in Blob.
  124081. */
  124082. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124083. /**
  124084. * Releases internal resources used during the recording.
  124085. */
  124086. dispose(): void;
  124087. private _handleDataAvailable;
  124088. private _handleError;
  124089. private _handleStop;
  124090. }
  124091. }
  124092. declare module BABYLON {
  124093. /**
  124094. * Class containing a set of static utilities functions for screenshots
  124095. */
  124096. export class ScreenshotTools {
  124097. /**
  124098. * Captures a screenshot of the current rendering
  124099. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124100. * @param engine defines the rendering engine
  124101. * @param camera defines the source camera
  124102. * @param size This parameter can be set to a single number or to an object with the
  124103. * following (optional) properties: precision, width, height. If a single number is passed,
  124104. * it will be used for both width and height. If an object is passed, the screenshot size
  124105. * will be derived from the parameters. The precision property is a multiplier allowing
  124106. * rendering at a higher or lower resolution
  124107. * @param successCallback defines the callback receives a single parameter which contains the
  124108. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124109. * src parameter of an <img> to display it
  124110. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124111. * Check your browser for supported MIME types
  124112. */
  124113. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  124114. /**
  124115. * Captures a screenshot of the current rendering
  124116. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124117. * @param engine defines the rendering engine
  124118. * @param camera defines the source camera
  124119. * @param size This parameter can be set to a single number or to an object with the
  124120. * following (optional) properties: precision, width, height. If a single number is passed,
  124121. * it will be used for both width and height. If an object is passed, the screenshot size
  124122. * will be derived from the parameters. The precision property is a multiplier allowing
  124123. * rendering at a higher or lower resolution
  124124. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124125. * Check your browser for supported MIME types
  124126. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124127. * to the src parameter of an <img> to display it
  124128. */
  124129. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124130. /**
  124131. * Generates an image screenshot from the specified camera.
  124132. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124133. * @param engine The engine to use for rendering
  124134. * @param camera The camera to use for rendering
  124135. * @param size This parameter can be set to a single number or to an object with the
  124136. * following (optional) properties: precision, width, height. If a single number is passed,
  124137. * it will be used for both width and height. If an object is passed, the screenshot size
  124138. * will be derived from the parameters. The precision property is a multiplier allowing
  124139. * rendering at a higher or lower resolution
  124140. * @param successCallback The callback receives a single parameter which contains the
  124141. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124142. * src parameter of an <img> to display it
  124143. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124144. * Check your browser for supported MIME types
  124145. * @param samples Texture samples (default: 1)
  124146. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124147. * @param fileName A name for for the downloaded file.
  124148. */
  124149. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124150. /**
  124151. * Generates an image screenshot from the specified camera.
  124152. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124153. * @param engine The engine to use for rendering
  124154. * @param camera The camera to use for rendering
  124155. * @param size This parameter can be set to a single number or to an object with the
  124156. * following (optional) properties: precision, width, height. If a single number is passed,
  124157. * it will be used for both width and height. If an object is passed, the screenshot size
  124158. * will be derived from the parameters. The precision property is a multiplier allowing
  124159. * rendering at a higher or lower resolution
  124160. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124161. * Check your browser for supported MIME types
  124162. * @param samples Texture samples (default: 1)
  124163. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124164. * @param fileName A name for for the downloaded file.
  124165. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124166. * to the src parameter of an <img> to display it
  124167. */
  124168. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  124169. }
  124170. }
  124171. declare module BABYLON {
  124172. /**
  124173. * A cursor which tracks a point on a path
  124174. */
  124175. export class PathCursor {
  124176. private path;
  124177. /**
  124178. * Stores path cursor callbacks for when an onchange event is triggered
  124179. */
  124180. private _onchange;
  124181. /**
  124182. * The value of the path cursor
  124183. */
  124184. value: number;
  124185. /**
  124186. * The animation array of the path cursor
  124187. */
  124188. animations: Animation[];
  124189. /**
  124190. * Initializes the path cursor
  124191. * @param path The path to track
  124192. */
  124193. constructor(path: Path2);
  124194. /**
  124195. * Gets the cursor point on the path
  124196. * @returns A point on the path cursor at the cursor location
  124197. */
  124198. getPoint(): Vector3;
  124199. /**
  124200. * Moves the cursor ahead by the step amount
  124201. * @param step The amount to move the cursor forward
  124202. * @returns This path cursor
  124203. */
  124204. moveAhead(step?: number): PathCursor;
  124205. /**
  124206. * Moves the cursor behind by the step amount
  124207. * @param step The amount to move the cursor back
  124208. * @returns This path cursor
  124209. */
  124210. moveBack(step?: number): PathCursor;
  124211. /**
  124212. * Moves the cursor by the step amount
  124213. * If the step amount is greater than one, an exception is thrown
  124214. * @param step The amount to move the cursor
  124215. * @returns This path cursor
  124216. */
  124217. move(step: number): PathCursor;
  124218. /**
  124219. * Ensures that the value is limited between zero and one
  124220. * @returns This path cursor
  124221. */
  124222. private ensureLimits;
  124223. /**
  124224. * Runs onchange callbacks on change (used by the animation engine)
  124225. * @returns This path cursor
  124226. */
  124227. private raiseOnChange;
  124228. /**
  124229. * Executes a function on change
  124230. * @param f A path cursor onchange callback
  124231. * @returns This path cursor
  124232. */
  124233. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124234. }
  124235. }
  124236. declare module BABYLON {
  124237. /** @hidden */
  124238. export var blurPixelShader: {
  124239. name: string;
  124240. shader: string;
  124241. };
  124242. }
  124243. declare module BABYLON {
  124244. /** @hidden */
  124245. export var pointCloudVertexDeclaration: {
  124246. name: string;
  124247. shader: string;
  124248. };
  124249. }
  124250. // Mixins
  124251. interface Window {
  124252. mozIndexedDB: IDBFactory;
  124253. webkitIndexedDB: IDBFactory;
  124254. msIndexedDB: IDBFactory;
  124255. webkitURL: typeof URL;
  124256. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124257. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124258. WebGLRenderingContext: WebGLRenderingContext;
  124259. MSGesture: MSGesture;
  124260. CANNON: any;
  124261. AudioContext: AudioContext;
  124262. webkitAudioContext: AudioContext;
  124263. PointerEvent: any;
  124264. Math: Math;
  124265. Uint8Array: Uint8ArrayConstructor;
  124266. Float32Array: Float32ArrayConstructor;
  124267. mozURL: typeof URL;
  124268. msURL: typeof URL;
  124269. VRFrameData: any; // WebVR, from specs 1.1
  124270. DracoDecoderModule: any;
  124271. setImmediate(handler: (...args: any[]) => void): number;
  124272. }
  124273. interface HTMLCanvasElement {
  124274. requestPointerLock(): void;
  124275. msRequestPointerLock?(): void;
  124276. mozRequestPointerLock?(): void;
  124277. webkitRequestPointerLock?(): void;
  124278. /** Track wether a record is in progress */
  124279. isRecording: boolean;
  124280. /** Capture Stream method defined by some browsers */
  124281. captureStream(fps?: number): MediaStream;
  124282. }
  124283. interface CanvasRenderingContext2D {
  124284. msImageSmoothingEnabled: boolean;
  124285. }
  124286. interface MouseEvent {
  124287. mozMovementX: number;
  124288. mozMovementY: number;
  124289. webkitMovementX: number;
  124290. webkitMovementY: number;
  124291. msMovementX: number;
  124292. msMovementY: number;
  124293. }
  124294. interface Navigator {
  124295. mozGetVRDevices: (any: any) => any;
  124296. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124297. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124298. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124299. webkitGetGamepads(): Gamepad[];
  124300. msGetGamepads(): Gamepad[];
  124301. webkitGamepads(): Gamepad[];
  124302. }
  124303. interface HTMLVideoElement {
  124304. mozSrcObject: any;
  124305. }
  124306. interface Math {
  124307. fround(x: number): number;
  124308. imul(a: number, b: number): number;
  124309. }
  124310. interface WebGLRenderingContext {
  124311. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124312. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124313. vertexAttribDivisor(index: number, divisor: number): void;
  124314. createVertexArray(): any;
  124315. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124316. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124317. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124318. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124319. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124320. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124321. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124322. // Queries
  124323. createQuery(): WebGLQuery;
  124324. deleteQuery(query: WebGLQuery): void;
  124325. beginQuery(target: number, query: WebGLQuery): void;
  124326. endQuery(target: number): void;
  124327. getQueryParameter(query: WebGLQuery, pname: number): any;
  124328. getQuery(target: number, pname: number): any;
  124329. MAX_SAMPLES: number;
  124330. RGBA8: number;
  124331. READ_FRAMEBUFFER: number;
  124332. DRAW_FRAMEBUFFER: number;
  124333. UNIFORM_BUFFER: number;
  124334. HALF_FLOAT_OES: number;
  124335. RGBA16F: number;
  124336. RGBA32F: number;
  124337. R32F: number;
  124338. RG32F: number;
  124339. RGB32F: number;
  124340. R16F: number;
  124341. RG16F: number;
  124342. RGB16F: number;
  124343. RED: number;
  124344. RG: number;
  124345. R8: number;
  124346. RG8: number;
  124347. UNSIGNED_INT_24_8: number;
  124348. DEPTH24_STENCIL8: number;
  124349. /* Multiple Render Targets */
  124350. drawBuffers(buffers: number[]): void;
  124351. readBuffer(src: number): void;
  124352. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124353. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124354. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124355. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124356. // Occlusion Query
  124357. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124358. ANY_SAMPLES_PASSED: number;
  124359. QUERY_RESULT_AVAILABLE: number;
  124360. QUERY_RESULT: number;
  124361. }
  124362. interface WebGLProgram {
  124363. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124364. }
  124365. interface EXT_disjoint_timer_query {
  124366. QUERY_COUNTER_BITS_EXT: number;
  124367. TIME_ELAPSED_EXT: number;
  124368. TIMESTAMP_EXT: number;
  124369. GPU_DISJOINT_EXT: number;
  124370. QUERY_RESULT_EXT: number;
  124371. QUERY_RESULT_AVAILABLE_EXT: number;
  124372. queryCounterEXT(query: WebGLQuery, target: number): void;
  124373. createQueryEXT(): WebGLQuery;
  124374. beginQueryEXT(target: number, query: WebGLQuery): void;
  124375. endQueryEXT(target: number): void;
  124376. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124377. deleteQueryEXT(query: WebGLQuery): void;
  124378. }
  124379. interface WebGLUniformLocation {
  124380. _currentState: any;
  124381. }
  124382. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124383. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124384. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124385. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124386. interface WebGLRenderingContext {
  124387. readonly RASTERIZER_DISCARD: number;
  124388. readonly DEPTH_COMPONENT24: number;
  124389. readonly TEXTURE_3D: number;
  124390. readonly TEXTURE_2D_ARRAY: number;
  124391. readonly TEXTURE_COMPARE_FUNC: number;
  124392. readonly TEXTURE_COMPARE_MODE: number;
  124393. readonly COMPARE_REF_TO_TEXTURE: number;
  124394. readonly TEXTURE_WRAP_R: number;
  124395. readonly HALF_FLOAT: number;
  124396. readonly RGB8: number;
  124397. readonly RED_INTEGER: number;
  124398. readonly RG_INTEGER: number;
  124399. readonly RGB_INTEGER: number;
  124400. readonly RGBA_INTEGER: number;
  124401. readonly R8_SNORM: number;
  124402. readonly RG8_SNORM: number;
  124403. readonly RGB8_SNORM: number;
  124404. readonly RGBA8_SNORM: number;
  124405. readonly R8I: number;
  124406. readonly RG8I: number;
  124407. readonly RGB8I: number;
  124408. readonly RGBA8I: number;
  124409. readonly R8UI: number;
  124410. readonly RG8UI: number;
  124411. readonly RGB8UI: number;
  124412. readonly RGBA8UI: number;
  124413. readonly R16I: number;
  124414. readonly RG16I: number;
  124415. readonly RGB16I: number;
  124416. readonly RGBA16I: number;
  124417. readonly R16UI: number;
  124418. readonly RG16UI: number;
  124419. readonly RGB16UI: number;
  124420. readonly RGBA16UI: number;
  124421. readonly R32I: number;
  124422. readonly RG32I: number;
  124423. readonly RGB32I: number;
  124424. readonly RGBA32I: number;
  124425. readonly R32UI: number;
  124426. readonly RG32UI: number;
  124427. readonly RGB32UI: number;
  124428. readonly RGBA32UI: number;
  124429. readonly RGB10_A2UI: number;
  124430. readonly R11F_G11F_B10F: number;
  124431. readonly RGB9_E5: number;
  124432. readonly RGB10_A2: number;
  124433. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124434. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124435. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124436. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124437. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124438. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124439. 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;
  124440. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124441. readonly TRANSFORM_FEEDBACK: number;
  124442. readonly INTERLEAVED_ATTRIBS: number;
  124443. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124444. createTransformFeedback(): WebGLTransformFeedback;
  124445. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124446. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124447. beginTransformFeedback(primitiveMode: number): void;
  124448. endTransformFeedback(): void;
  124449. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124450. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124451. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124452. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124453. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124454. }
  124455. interface ImageBitmap {
  124456. readonly width: number;
  124457. readonly height: number;
  124458. close(): void;
  124459. }
  124460. interface WebGLQuery extends WebGLObject {
  124461. }
  124462. declare var WebGLQuery: {
  124463. prototype: WebGLQuery;
  124464. new(): WebGLQuery;
  124465. };
  124466. interface WebGLSampler extends WebGLObject {
  124467. }
  124468. declare var WebGLSampler: {
  124469. prototype: WebGLSampler;
  124470. new(): WebGLSampler;
  124471. };
  124472. interface WebGLSync extends WebGLObject {
  124473. }
  124474. declare var WebGLSync: {
  124475. prototype: WebGLSync;
  124476. new(): WebGLSync;
  124477. };
  124478. interface WebGLTransformFeedback extends WebGLObject {
  124479. }
  124480. declare var WebGLTransformFeedback: {
  124481. prototype: WebGLTransformFeedback;
  124482. new(): WebGLTransformFeedback;
  124483. };
  124484. interface WebGLVertexArrayObject extends WebGLObject {
  124485. }
  124486. declare var WebGLVertexArrayObject: {
  124487. prototype: WebGLVertexArrayObject;
  124488. new(): WebGLVertexArrayObject;
  124489. };
  124490. // Type definitions for WebVR API
  124491. // Project: https://w3c.github.io/webvr/
  124492. // Definitions by: six a <https://github.com/lostfictions>
  124493. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124494. interface VRDisplay extends EventTarget {
  124495. /**
  124496. * Dictionary of capabilities describing the VRDisplay.
  124497. */
  124498. readonly capabilities: VRDisplayCapabilities;
  124499. /**
  124500. * z-depth defining the far plane of the eye view frustum
  124501. * enables mapping of values in the render target depth
  124502. * attachment to scene coordinates. Initially set to 10000.0.
  124503. */
  124504. depthFar: number;
  124505. /**
  124506. * z-depth defining the near plane of the eye view frustum
  124507. * enables mapping of values in the render target depth
  124508. * attachment to scene coordinates. Initially set to 0.01.
  124509. */
  124510. depthNear: number;
  124511. /**
  124512. * An identifier for this distinct VRDisplay. Used as an
  124513. * association point in the Gamepad API.
  124514. */
  124515. readonly displayId: number;
  124516. /**
  124517. * A display name, a user-readable name identifying it.
  124518. */
  124519. readonly displayName: string;
  124520. readonly isConnected: boolean;
  124521. readonly isPresenting: boolean;
  124522. /**
  124523. * If this VRDisplay supports room-scale experiences, the optional
  124524. * stage attribute contains details on the room-scale parameters.
  124525. */
  124526. readonly stageParameters: VRStageParameters | null;
  124527. /**
  124528. * Passing the value returned by `requestAnimationFrame` to
  124529. * `cancelAnimationFrame` will unregister the callback.
  124530. * @param handle Define the hanle of the request to cancel
  124531. */
  124532. cancelAnimationFrame(handle: number): void;
  124533. /**
  124534. * Stops presenting to the VRDisplay.
  124535. * @returns a promise to know when it stopped
  124536. */
  124537. exitPresent(): Promise<void>;
  124538. /**
  124539. * Return the current VREyeParameters for the given eye.
  124540. * @param whichEye Define the eye we want the parameter for
  124541. * @returns the eye parameters
  124542. */
  124543. getEyeParameters(whichEye: string): VREyeParameters;
  124544. /**
  124545. * Populates the passed VRFrameData with the information required to render
  124546. * the current frame.
  124547. * @param frameData Define the data structure to populate
  124548. * @returns true if ok otherwise false
  124549. */
  124550. getFrameData(frameData: VRFrameData): boolean;
  124551. /**
  124552. * Get the layers currently being presented.
  124553. * @returns the list of VR layers
  124554. */
  124555. getLayers(): VRLayer[];
  124556. /**
  124557. * Return a VRPose containing the future predicted pose of the VRDisplay
  124558. * when the current frame will be presented. The value returned will not
  124559. * change until JavaScript has returned control to the browser.
  124560. *
  124561. * The VRPose will contain the position, orientation, velocity,
  124562. * and acceleration of each of these properties.
  124563. * @returns the pose object
  124564. */
  124565. getPose(): VRPose;
  124566. /**
  124567. * Return the current instantaneous pose of the VRDisplay, with no
  124568. * prediction applied.
  124569. * @returns the current instantaneous pose
  124570. */
  124571. getImmediatePose(): VRPose;
  124572. /**
  124573. * The callback passed to `requestAnimationFrame` will be called
  124574. * any time a new frame should be rendered. When the VRDisplay is
  124575. * presenting the callback will be called at the native refresh
  124576. * rate of the HMD. When not presenting this function acts
  124577. * identically to how window.requestAnimationFrame acts. Content should
  124578. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124579. * asynchronously from other displays and at differing refresh rates.
  124580. * @param callback Define the eaction to run next frame
  124581. * @returns the request handle it
  124582. */
  124583. requestAnimationFrame(callback: FrameRequestCallback): number;
  124584. /**
  124585. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124586. * Repeat calls while already presenting will update the VRLayers being displayed.
  124587. * @param layers Define the list of layer to present
  124588. * @returns a promise to know when the request has been fulfilled
  124589. */
  124590. requestPresent(layers: VRLayer[]): Promise<void>;
  124591. /**
  124592. * Reset the pose for this display, treating its current position and
  124593. * orientation as the "origin/zero" values. VRPose.position,
  124594. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124595. * updated when calling resetPose(). This should be called in only
  124596. * sitting-space experiences.
  124597. */
  124598. resetPose(): void;
  124599. /**
  124600. * The VRLayer provided to the VRDisplay will be captured and presented
  124601. * in the HMD. Calling this function has the same effect on the source
  124602. * canvas as any other operation that uses its source image, and canvases
  124603. * created without preserveDrawingBuffer set to true will be cleared.
  124604. * @param pose Define the pose to submit
  124605. */
  124606. submitFrame(pose?: VRPose): void;
  124607. }
  124608. declare var VRDisplay: {
  124609. prototype: VRDisplay;
  124610. new(): VRDisplay;
  124611. };
  124612. interface VRLayer {
  124613. leftBounds?: number[] | Float32Array | null;
  124614. rightBounds?: number[] | Float32Array | null;
  124615. source?: HTMLCanvasElement | null;
  124616. }
  124617. interface VRDisplayCapabilities {
  124618. readonly canPresent: boolean;
  124619. readonly hasExternalDisplay: boolean;
  124620. readonly hasOrientation: boolean;
  124621. readonly hasPosition: boolean;
  124622. readonly maxLayers: number;
  124623. }
  124624. interface VREyeParameters {
  124625. /** @deprecated */
  124626. readonly fieldOfView: VRFieldOfView;
  124627. readonly offset: Float32Array;
  124628. readonly renderHeight: number;
  124629. readonly renderWidth: number;
  124630. }
  124631. interface VRFieldOfView {
  124632. readonly downDegrees: number;
  124633. readonly leftDegrees: number;
  124634. readonly rightDegrees: number;
  124635. readonly upDegrees: number;
  124636. }
  124637. interface VRFrameData {
  124638. readonly leftProjectionMatrix: Float32Array;
  124639. readonly leftViewMatrix: Float32Array;
  124640. readonly pose: VRPose;
  124641. readonly rightProjectionMatrix: Float32Array;
  124642. readonly rightViewMatrix: Float32Array;
  124643. readonly timestamp: number;
  124644. }
  124645. interface VRPose {
  124646. readonly angularAcceleration: Float32Array | null;
  124647. readonly angularVelocity: Float32Array | null;
  124648. readonly linearAcceleration: Float32Array | null;
  124649. readonly linearVelocity: Float32Array | null;
  124650. readonly orientation: Float32Array | null;
  124651. readonly position: Float32Array | null;
  124652. readonly timestamp: number;
  124653. }
  124654. interface VRStageParameters {
  124655. sittingToStandingTransform?: Float32Array;
  124656. sizeX?: number;
  124657. sizeY?: number;
  124658. }
  124659. interface Navigator {
  124660. getVRDisplays(): Promise<VRDisplay[]>;
  124661. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  124662. }
  124663. interface Window {
  124664. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  124665. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  124666. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  124667. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124668. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124669. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  124670. }
  124671. interface Gamepad {
  124672. readonly displayId: number;
  124673. }
  124674. type XRSessionMode =
  124675. | "inline"
  124676. | "immersive-vr"
  124677. | "immersive-ar";
  124678. type XRReferenceSpaceType =
  124679. | "viewer"
  124680. | "local"
  124681. | "local-floor"
  124682. | "bounded-floor"
  124683. | "unbounded";
  124684. type XREnvironmentBlendMode =
  124685. | "opaque"
  124686. | "additive"
  124687. | "alpha-blend";
  124688. type XRVisibilityState =
  124689. | "visible"
  124690. | "visible-blurred"
  124691. | "hidden";
  124692. type XRHandedness =
  124693. | "none"
  124694. | "left"
  124695. | "right";
  124696. type XRTargetRayMode =
  124697. | "gaze"
  124698. | "tracked-pointer"
  124699. | "screen";
  124700. type XREye =
  124701. | "none"
  124702. | "left"
  124703. | "right";
  124704. interface XRSpace extends EventTarget {
  124705. }
  124706. interface XRRenderState {
  124707. depthNear?: number;
  124708. depthFar?: number;
  124709. inlineVerticalFieldOfView?: number;
  124710. baseLayer?: XRWebGLLayer;
  124711. }
  124712. interface XRInputSource {
  124713. handedness: XRHandedness;
  124714. targetRayMode: XRTargetRayMode;
  124715. targetRaySpace: XRSpace;
  124716. gripSpace: XRSpace | undefined;
  124717. gamepad: Gamepad | undefined;
  124718. profiles: Array<string>;
  124719. }
  124720. interface XRSession {
  124721. addEventListener: Function;
  124722. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124723. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  124724. requestAnimationFrame: Function;
  124725. end(): Promise<void>;
  124726. renderState: XRRenderState;
  124727. inputSources: Array<XRInputSource>;
  124728. }
  124729. interface XRReferenceSpace extends XRSpace {
  124730. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  124731. onreset: any;
  124732. }
  124733. interface XRFrame {
  124734. session: XRSession;
  124735. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  124736. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  124737. }
  124738. interface XRViewerPose extends XRPose {
  124739. views: Array<XRView>;
  124740. }
  124741. interface XRPose {
  124742. transform: XRRigidTransform;
  124743. emulatedPosition: boolean;
  124744. }
  124745. declare var XRWebGLLayer: {
  124746. prototype: XRWebGLLayer;
  124747. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  124748. };
  124749. interface XRWebGLLayer {
  124750. framebuffer: WebGLFramebuffer;
  124751. framebufferWidth: number;
  124752. framebufferHeight: number;
  124753. getViewport: Function;
  124754. }
  124755. interface XRRigidTransform {
  124756. position: DOMPointReadOnly;
  124757. orientation: DOMPointReadOnly;
  124758. matrix: Float32Array;
  124759. inverse: XRRigidTransform;
  124760. }
  124761. interface XRView {
  124762. eye: XREye;
  124763. projectionMatrix: Float32Array;
  124764. transform: XRRigidTransform;
  124765. }
  124766. interface XRInputSourceChangeEvent {
  124767. session: XRSession;
  124768. removed: Array<XRInputSource>;
  124769. added: Array<XRInputSource>;
  124770. }